[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Determine if function is defined with C API?
- From: "Patrick J. O'Leary Jr." <polearyjr@...>
- Date: Thu, 31 Jul 2008 20:12:35 -0700
Ben Kelly wrote:
>>>> How would I do something like this? From lua_pcall, I get a return
>>>> value of 2 but is this defined somewhere? Should I just check for
>>>> that value or is there a preferred constant?
>>
>> This requires the function be on the stack and that you know the
>> index, though.
>>
> If he's in a position to use pcall on it, it's already on stack and
> thus using lua_isfunction() is entirely reasonable, no?
> Ben
I took the "return value of 2" to mean lua_pcall returned 2 (which I believe
is LUA_ERRRUN) so perhaps the function is not on the stack? Simply pushing
some random things onto the stack (none of which are functions) and then
calling lua_pcall will give you a return value of 2. It could be the
function is on the stack but the number of arguments (nargs) supplied to
lua_pcall is incorrect. I think further details from Joey are needed.