tree-sitter/lib/binding_web/imports.js

26 lines
687 B
JavaScript
Raw Normal View History

2019-04-23 14:29:46 -07:00
mergeInto(LibraryManager.library, {
2024-04-09 21:44:37 -04:00
tree_sitter_parse_callback(
2019-04-23 14:29:46 -07:00
inputBufferAddress,
index,
row,
column,
lengthAddress,
2019-04-23 14:29:46 -07:00
) {
const INPUT_BUFFER_SIZE = 10 * 1024;
2024-04-09 21:44:37 -04:00
const string = currentParseCallback(index, {row, column});
2019-04-26 17:28:15 -07:00
if (typeof string === 'string') {
setValue(lengthAddress, string.length, 'i32');
stringToUTF16(string, inputBufferAddress, INPUT_BUFFER_SIZE);
} else {
setValue(lengthAddress, 0, 'i32');
}
2019-04-23 14:29:46 -07:00
},
2024-04-09 21:44:37 -04:00
tree_sitter_log_callback(isLexMessage, messageAddress) {
2019-04-23 14:29:46 -07:00
if (currentLogCallback) {
const message = UTF8ToString(messageAddress);
2019-04-26 17:28:15 -07:00
currentLogCallback(message, isLexMessage !== 0);
2019-04-23 14:29:46 -07:00
}
},
2019-04-23 14:29:46 -07:00
});