comparison Platforms/Wasm/default-library.js @ 603:70992b38aa8a

new routable logging system in STDIO mode + flag support (with no value) in StartupParametersBuilder + 80 col indent
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 29 Apr 2019 15:09:48 +0200
parents 7105a0bad250
children
comparison
equal deleted inserted replaced
602:03c4b998fcd0 603:70992b38aa8a
1 // this file contains the JS method you want to expose to C++ code 1 // this file contains the JS method you want to expose to C++ code
2 2
3 mergeInto(LibraryManager.library, { 3 mergeInto(LibraryManager.library, {
4
4 ScheduleWebViewportRedrawFromCpp: function(cppViewportHandle) { 5 ScheduleWebViewportRedrawFromCpp: function(cppViewportHandle) {
5 window.ScheduleWebViewportRedraw(cppViewportHandle); 6 window.ScheduleWebViewportRedraw(cppViewportHandle);
6 }, 7 },
8
7 CreateWasmViewportFromCpp: function(htmlCanvasId) { 9 CreateWasmViewportFromCpp: function(htmlCanvasId) {
8 return window.CreateWasmViewport(htmlCanvasId); 10 return window.CreateWasmViewport(htmlCanvasId);
9 }, 11 },
12
10 // each time the StoneApplication updates its status, it may signal it 13 // each time the StoneApplication updates its status, it may signal it
11 // through this method. i.e, to change the status of a button in the web interface 14 // through this method. i.e, to change the status of a button in the web interface
12 UpdateStoneApplicationStatusFromCppWithString: function(statusUpdateMessage) { 15 UpdateStoneApplicationStatusFromCppWithString: function(statusUpdateMessage) {
13 var statusUpdateMessage_ = UTF8ToString(statusUpdateMessage); 16 var statusUpdateMessage_ = UTF8ToString(statusUpdateMessage);
14 window.UpdateWebApplicationWithString(statusUpdateMessage_); 17 window.UpdateWebApplicationWithString(statusUpdateMessage_);
15 }, 18 },
19
16 // same, but with a serialized message 20 // same, but with a serialized message
17 UpdateStoneApplicationStatusFromCppWithSerializedMessage: function(statusUpdateMessage) { 21 UpdateStoneApplicationStatusFromCppWithSerializedMessage: function(statusUpdateMessage) {
18 var statusUpdateMessage_ = UTF8ToString(statusUpdateMessage); 22 var statusUpdateMessage_ = UTF8ToString(statusUpdateMessage);
19 window.UpdateWebApplicationWithSerializedMessage(statusUpdateMessage_); 23 window.UpdateWebApplicationWithSerializedMessage(statusUpdateMessage_);
24 },
25
26 // These functions are called from C++ (through an extern declaration)
27 // and call the standard logger that, here, routes to the console.
28
29 stone_console_error : function(message) {
30 var text = UTF8ToString(message);
31 window.errorFromCpp(text);
32 },
33
34 stone_console_warning : function(message) {
35 var text = UTF8ToString(message);
36 window.warningFromCpp(text);
37 },
38
39 stone_console_info: function(message) {
40 var text = UTF8ToString(message);
41 window.infoFromCpp(text);
42 },
43
44 stone_console_trace : function(message) {
45 var text = UTF8ToString(message);
46 window.debugFromCpp(text);
20 } 47 }
48
21 }); 49 });