pocketlang/docs/try/js_api.js

24 lines
725 B
JavaScript
Raw Normal View History

2021-05-12 18:57:35 +08:00
/*
* Copyright (c) 2021 Thakee Nathees
* Licensed under: MIT License
*/
// This will link the javascript C api function.
// Add the option '--js-library pocketlang.js' to link at compiling.
// Reference: https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#implement-a-c-api-in-javascript
mergeInto(LibraryManager.library, {
/** js_func_name : function() {...} */
js_errorPrint : function(message, line) {
2021-05-13 03:28:44 +08:00
var out = document.getElementById("output");
out.innerText += "Error: "+ AsciiToString(message) + " at:" + line + '\n';
2021-05-12 18:57:35 +08:00
},
js_writeFunction : function(message) {
2021-05-13 03:28:44 +08:00
var out = document.getElementById("output");
2021-05-12 18:57:35 +08:00
out.innerText += AsciiToString(message)
},
});