RE: FFI enums are now always boxed

  • From: William Adams <william_a_adams@xxxxxxx>
  • To: <luajit@xxxxxxxxxxxxx>
  • Date: Wed, 18 Jul 2012 02:22:33 +0000

Well, this is great as I've just been doing some 

network programming, and being able to just

use "WOULDBLOCK" everywhere is a good thing (tm).
===============================

- Shaping clay is easier than digging it out of the ground.
http://williamaadams.wordpress.com
https://github.com/Wiladams

 
> 
> Here's an example from the expat API:
> 
> ffi.cdef[[
> enum XML_Status {
> XML_STATUS_ERROR = 0,
> XML_STATUS_OK = 1,
> XML_STATUS_SUSPENDED = 2
> };
> // ... Needs more declarations ...
> enum XML_Status XML_StopParser(XML_Parser parser, uint8_t resumable);
> ]]
> 
> if lib.XML_StopParser(parser, 1) ~= "XML_STATUS_OK" then
> ...
> end
> 
> You couldn't do this before, because the enum type was lost with
> the implicit conversion to a number (and a number never compares
> equal to a string).
> 
> --Mike
>                                         

Other related posts: