-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenNoneFfi.js
49 lines (38 loc) · 1.26 KB
/
genNoneFfi.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { readFileSync, writeFileSync } from 'fs';
function readZigFile(filePath) {
const content = readFileSync(filePath, 'utf8');
const lines = content.split('\n');
const functionNames = new Set();
lines.forEach(line => {
const match = line.match(/fn (\w+)/);
if (match) {
functionNames.add(match[1]);
}
});
return functionNames;
}
function readJsonFile(filePath) {
const jsonContent = readFileSync(filePath, 'utf8');
return JSON.parse(jsonContent);
}
function compareAndGenerateNoneffi(zigFunctions, ffiJson, outputFilePath) {
const noneffi = {};
Object.keys(ffiJson).forEach(funcName => {
if (!zigFunctions.has(funcName)) {
noneffi[funcName] = ffiJson[funcName];
}
});
writeFileSync(outputFilePath, JSON.stringify(noneffi, null, 2));
}
function main() {
const zigFilePath = './raylib-zig/lib/raylib-ext.zig';
const ffiJsonFilePath = './ffi.json';
const noneffiJsonFilePath = './noneffi.json';
const zigFunctions = readZigFile(zigFilePath);
console.log(zigFunctions.size);
const ffiJson = readJsonFile(ffiJsonFilePath);
console.log(Object.keys(ffiJson).length);
compareAndGenerateNoneffi(zigFunctions, ffiJson, noneffiJsonFilePath);
console.log('noneffi.json has been generated successfully.');
}
main();