koffi 0.9.33 → 0.9.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CMakeLists.txt +2 -1
- package/README.md +81 -108
- package/package.json +5 -4
- package/src/call_arm32.cc +24 -10
- package/src/call_arm64.cc +6 -2
- package/src/call_x64_sysv.cc +6 -2
- package/src/call_x64_win.cc +6 -2
- package/src/call_x86.cc +7 -3
- package/src/ffi.cc +78 -61
- package/src/ffi.hh +2 -2
- package/src/parser.cc +246 -0
- package/src/parser.hh +63 -0
- package/src/util.cc +23 -0
- package/src/util.hh +3 -0
- package/test/registry/machines.json +70 -0
- package/test/test.js +115 -7
- package/test/tests/misc.js +16 -16
- package/test/tests/raylib.js +8 -8
- package/test/tests/sqlite.js +9 -9
package/test/tests/misc.js
CHANGED
|
@@ -69,25 +69,25 @@ async function test() {
|
|
|
69
69
|
let lib_filename = path.dirname(__filename) + '/../build/misc' + koffi.extension;
|
|
70
70
|
let lib = koffi.load(lib_filename);
|
|
71
71
|
|
|
72
|
-
const FillPack1 = lib.
|
|
73
|
-
const RetPack1 = lib.
|
|
72
|
+
const FillPack1 = lib.func('FillPack1', 'void', ['int', koffi.out(koffi.pointer(Pack1))]);
|
|
73
|
+
const RetPack1 = lib.func('RetPack1', Pack1, ['int']);
|
|
74
74
|
const AddPack1 = lib.fastcall('AddPack1', 'void', ['int', koffi.inout(koffi.pointer(Pack1))]);
|
|
75
|
-
const FillPack2 = lib.
|
|
76
|
-
const RetPack2 = lib.
|
|
75
|
+
const FillPack2 = lib.func('FillPack2', 'void', ['int', 'int', koffi.out(koffi.pointer(Pack2))]);
|
|
76
|
+
const RetPack2 = lib.func('RetPack2', Pack2, ['int', 'int']);
|
|
77
77
|
const AddPack2 = lib.fastcall('AddPack2', 'void', ['int', 'int', koffi.inout(koffi.pointer(Pack2))]);
|
|
78
|
-
const FillPack3 = lib.
|
|
79
|
-
const RetPack3 = lib.
|
|
78
|
+
const FillPack3 = lib.func('FillPack3', 'void', ['int', 'int', 'int', koffi.out(koffi.pointer(Pack3))]);
|
|
79
|
+
const RetPack3 = lib.func('RetPack3', Pack3, ['int', 'int', 'int']);
|
|
80
80
|
const AddPack3 = lib.fastcall('AddPack3', 'void', ['int', 'int', 'int', koffi.inout(koffi.pointer(Pack3))]);
|
|
81
|
-
const ConcatenateToInt1 = lib.
|
|
82
|
-
const ConcatenateToInt4 = lib.
|
|
83
|
-
const ConcatenateToInt8 = lib.
|
|
84
|
-
const ConcatenateToStr1 = lib.
|
|
85
|
-
const ConcatenateToStr4 = lib.
|
|
86
|
-
const ConcatenateToStr8 = lib.
|
|
87
|
-
const MakeBFG = lib.
|
|
88
|
-
const MakePackedBFG = lib.
|
|
89
|
-
const ReturnBigString = lib.
|
|
90
|
-
const PrintFmt = lib.
|
|
81
|
+
const ConcatenateToInt1 = lib.func('ConcatenateToInt1', 'int64_t', Array(12).fill('int8_t'));
|
|
82
|
+
const ConcatenateToInt4 = lib.func('ConcatenateToInt4', 'int64_t', Array(12).fill('int32_t'));
|
|
83
|
+
const ConcatenateToInt8 = lib.func('ConcatenateToInt8', 'int64_t', Array(12).fill('int64_t'));
|
|
84
|
+
const ConcatenateToStr1 = lib.func('ConcatenateToStr1', 'string', [...Array(8).fill('int8_t'), koffi.struct('IJK1', {i: 'int8_t', j: 'int8_t', k: 'int8_t'}), 'int8_t']);
|
|
85
|
+
const ConcatenateToStr4 = lib.func('ConcatenateToStr4', 'string', [...Array(8).fill('int32_t'), koffi.pointer(koffi.struct('IJK4', {i: 'int32_t', j: 'int32_t', k: 'int32_t'})), 'int32_t']);
|
|
86
|
+
const ConcatenateToStr8 = lib.func('ConcatenateToStr8', 'string', [...Array(8).fill('int64_t'), koffi.struct('IJK8', {i: 'int64_t', j: 'int64_t', k: 'int64_t'}), 'int64_t']);
|
|
87
|
+
const MakeBFG = lib.func('BFG __stdcall MakeBFG(_Out_ BFG *p, int x, double y, const char *str)');
|
|
88
|
+
const MakePackedBFG = lib.func('PackedBFG __fastcall MakePackedBFG(int x, double y, _Out_ PackedBFG *p, const char *str)');
|
|
89
|
+
const ReturnBigString = lib.func('const char * __stdcall ReturnBigString(const char *str)');
|
|
90
|
+
const PrintFmt = lib.func('const char *PrintFmt(const char *fmt, ...)');
|
|
91
91
|
|
|
92
92
|
// Simple tests with Pack1
|
|
93
93
|
{
|
package/test/tests/raylib.js
CHANGED
|
@@ -86,14 +86,14 @@ async function test() {
|
|
|
86
86
|
let lib_filename = path.dirname(__filename) + '/../build/raylib' + koffi.extension;
|
|
87
87
|
let lib = koffi.load(lib_filename);
|
|
88
88
|
|
|
89
|
-
const InitWindow = lib.
|
|
90
|
-
const SetTraceLogLevel = lib.
|
|
91
|
-
const SetWindowState = lib.
|
|
92
|
-
const GenImageColor = lib.
|
|
93
|
-
const GetFontDefault = lib.
|
|
94
|
-
const MeasureTextEx = lib.
|
|
95
|
-
const ImageDrawTextEx = lib.
|
|
96
|
-
const ExportImage = lib.
|
|
89
|
+
const InitWindow = lib.func('InitWindow', 'void', ['int', 'int', 'string']);
|
|
90
|
+
const SetTraceLogLevel = lib.func('SetTraceLogLevel', 'void', ['int']);
|
|
91
|
+
const SetWindowState = lib.func('SetWindowState', 'void', ['uint']);
|
|
92
|
+
const GenImageColor = lib.func('GenImageColor', Image, ['int', 'int', Color]);
|
|
93
|
+
const GetFontDefault = lib.func('GetFontDefault', Font, []);
|
|
94
|
+
const MeasureTextEx = lib.func('MeasureTextEx', Vector2, [Font, 'string', 'float', 'float']);
|
|
95
|
+
const ImageDrawTextEx = lib.func('ImageDrawTextEx', 'void', [koffi.pointer(Image), Font, 'string', Vector2, 'float', 'float', Color]);
|
|
96
|
+
const ExportImage = lib.func('ExportImage', 'bool', [Image, 'string']);
|
|
97
97
|
|
|
98
98
|
// We need to call InitWindow before using anything else (such as fonts)
|
|
99
99
|
SetTraceLogLevel(4); // Warnings
|
package/test/tests/sqlite.js
CHANGED
|
@@ -39,15 +39,15 @@ async function test() {
|
|
|
39
39
|
let lib_filename = path.dirname(__filename) + '/../build/sqlite3' + koffi.extension;
|
|
40
40
|
let lib = koffi.load(lib_filename);
|
|
41
41
|
|
|
42
|
-
const sqlite3_open_v2 = lib.
|
|
43
|
-
const sqlite3_exec = lib.
|
|
44
|
-
const sqlite3_prepare_v2 = lib.
|
|
45
|
-
const sqlite3_reset = lib.
|
|
46
|
-
const sqlite3_bind_text = lib.
|
|
47
|
-
const sqlite3_bind_int = lib.
|
|
48
|
-
const sqlite3_step = lib.
|
|
49
|
-
const sqlite3_finalize = lib.
|
|
50
|
-
const sqlite3_close_v2 = lib.
|
|
42
|
+
const sqlite3_open_v2 = lib.func('sqlite3_open_v2', 'int', ['string', koffi.out(koffi.pointer(sqlite3_db)), 'int', 'string']);
|
|
43
|
+
const sqlite3_exec = lib.func('sqlite3_exec', 'int', [sqlite3_db, 'string', 'void *', 'void *', 'void *']);
|
|
44
|
+
const sqlite3_prepare_v2 = lib.func('sqlite3_prepare_v2', 'int', [sqlite3_db, 'string', 'int', koffi.out(koffi.pointer(sqlite3_stmt)), 'string']);
|
|
45
|
+
const sqlite3_reset = lib.func('sqlite3_reset', 'int', [sqlite3_stmt]);
|
|
46
|
+
const sqlite3_bind_text = lib.func('sqlite3_bind_text', 'int', [sqlite3_stmt, 'int', 'string', 'int', 'void *']);
|
|
47
|
+
const sqlite3_bind_int = lib.func('sqlite3_bind_int', 'int', [sqlite3_stmt, 'int', 'int']);
|
|
48
|
+
const sqlite3_step = lib.func('sqlite3_step', 'int', [sqlite3_stmt]);
|
|
49
|
+
const sqlite3_finalize = lib.func('sqlite3_finalize', 'int', [sqlite3_stmt]);
|
|
50
|
+
const sqlite3_close_v2 = lib.func('sqlite3_close_v2', 'int', [sqlite3_db]);
|
|
51
51
|
|
|
52
52
|
let filename = await create_temporary_file(path.join(os.tmpdir(), 'test_sqlite'));
|
|
53
53
|
let db = {};
|