koffi 2.1.0-beta.1 → 2.1.0-beta.2

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.
Files changed (99) hide show
  1. package/CMakeLists.txt +1 -1
  2. package/ChangeLog.md +17 -0
  3. package/build/qemu/2.1.0-beta.2/koffi_darwin_arm64.tar.gz +0 -0
  4. package/build/qemu/2.1.0-beta.2/koffi_darwin_x64.tar.gz +0 -0
  5. package/build/qemu/2.1.0-beta.2/koffi_freebsd_arm64.tar.gz +0 -0
  6. package/build/qemu/2.1.0-beta.2/koffi_freebsd_ia32.tar.gz +0 -0
  7. package/build/qemu/2.1.0-beta.2/koffi_freebsd_x64.tar.gz +0 -0
  8. package/build/qemu/2.1.0-beta.2/koffi_linux_arm32hf.tar.gz +0 -0
  9. package/build/qemu/2.1.0-beta.2/koffi_linux_arm64.tar.gz +0 -0
  10. package/build/qemu/2.1.0-beta.2/koffi_linux_ia32.tar.gz +0 -0
  11. package/build/qemu/2.1.0-beta.2/koffi_linux_riscv64hf64.tar.gz +0 -0
  12. package/build/qemu/2.1.0-beta.2/koffi_linux_x64.tar.gz +0 -0
  13. package/build/qemu/2.1.0-beta.2/koffi_openbsd_ia32.tar.gz +0 -0
  14. package/build/qemu/2.1.0-beta.2/koffi_openbsd_x64.tar.gz +0 -0
  15. package/build/qemu/2.1.0-beta.2/koffi_win32_arm64.tar.gz +0 -0
  16. package/build/qemu/2.1.0-beta.2/koffi_win32_ia32.tar.gz +0 -0
  17. package/build/qemu/2.1.0-beta.2/koffi_win32_x64.tar.gz +0 -0
  18. package/doc/functions.md +67 -1
  19. package/doc/templates/badges.html +1 -2
  20. package/doc/types.md +100 -147
  21. package/package.json +1 -1
  22. package/src/abi_arm32.cc +166 -2
  23. package/src/abi_arm64.cc +195 -2
  24. package/src/abi_riscv64.cc +106 -2
  25. package/src/abi_x64_sysv.cc +113 -3
  26. package/src/abi_x64_win.cc +112 -2
  27. package/src/abi_x86.cc +155 -4
  28. package/src/call.cc +199 -0
  29. package/src/ffi.cc +50 -18
  30. package/src/ffi.hh +12 -0
  31. package/build/qemu/2.1.0-beta.1/koffi_darwin_arm64.tar.gz +0 -0
  32. package/build/qemu/2.1.0-beta.1/koffi_darwin_x64.tar.gz +0 -0
  33. package/build/qemu/2.1.0-beta.1/koffi_freebsd_arm64.tar.gz +0 -0
  34. package/build/qemu/2.1.0-beta.1/koffi_freebsd_ia32.tar.gz +0 -0
  35. package/build/qemu/2.1.0-beta.1/koffi_freebsd_x64.tar.gz +0 -0
  36. package/build/qemu/2.1.0-beta.1/koffi_linux_arm32hf.tar.gz +0 -0
  37. package/build/qemu/2.1.0-beta.1/koffi_linux_arm64.tar.gz +0 -0
  38. package/build/qemu/2.1.0-beta.1/koffi_linux_ia32.tar.gz +0 -0
  39. package/build/qemu/2.1.0-beta.1/koffi_linux_riscv64hf64.tar.gz +0 -0
  40. package/build/qemu/2.1.0-beta.1/koffi_linux_x64.tar.gz +0 -0
  41. package/build/qemu/2.1.0-beta.1/koffi_openbsd_ia32.tar.gz +0 -0
  42. package/build/qemu/2.1.0-beta.1/koffi_openbsd_x64.tar.gz +0 -0
  43. package/build/qemu/2.1.0-beta.1/koffi_win32_arm64.tar.gz +0 -0
  44. package/build/qemu/2.1.0-beta.1/koffi_win32_ia32.tar.gz +0 -0
  45. package/build/qemu/2.1.0-beta.1/koffi_win32_x64.tar.gz +0 -0
  46. package/doc/dist/html/.buildinfo +0 -4
  47. package/doc/dist/html/_sources/benchmarks.md.txt +0 -137
  48. package/doc/dist/html/_sources/changes.md.txt +0 -161
  49. package/doc/dist/html/_sources/contribute.md.txt +0 -127
  50. package/doc/dist/html/_sources/functions.md.txt +0 -355
  51. package/doc/dist/html/_sources/index.rst.txt +0 -39
  52. package/doc/dist/html/_sources/memory.md.txt +0 -32
  53. package/doc/dist/html/_sources/platforms.md.txt +0 -31
  54. package/doc/dist/html/_sources/start.md.txt +0 -100
  55. package/doc/dist/html/_sources/types.md.txt +0 -588
  56. package/doc/dist/html/_static/_sphinx_javascript_frameworks_compat.js +0 -134
  57. package/doc/dist/html/_static/basic.css +0 -932
  58. package/doc/dist/html/_static/bench_linux.png +0 -0
  59. package/doc/dist/html/_static/bench_windows.png +0 -0
  60. package/doc/dist/html/_static/custom.css +0 -22
  61. package/doc/dist/html/_static/debug.css +0 -69
  62. package/doc/dist/html/_static/doctools.js +0 -264
  63. package/doc/dist/html/_static/documentation_options.js +0 -14
  64. package/doc/dist/html/_static/file.png +0 -0
  65. package/doc/dist/html/_static/jquery-3.6.0.js +0 -10881
  66. package/doc/dist/html/_static/jquery.js +0 -2
  67. package/doc/dist/html/_static/language_data.js +0 -199
  68. package/doc/dist/html/_static/minus.png +0 -0
  69. package/doc/dist/html/_static/perf_linux_20220623.png +0 -0
  70. package/doc/dist/html/_static/perf_linux_20220623_2.png +0 -0
  71. package/doc/dist/html/_static/perf_windows_20220623.png +0 -0
  72. package/doc/dist/html/_static/perf_windows_20220623_2.png +0 -0
  73. package/doc/dist/html/_static/plus.png +0 -0
  74. package/doc/dist/html/_static/pygments.css +0 -252
  75. package/doc/dist/html/_static/scripts/furo-extensions.js +0 -0
  76. package/doc/dist/html/_static/scripts/furo.js +0 -3
  77. package/doc/dist/html/_static/scripts/furo.js.LICENSE.txt +0 -7
  78. package/doc/dist/html/_static/scripts/furo.js.map +0 -1
  79. package/doc/dist/html/_static/searchtools.js +0 -531
  80. package/doc/dist/html/_static/skeleton.css +0 -296
  81. package/doc/dist/html/_static/styles/furo-extensions.css +0 -2
  82. package/doc/dist/html/_static/styles/furo-extensions.css.map +0 -1
  83. package/doc/dist/html/_static/styles/furo.css +0 -2
  84. package/doc/dist/html/_static/styles/furo.css.map +0 -1
  85. package/doc/dist/html/_static/underscore-1.13.1.js +0 -2042
  86. package/doc/dist/html/_static/underscore.js +0 -6
  87. package/doc/dist/html/benchmarks.html +0 -572
  88. package/doc/dist/html/changes.html +0 -668
  89. package/doc/dist/html/contribute.html +0 -404
  90. package/doc/dist/html/functions.html +0 -657
  91. package/doc/dist/html/genindex.html +0 -254
  92. package/doc/dist/html/index.html +0 -360
  93. package/doc/dist/html/memory.html +0 -347
  94. package/doc/dist/html/objects.inv +0 -0
  95. package/doc/dist/html/platforms.html +0 -372
  96. package/doc/dist/html/search.html +0 -262
  97. package/doc/dist/html/searchindex.js +0 -1
  98. package/doc/dist/html/start.html +0 -385
  99. package/doc/dist/html/types.html +0 -1097
@@ -1,404 +0,0 @@
1
- <!doctype html>
2
- <html class="no-js" lang="en">
3
- <head><meta charset="utf-8"/>
4
- <meta name="viewport" content="width=device-width,initial-scale=1"/>
5
- <meta name="color-scheme" content="light dark"><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
6
- <link rel="index" title="Index" href="genindex" /><link rel="search" title="Search" href="search" /><link rel="next" title="Changelog" href="changes" /><link rel="prev" title="Benchmarks" href="benchmarks" />
7
-
8
- <meta name="generator" content="sphinx-5.0.1, furo 2022.06.04.1"/>
9
- <title>Contributing - Koffi</title>
10
- <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
11
- <link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=40978830699223671f4072448e654b5958f38b89" />
12
- <link rel="stylesheet" type="text/css" href="_static/styles/furo-extensions.css?digest=30d1aed668e5c3a91c3e3bf6a60b675221979f0e" />
13
- <link rel="stylesheet" type="text/css" href="_static/custom.css" />
14
-
15
-
16
-
17
-
18
- <style>
19
- body {
20
- --color-code-background: #f8f8f8;
21
- --color-code-foreground: black;
22
- --color-brand-primary: #FF6600;
23
- --color-brand-content: #FF6600;
24
-
25
- }
26
- @media not print {
27
- body[data-theme="dark"] {
28
- --color-code-background: #202020;
29
- --color-code-foreground: #d0d0d0;
30
- --color-brand-primary: #FF6600;
31
- --color-brand-content: #FF6600;
32
-
33
- }
34
- @media (prefers-color-scheme: dark) {
35
- body:not([data-theme="light"]) {
36
- --color-code-background: #202020;
37
- --color-code-foreground: #d0d0d0;
38
- --color-brand-primary: #FF6600;
39
- --color-brand-content: #FF6600;
40
-
41
- }
42
- }
43
- }
44
- </style></head>
45
- <body>
46
-
47
- <script>
48
- document.body.dataset.theme = localStorage.getItem("theme") || "auto";
49
- </script>
50
-
51
-
52
- <svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
53
- <symbol id="svg-toc" viewBox="0 0 24 24">
54
- <title>Contents</title>
55
- <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024">
56
- <path d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM115.4 518.9L271.7 642c5.8 4.6 14.4.5 14.4-6.9V388.9c0-7.4-8.5-11.5-14.4-6.9L115.4 505.1a8.74 8.74 0 0 0 0 13.8z"/>
57
- </svg>
58
- </symbol>
59
- <symbol id="svg-menu" viewBox="0 0 24 24">
60
- <title>Menu</title>
61
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
62
- stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-menu">
63
- <line x1="3" y1="12" x2="21" y2="12"></line>
64
- <line x1="3" y1="6" x2="21" y2="6"></line>
65
- <line x1="3" y1="18" x2="21" y2="18"></line>
66
- </svg>
67
- </symbol>
68
- <symbol id="svg-arrow-right" viewBox="0 0 24 24">
69
- <title>Expand</title>
70
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
71
- stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-chevron-right">
72
- <polyline points="9 18 15 12 9 6"></polyline>
73
- </svg>
74
- </symbol>
75
- <symbol id="svg-sun" viewBox="0 0 24 24">
76
- <title>Light mode</title>
77
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
78
- stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather-sun">
79
- <circle cx="12" cy="12" r="5"></circle>
80
- <line x1="12" y1="1" x2="12" y2="3"></line>
81
- <line x1="12" y1="21" x2="12" y2="23"></line>
82
- <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
83
- <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
84
- <line x1="1" y1="12" x2="3" y2="12"></line>
85
- <line x1="21" y1="12" x2="23" y2="12"></line>
86
- <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
87
- <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
88
- </svg>
89
- </symbol>
90
- <symbol id="svg-moon" viewBox="0 0 24 24">
91
- <title>Dark mode</title>
92
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
93
- stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-moon">
94
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
95
- <path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z" />
96
- </svg>
97
- </symbol>
98
- <symbol id="svg-sun-half" viewBox="0 0 24 24">
99
- <title>Auto light/dark mode</title>
100
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
101
- stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-shadow">
102
- <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
103
- <circle cx="12" cy="12" r="9" />
104
- <path d="M13 12h5" />
105
- <path d="M13 15h4" />
106
- <path d="M13 18h1" />
107
- <path d="M13 9h4" />
108
- <path d="M13 6h1" />
109
- </svg>
110
- </symbol>
111
- </svg>
112
-
113
- <input type="checkbox" class="sidebar-toggle" name="__navigation" id="__navigation">
114
- <input type="checkbox" class="sidebar-toggle" name="__toc" id="__toc">
115
- <label class="overlay sidebar-overlay" for="__navigation">
116
- <div class="visually-hidden">Hide navigation sidebar</div>
117
- </label>
118
- <label class="overlay toc-overlay" for="__toc">
119
- <div class="visually-hidden">Hide table of contents sidebar</div>
120
- </label>
121
-
122
-
123
-
124
- <div class="page">
125
- <header class="mobile-header">
126
- <div class="header-left">
127
- <label class="nav-overlay-icon" for="__navigation">
128
- <div class="visually-hidden">Toggle site navigation sidebar</div>
129
- <i class="icon"><svg><use href="#svg-menu"></use></svg></i>
130
- </label>
131
- </div>
132
- <div class="header-center">
133
- <a href="index"><div class="brand">Koffi</div></a>
134
- </div>
135
- <div class="header-right">
136
- <div class="theme-toggle-container theme-toggle-header">
137
- <button class="theme-toggle">
138
- <div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
139
- <svg class="theme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
140
- <svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
141
- <svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
142
- </button>
143
- </div>
144
- <label class="toc-overlay-icon toc-header-icon" for="__toc">
145
- <div class="visually-hidden">Toggle table of contents sidebar</div>
146
- <i class="icon"><svg><use href="#svg-toc"></use></svg></i>
147
- </label>
148
- </div>
149
- </header>
150
- <aside class="sidebar-drawer">
151
- <div class="sidebar-container">
152
-
153
- <div class="sidebar-sticky"><a class="sidebar-brand" href="index">
154
-
155
-
156
- <span class="sidebar-brand-text">Koffi</span>
157
-
158
- </a><form class="sidebar-search-container" method="get" action="search" role="search">
159
- <input class="sidebar-search" placeholder=Search name="q" aria-label="Search">
160
- <input type="hidden" name="check_keywords" value="yes">
161
- <input type="hidden" name="area" value="default">
162
- </form>
163
- <div id="searchbox"></div><div class="sidebar-scroll"><div class="sidebar-tree">
164
- <ul class="current">
165
- <li class="toctree-l1"><a class="reference internal" href="platforms">Requirements</a></li>
166
- <li class="toctree-l1"><a class="reference internal" href="start">Quick start</a></li>
167
- <li class="toctree-l1"><a class="reference internal" href="types">Data types</a></li>
168
- <li class="toctree-l1"><a class="reference internal" href="functions">Functions</a></li>
169
- <li class="toctree-l1"><a class="reference internal" href="memory">Memory usage</a></li>
170
- <li class="toctree-l1"><a class="reference internal" href="benchmarks">Benchmarks</a></li>
171
- <li class="toctree-l1 current current-page"><a class="current reference internal" href="#">Contributing</a></li>
172
- <li class="toctree-l1"><a class="reference internal" href="changes">Changelog</a></li>
173
- </ul>
174
-
175
- </div>
176
- <div style="text-align: center; margin-top: 2em;">
177
- <a href="https://www.npmjs.com/package/koffi"><img src="https://img.shields.io/badge/NPM-2.0.1-brightgreen" alt="NPM"/></a>
178
- <a href="https://github.com/Koromix/luigi/tree/master/koffi"><img src="https://img.shields.io/badge/GitHub-Koffi-ff6600" alt="GitHub"/></a>
179
- </div>
180
- </div>
181
-
182
- </div>
183
-
184
- </div>
185
- </aside>
186
- <div class="main">
187
- <div class="content">
188
- <div class="article-container">
189
- <a href="#" class="back-to-top muted-link">
190
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
191
- <path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12z"></path>
192
- </svg>
193
- <span>Back to top</span>
194
- </a>
195
- <div class="content-icon-container">
196
- <div class="theme-toggle-container theme-toggle-content">
197
- <button class="theme-toggle">
198
- <div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
199
- <svg class="theme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
200
- <svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
201
- <svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
202
- </button>
203
- </div>
204
- <label class="toc-overlay-icon toc-content-icon" for="__toc">
205
- <div class="visually-hidden">Toggle table of contents sidebar</div>
206
- <i class="icon"><svg><use href="#svg-toc"></use></svg></i>
207
- </label>
208
- </div>
209
- <article role="main">
210
- <section id="contributing">
211
- <h1>Contributing<a class="headerlink" href="#contributing" title="Permalink to this heading">#</a></h1>
212
- <section id="bugs-and-feature-requests">
213
- <h2>Bugs and feature requests<a class="headerlink" href="#bugs-and-feature-requests" title="Permalink to this heading">#</a></h2>
214
- <p>Use the official repository (named Luigi, because this is a monorepo containing multiple projects) for bugs, ideas and features requests.</p>
215
- <p>Go here: <a class="reference external" href="https://github.com/Koromix/luigi/">https://github.com/Koromix/luigi/</a></p>
216
- </section>
217
- <section id="build-from-source">
218
- <h2>Build from source<a class="headerlink" href="#build-from-source" title="Permalink to this heading">#</a></h2>
219
- <p>We provide prebuilt binaries, packaged in the NPM archive, so in most cases it should be as simple as <code class="docutils literal notranslate"><span class="pre">npm</span> <span class="pre">install</span> <span class="pre">koffi</span></code>. If you want to hack Koffi or use a specific platform, follow the instructions below.</p>
220
- <p>Start by cloning the repository with <a class="reference external" href="https://git-scm.com/">Git</a>:</p>
221
- <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span>git clone https://github.com/Koromix/luigi
222
- <span class="linenos">2</span><span class="nb">cd</span> luigi/koffi
223
- </pre></div>
224
- </div>
225
- <p>As said before, this is a monorepository containg multiple projects, hence the name.</p>
226
- <section id="windows">
227
- <h3>Windows<a class="headerlink" href="#windows" title="Permalink to this heading">#</a></h3>
228
- <p>First, make sure the following dependencies are met:</p>
229
- <ul class="simple">
230
- <li><p>The “Desktop development with C++” workload from <a class="reference external" href="https://visualstudio.microsoft.com/downloads/">Visual Studio 2022 or 2019</a> or the “C++ build tools” workload from the <a class="reference external" href="https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022">Build Tools</a>, with the default optional components.</p></li>
231
- <li><p><a class="reference external" href="https://cmake.org/">CMake meta build system</a></p></li>
232
- <li><p><a class="reference external" href="https://nodejs.org/">Node.js</a> 12 or later</p></li>
233
- </ul>
234
- <p>Once this is done, run this command <em>from the test or the benchmark directory</em> (depending on what you want to build):</p>
235
- <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">cd</span> koffi/test <span class="c1"># or cd koffi/benchmark</span>
236
- <span class="linenos">2</span>node ../../cnoke/cnoke.js
237
- </pre></div>
238
- </div>
239
- </section>
240
- <section id="other-platforms">
241
- <h3>Other platforms<a class="headerlink" href="#other-platforms" title="Permalink to this heading">#</a></h3>
242
- <p>Make sure the following dependencies are met:</p>
243
- <ul class="simple">
244
- <li><p><code class="docutils literal notranslate"><span class="pre">gcc</span></code> and <code class="docutils literal notranslate"><span class="pre">g++</span></code> &gt;= 8.3 or newer</p></li>
245
- <li><p>GNU Make 3.81 or newer</p></li>
246
- <li><p><a class="reference external" href="https://cmake.org/">CMake meta build system</a></p></li>
247
- <li><p><a class="reference external" href="https://nodejs.org/">Node.js</a> 12 or later</p></li>
248
- </ul>
249
- <p>Once this is done, run this command <em>from the test or the benchmark directory</em> (depending on what you want to build):</p>
250
- <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">cd</span> koffi/test <span class="c1"># or cd koffi/benchmark</span>
251
- <span class="linenos">2</span>node ../../cnoke/cnoke.js
252
- </pre></div>
253
- </div>
254
- </section>
255
- </section>
256
- <section id="running-tests">
257
- <h2>Running tests<a class="headerlink" href="#running-tests" title="Permalink to this heading">#</a></h2>
258
- <p>Koffi is tested on multiple architectures using emulated (accelerated when possible) QEMU machines. First, you need to install qemu packages, such as <code class="docutils literal notranslate"><span class="pre">qemu-system</span></code> (or even <code class="docutils literal notranslate"><span class="pre">qemu-system-gui</span></code>) on Ubuntu.</p>
259
- <p>These machines are not included directly in this repository (for license and size reasons), but they are available here: <a class="reference external" href="https://koromix.dev/files/machines/">https://koromix.dev/files/machines/</a></p>
260
- <p>For example, if you want to run the tests on Debian ARM64, run the following commands:</p>
261
- <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">cd</span> luigi/koffi/qemu/
262
- <span class="linenos">2</span>wget -q -O- https://koromix.dev/files/machines/qemu_debian_arm64.tar.zst <span class="p">|</span> zstd -d <span class="p">|</span> tar xv
263
- <span class="linenos">3</span>sha256sum -c --ignore-missing registry/sha256sum.txt
264
- </pre></div>
265
- </div>
266
- <p>Note that the machine disk content may change each time the machine runs, so the checksum test will fail once a machine has been used at least once.</p>
267
- <p>And now you can run the tests with:</p>
268
- <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span>node qemu.js <span class="nb">test</span> <span class="c1"># Several options are available, use --help</span>
269
- </pre></div>
270
- </div>
271
- <p>And be patient, this can be pretty slow for emulated machines. The Linux machines have and use ccache to build Koffi, so subsequent build steps will get much more tolerable.</p>
272
- <p>By default, machines are started and stopped for each test. But you can start the machines ahead of time and run the tests multiple times instead:</p>
273
- <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span>node qemu.js start <span class="c1"># Start the machines</span>
274
- <span class="linenos">2</span>node qemu.js <span class="nb">test</span> <span class="c1"># Test (without shutting down)</span>
275
- <span class="linenos">3</span>node qemu.js <span class="nb">test</span> <span class="c1"># Test again</span>
276
- <span class="linenos">4</span>node qemu.js stop <span class="c1"># Stop everything</span>
277
- </pre></div>
278
- </div>
279
- <p>You can also restrict the test to a subset of machines:</p>
280
- <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="c1"># Full test cycle</span>
281
- <span class="linenos">2</span>node qemu.js <span class="nb">test</span> debian_x64 debian_i386
282
- <span class="linenos">3</span>
283
- <span class="linenos">4</span><span class="c1"># Separate start, test, shutdown</span>
284
- <span class="linenos">5</span>node qemu.js start debian_x64 debian_i386
285
- <span class="linenos">6</span>node qemu.js <span class="nb">test</span> debian_x64 debian_i386
286
- <span class="linenos">7</span>node qemu.js stop
287
- </pre></div>
288
- </div>
289
- <p>Finally, you can join a running machine with SSH with the following shortcut, if you need to do some debugging or any other manual procedure:</p>
290
- <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span>node qemu.js ssh debian_i386
291
- </pre></div>
292
- </div>
293
- <p>Each machine is configured to run a VNC server available locally, which you can use to access the display, using KRDC or any other compatible viewer. Use the <code class="docutils literal notranslate"><span class="pre">info</span></code> command to get the VNC port.</p>
294
- <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span>node qemu.js info debian_x64
295
- </pre></div>
296
- </div>
297
- </section>
298
- <section id="todo-list">
299
- <h2>Todo list<a class="headerlink" href="#todo-list" title="Permalink to this heading">#</a></h2>
300
- <p>The following features and improvements are planned, not necessarily in that order:</p>
301
- <ul class="simple">
302
- <li><p>Optimize passing of structs and arrays (avoid setting named properties one by one? separate HFA-specific helper functions?)</p></li>
303
- <li><p>Automate Windows/AArch64 (qemu) and macOS/AArch64 (how? … thanks Apple) tests</p></li>
304
- <li><p>Create a real-world example, using several libraries (Raylib, SQLite, libsodium) to illustrate various C API styles</p></li>
305
- <li><p>Add simple struct type parser</p></li>
306
- <li><p>Add more ways to manually encode and decode various types to and from byte arrays</p></li>
307
- <li><p>Add support for unions</p></li>
308
- <li><p>Port Koffi to PowerPC (POWER9+) ABI</p></li>
309
- <li><p>Fix assembly unwind and CFI directives for better debugging experience</p></li>
310
- </ul>
311
- </section>
312
- <section id="code-style">
313
- <h2>Code style<a class="headerlink" href="#code-style" title="Permalink to this heading">#</a></h2>
314
- <p>Koffi is programmed in a mix of C++ and assembly code (architecture-specific code). It uses <a class="reference external" href="https://github.com/nodejs/node-addon-api">node-addon-api</a> (C++ N-API wrapper) to interact with Node.js.</p>
315
- <p>My personal preference goes to a rather C-like C++ style, with careful use of templates (mainly for containers) and little object-oriented programming. I strongly prefer tagged unions and code locality over inheritance and virtual methods. Exceptions are disabled.</p>
316
- </section>
317
- </section>
318
-
319
- </article>
320
- </div>
321
- <footer>
322
-
323
- <div class="related-pages">
324
- <a class="next-page" href="changes">
325
- <div class="page-info">
326
- <div class="context">
327
- <span>Next</span>
328
- </div>
329
- <div class="title">Changelog</div>
330
- </div>
331
- <svg><use href="#svg-arrow-right"></use></svg>
332
- </a>
333
- <a class="prev-page" href="benchmarks">
334
- <svg><use href="#svg-arrow-right"></use></svg>
335
- <div class="page-info">
336
- <div class="context">
337
- <span>Previous</span>
338
- </div>
339
-
340
- <div class="title">Benchmarks</div>
341
-
342
- </div>
343
- </a>
344
- </div>
345
- <div class="bottom-of-page">
346
- <div class="left-details">
347
- <div class="copyright">
348
- Copyright &#169; 2022, Niels Martignène
349
- </div>
350
- Made with <a href="https://www.sphinx-doc.org/">Sphinx</a> and <a class="muted-link" href="https://pradyunsg.me">@pradyunsg</a>'s
351
-
352
- <a href="https://github.com/pradyunsg/furo">Furo</a>
353
-
354
- </div>
355
- <div class="right-details">
356
- <div class="icons">
357
-
358
- </div>
359
- </div>
360
- </div>
361
-
362
- </footer>
363
- </div>
364
- <aside class="toc-drawer">
365
-
366
-
367
- <div class="toc-sticky toc-scroll">
368
- <div class="toc-title-container">
369
- <span class="toc-title">
370
- Contents
371
- </span>
372
- </div>
373
- <div class="toc-tree-container">
374
- <div class="toc-tree">
375
- <ul>
376
- <li><a class="reference internal" href="#">Contributing</a><ul>
377
- <li><a class="reference internal" href="#bugs-and-feature-requests">Bugs and feature requests</a></li>
378
- <li><a class="reference internal" href="#build-from-source">Build from source</a><ul>
379
- <li><a class="reference internal" href="#windows">Windows</a></li>
380
- <li><a class="reference internal" href="#other-platforms">Other platforms</a></li>
381
- </ul>
382
- </li>
383
- <li><a class="reference internal" href="#running-tests">Running tests</a></li>
384
- <li><a class="reference internal" href="#todo-list">Todo list</a></li>
385
- <li><a class="reference internal" href="#code-style">Code style</a></li>
386
- </ul>
387
- </li>
388
- </ul>
389
-
390
- </div>
391
- </div>
392
- </div>
393
-
394
-
395
- </aside>
396
- </div>
397
- </div><script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
398
- <script src="_static/jquery.js"></script>
399
- <script src="_static/underscore.js"></script>
400
- <script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
401
- <script src="_static/doctools.js"></script>
402
- <script src="_static/scripts/furo.js"></script>
403
- </body>
404
- </html>