[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: question about cdata type identification
- From: Mike Pall <mikelu-1104@...>
- Date: Wed, 20 Apr 2011 02:05:53 +0200
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