Mercurial > hg > orthanc-stone
comparison Platforms/Wasm/Defaults.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 | e74f9271d653 |
children | 97a16b694321 |
comparison
equal
deleted
inserted
replaced
507:ce49eae4c887 | 508:7105a0bad250 |
---|---|
340 void EMSCRIPTEN_KEEPALIVE ViewportMouseLeave(ViewportHandle viewport) | 340 void EMSCRIPTEN_KEEPALIVE ViewportMouseLeave(ViewportHandle viewport) |
341 { | 341 { |
342 viewport->MouseLeave(); | 342 viewport->MouseLeave(); |
343 } | 343 } |
344 | 344 |
345 const char* EMSCRIPTEN_KEEPALIVE SendMessageToStoneApplication(const char* message) | 345 const char* EMSCRIPTEN_KEEPALIVE SendSerializedMessageToStoneApplication(const char* message) |
346 { | 346 { |
347 static std::string output; // we don't want the string to be deallocated when we return to JS code so we always use the same string (this is fine since JS is single-thread) | 347 static std::string output; // we don't want the string to be deallocated when we return to JS code so we always use the same string (this is fine since JS is single-thread) |
348 | 348 |
349 printf("SendMessageToStoneApplication (JS -> C++): %s\n", message); | 349 printf("SendSerializedMessageToStoneApplication\n"); |
350 printf("%s", message); | |
350 | 351 |
351 if (applicationWasmAdapter.get() != NULL) { | 352 if (applicationWasmAdapter.get() != NULL) { |
352 applicationWasmAdapter->HandleMessageFromWeb(output, std::string(message)); | 353 printf("sending serialized message to C++\n"); |
354 applicationWasmAdapter->HandleSerializedMessageFromWeb(output, std::string(message)); | |
353 return output.c_str(); | 355 return output.c_str(); |
354 } | 356 } |
355 printf("This stone application does not have a Web Adapter\n"); | 357 printf("This Stone application does not have a Web Adapter"); |
356 return NULL; | 358 return NULL; |
357 } | 359 } |
358 | 360 |
361 const char* EMSCRIPTEN_KEEPALIVE SendCommandToStoneApplication(const char* message) | |
362 { | |
363 static std::string output; // we don't want the string to be deallocated when we return to JS code so we always use the same string (this is fine since JS is single-thread) | |
364 | |
365 printf("SendCommandToStoneApplication\n"); | |
366 printf("%s", message); | |
367 | |
368 if (applicationWasmAdapter.get() != NULL) { | |
369 printf("sending command to C++\n"); | |
370 applicationWasmAdapter->HandleCommandFromWeb(output, std::string(message)); | |
371 return output.c_str(); | |
372 } | |
373 printf("This Stone application does not have a Web Adapter"); | |
374 return NULL; | |
375 } | |
359 | 376 |
360 #ifdef __cplusplus | 377 #ifdef __cplusplus |
361 } | 378 } |
362 #endif | 379 #endif |