comparison Platforms/Wasm/stone-framework-loader.ts @ 526:548eed46f535 dev

introduced a Logger class that displays timing and source (C++/JS)
author Alain Mazy <alain@mazy.be>
date Thu, 14 Mar 2019 19:04:35 +0100
parents 5055031f4a06
children 70992b38aa8a
comparison
equal deleted inserted replaced
524:9e241cef32a4 526:548eed46f535
1 /** 1 /**
2 * This file contains primitives to interface with WebAssembly and 2 * This file contains primitives to interface with WebAssembly and
3 * with the Stone framework. 3 * with the Stone framework.
4 **/ 4 **/
5 import * as Logger from './logger'
5 6
6 export declare type InitializationCallback = () => void; 7 export declare type InitializationCallback = () => void;
7 8
8 //export declare var StoneFrameworkModule : any; 9 //export declare var StoneFrameworkModule : any;
9 export var StoneFrameworkModule : any; 10 export var StoneFrameworkModule : any;
54 55
55 56
56 public static Initialize( verbose: boolean, 57 public static Initialize( verbose: boolean,
57 callback: InitializationCallback) 58 callback: InitializationCallback)
58 { 59 {
59 console.log('Initializing WebAssembly Module'); 60 Logger.defaultLogger.debug('Initializing WebAssembly Module');
60 61
61 // (<any> window). 62 // (<any> window).
62 (<any> window).StoneFrameworkModule = { 63 (<any> window).StoneFrameworkModule = {
63 preRun: [ 64 preRun: [
64 function() { 65 function() {
65 console.log('Loading the Stone Framework using WebAssembly'); 66 Logger.defaultLogger.debug('Loading the Stone Framework using WebAssembly');
66 } 67 }
67 ], 68 ],
68 postRun: [ 69 postRun: [
69 function() { 70 function() {
70 // This function is called by ".js" wrapper once the ".wasm" 71 // This function is called by ".js" wrapper once the ".wasm"
71 // WebAssembly module has been loaded and compiled by the 72 // WebAssembly module has been loaded and compiled by the
72 // browser 73 // browser
73 console.log('WebAssembly is ready'); 74 Logger.defaultLogger.debug('WebAssembly is ready');
74 Framework.singleton_ = new Framework(verbose); 75 Framework.singleton_ = new Framework(verbose);
75 callback(); 76 callback();
76 } 77 }
77 ], 78 ],
78 print: function(text : string) { 79 print: function(text : string) {
79 console.log(text); 80 Logger.defaultLogger.infoFromCpp(text);
80 }, 81 },
81 printErr: function(text : string) { 82 printErr: function(text : string) {
82 console.error(text); 83 Logger.defaultLogger.errorFromCpp(text);
83 }, 84 },
84 totalDependencies: 0 85 totalDependencies: 0
85 }; 86 };
86 87
87 // Dynamic loading of the JavaScript wrapper around WebAssembly 88 // Dynamic loading of the JavaScript wrapper around WebAssembly