lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Francesco Abbate wrote:
> The ffi.typeof function return a function that creates an object of a
> given ctype. Why do not add a function:
> 
> ffi.istype
> 
> that return a function that check the type of a cdata.

The need to create and manage special predicate functions would
complicate things too much.

I've chosen to do it in the style of the other ffi.* functions that
accept a ct (cdecl, ctype or template cdata) as the first argument.

See: http://luajit.org/ext_ffi_api.html#ffi_istype

And, yes, this function is JIT-compiled. The input types are usually
constant or already checked, so this should be a zero-cost check
in most use cases.

--Mike