From 8ca89a09d2e8f213087a48cc016b747cfda260d5 Mon Sep 17 00:00:00 2001 From: zongor Date: Mon, 27 May 2024 21:21:21 -0400 Subject: [PATCH] fix naming bug, add test data --- tools/js-class-c-struct-transpiler/test/testgen.sh | 9 ++++++++- tools/js-class-c-struct-transpiler/transpile.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/js-class-c-struct-transpiler/test/testgen.sh b/tools/js-class-c-struct-transpiler/test/testgen.sh index 00acd90..c78f5a9 100755 --- a/tools/js-class-c-struct-transpiler/test/testgen.sh +++ b/tools/js-class-c-struct-transpiler/test/testgen.sh @@ -1 +1,8 @@ -bun run ../transpile.js -S schema.json -j out/ -c out/ -s out/ \ No newline at end of file +bun run ../transpile.js -S schema.json -j out/ -c out/ -s out/; +rm -rf out/test.db; +sqlite3 out/test.db < out/types.sql; +echo 'INSERT INTO Vector3 (x, y, z) VALUES (-9.0, 9.0, 4.0);' | sqlite3 out/test.db; +echo 'INSERT INTO Vector3 (x, y, z) VALUES (9.0, 9.0, 0.0);' | sqlite3 out/test.db; +echo 'INSERT INTO Vector3 (x, y, z) VALUES (0.0, 1.0, 0.0);' | sqlite3 out/test.db; +echo 'INSERT INTO Camera3D (position_vector3_id, target_vector3_id, up_vector3_id, fovy, projection) VALUES (1, 2, 3, 60.0, 0);' | sqlite3 out/test.db; +echo "INSERT INTO Entity (Name, camera_camera3d_id, Strength, Endurance, Intelligence, Wisdom, Charisma, Faith, Artisan, Metalworking, Alchemy, Engineering, Culinary, Ranged, Melee, Acrobatics, Prestidigitation, Language, Medicine, Thaumatology, Theology, Fishing, Mining, Survival, Gardening, History, Perception, Luck, Stealth, Attractiveness, Affluence, Notoriety) VALUES ('Zongor',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,42,1,1,1,1);" | sqlite3 out/test.db; diff --git a/tools/js-class-c-struct-transpiler/transpile.js b/tools/js-class-c-struct-transpiler/transpile.js index cced04d..e6ee930 100644 --- a/tools/js-class-c-struct-transpiler/transpile.js +++ b/tools/js-class-c-struct-transpiler/transpile.js @@ -142,7 +142,7 @@ for (const type of Object.keys(schema)) { set ${prop}(v) { this._data.set(this._encoder.encode(v), ${parseInt(offset)}); }`; - sqlData += `, ${propType} TEXT`; + sqlData += `, ${prop} TEXT`; cData += ` char ${prop}[${iSize}];`; break;