Re: getting Lua state in FFI function

  • From: Dan Eloff <dan.eloff@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 18 Apr 2013 08:17:34 -0500

No, you're thinking about this backwards. You can't mix the ffi and the
classical Lua C api. So trying to get the Lua callstack from a C function
called via the ffi is a bad idea, it shouldn't even be aware of Lua.

Better is to return an error code from your function and construct the
error message with callstack in the calling Lua code.

Cheers,
Dan


On Thu, Apr 18, 2013 at 3:43 AM, Stefan Hett <stefan@xxxxxxxxxxx> wrote:

> Or maybe more a concrete question:
> Is there a way to get the lua callstack in an function called via the FFI,
> so we'd issue a useful error message showing which script
> (linenumber/function) made the call?
>
> If not, did s/o already handle the case in some other way?
>
> Regards,
> Stefan
>
>
>  Hi,
>>
>> When calling my FFI-bound function void Foo(), I'd like to know from
>> which luastate the call was issued. Is there an easy way to get the
>> luastate?
>>
>> I couldn't find anything in the documentation or on the web. Did I
>> overlook something?
>>
>> Regards,
>> Stefan
>>
>>
>>
>
>

Other related posts: