<p>I've heard that Lua's FFI is wonderful. Maybe we should take a look how did they tackle this problem.</p>
<p>After some quick digging around, here is the code setting up the arguments:<br>
<a href="https://github.com/LuaJIT/LuaJIT/blob/v2.1/src/lj_ccall.c#L917">https://github.com/LuaJIT/LuaJIT/blob/v2.1/src/lj_ccall.c#L917</a></p>
<p>Here are the x64 specific defines used by the setting up code:<br>
<a href="https://github.com/LuaJIT/LuaJIT/blob/v2.1/src/lj_ccall.c#L132">https://github.com/LuaJIT/LuaJIT/blob/v2.1/src/lj_ccall.c#L132</a></p>
<p>They definitely have all the type information. They get it from parsing the C declarations.</p>
<p>Here is an example of the declaration part:<br>
<a href="https://github.com/luapower/chipmunk/blob/master/chipmunk_h.lua">https://github.com/luapower/chipmunk/blob/master/chipmunk_h.lua</a><br>
And the usage:<br>
<a href="https://github.com/luapower/chipmunk/blob/master/chipmunk_demo.lua">https://github.com/luapower/chipmunk/blob/master/chipmunk_demo.lua</a></p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/443?email_source=notifications&email_token=AIJPEW2BE7UH64VU4ZZTKH3QSU7IBA5CNFSM4JJ3EAU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDQB7AQ#issuecomment-551559042">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AIJPEWYMYKO2XUTROLXZSCDQSU7IBANCNFSM4JJ3EAUQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AIJPEW7RPBYPDCJOPXOSJ6DQSU7IBA5CNFSM4JJ3EAU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDQB7AQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/443?email_source=notifications\u0026email_token=AIJPEW2BE7UH64VU4ZZTKH3QSU7IBA5CNFSM4JJ3EAU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDQB7AQ#issuecomment-551559042",
"url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/443?email_source=notifications\u0026email_token=AIJPEW2BE7UH64VU4ZZTKH3QSU7IBA5CNFSM4JJ3EAU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDQB7AQ#issuecomment-551559042",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>