Re: Some form of __thiscall support

  • From: Mike Pall <mike-1206@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 27 Jun 2012 00:14:35 +0200

Claire Lewis wrote:
> It would be pretty handy to have some sort of support for
> marking functions as “__thiscall” calling convention (or
> equivalent), such that one could directly use the decorated C++
> names, passing ‘this’ as the first argument.

Actually, the __thiscall declaration already works. But the call
setup is still wrong.

> On some platforms, this is already the case I think?
> 
> On Windows 64 bit I believe this works fine, but not on 32 bit,
> which uses ECX to represent ‘this’, and this is different from
> the normal calling convention.

__thiscall only exists on Windows/x86. It's ignored on Windows/x64
by MS tools and it would probably be considered an error on all
other platforms. The FFI simply ignores it, except for x86.

> Anyway, just thought I’d bring it up, as it would remove the
> need for lots of silly little C stub functions that basically
> just do the same thing.

I'll see what I can do. Shouldn't be too difficult to fix, but
might be a bit tricky to test.

--Mike

Other related posts: