Normalize identifiers to - instead of _

As a result
 - The error messages will now show the error with `-` instead of `_`
 - The LSP will auto-complete with -
 - The interpreter's list of properties will list the property with '-'
   (but we made the change so that set_property, get_property, and so on
   work also if passed a '-')
This commit is contained in:
Olivier Goffart 2021-08-10 18:03:59 +02:00 committed by Olivier Goffart
parent 9c95da8a7c
commit c25538c982
49 changed files with 327 additions and 272 deletions

View file

@ -77,18 +77,18 @@ interface Callback {
require.extensions['.60'] =
function (module, filename) {
var c = native.load(filename);
module.exports[c.name()] = function (init_properties: any) {
module.exports[c.name().replaceAll('-', '_')] = function (init_properties: any) {
let comp = c.create(init_properties);
let ret = new Component(comp);
c.properties().forEach((x: string) => {
Object.defineProperty(ret, x, {
Object.defineProperty(ret, x.replaceAll('-', '_'), {
get() { return comp.get_property(x); },
set(newValue) { comp.set_property(x, newValue); },
enumerable: true,
})
});
c.callbacks().forEach((x: string) => {
Object.defineProperty(ret, x, {
Object.defineProperty(ret, x.replaceAll('-', '_'), {
get() {
let callback = function () { return comp.invoke_callback(x, [...arguments]); } as Callback;
callback.setHandler = function (callback) { comp.connect_callback(x, callback) };