lua-users home
lua-l archive

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


--- El vie 16-dic-11, Patrick Rapin <toupie300@gmail.com> escribió:
> 
> No. The parsing is done manually in C with something like
> "while(isalnum(*ptr++))".
> It was not really difficult.

Yes, I thougth it would be something like it. Thanks a lot for the code.

I would be totally convinced on going this way: 

flags = 'FLAG1,FLAG2,FLAG3'

If it was only lua-to-C direction. Unfortunately, the library I am binding to has both directions. So the thing is, how to return effectively from c-to-lua while keeping a clean interface?

To be more specific, the binding is for DirectFB. So the code would look
like this:

-- 1 
desc = {}
desc.flags = DSDESC_CAPS
desc.caps = DSCAPS_PRIMARY + DSCAPS_FLIPPING
surface = dfb:CreateSurface(desc)

or
-- 2
desc = {}
desc.flags = 'DSDESC_CAPS'
desc.caps = 'DSCAPS_PRIMARY,DSCAPS_FLIPPING'

or
-- 3
desc = {}
desc.flags = {'DSDESC_CAPS', 'DSDESC_ANOTHER'}
desc.caps = {'DSDESC_PRIMARY', 'DSDESC_FLIPPING'}

I really hate to define all as variables, but I don't want to
force the user all that typing. The whole point of the binding 
was being able to write *quick* tests.

Option (2) looks good to me. But, how do I manage return flags?

caps = dfb:GetCapabilities()

For this it would be better to wrap 'em all in tables, but again...
all that typing!!!

I know that *stringify* is the trend in Lua, but this case seems 
to break rules.

Thanks,
Ezequiel.