spiegel-keyman/core/include/ldml/ldml-const-builder.ts
Steven R. Loomis 1f4509f29b feat(core): constant generator between core and developer
- resolved review comments
2022-08-09 14:14:20 -05:00

27 lines
877 B
TypeScript

import { constants } from './keyboardprocessor_ldml';
const keys = Object.keys(constants);
keys.sort();
console.log(`//
// Generated File - do not edit
//
// This file is generated by core/tools/ldml-const-builder/build.sh
// based on core/include/ldml/keyboardprocessor_ldml.ts
//
#pragma once`);
for (const key of keys) {
const value = constants[key];
const upkey = key.toUpperCase();
const type = typeof value;
if ((key.indexOf('section_') === 0) && type === 'string' && value.length === 4) {
// the 4-char section ID strings get handled specially
console.log('// Section ID');
console.log(`#define LDML_${upkey} ((uint32_t)'${value}')`);
} else if (type === 'number') {
console.log(`#define LDML_${upkey} ${value}`);
} else if (type === 'string') {
console.log(`#define LDML_${upkey} "${value}"`);
}
}