[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Exposing emum flags from the C-API
- From: "Jasper Klein" <jasper@...>
- Date: Fri, 15 Jul 2022 22:25:59 +0200
Op Thu, 14 Jul 2022 23:50:38 +0200 schreef Sean Conner <sean@conman.org>:
Only if the program isn't running fast enough. If no one complains, then
it isn't an issue.
That is right.
I think a very few use the library and have no complains so far.
The biggest issue I have is the cumbersome method of testing if a flag is set.
I've solved this several ways. At work, we have a data file that contains
a 32-bit value that defines a bunch of flags. In the Lua module, I
break this field out to individial boolean values:
licensed = true,
mdn = true,
min = false,
capable = true,
company = false,
trace = true,
-- ...
The original module was written when Lua 5.1 was the latest version, which
is why I did it this way (no bit module, no bit operations). It hasn't been
a performance issue for us (we use this code to handle actual phone calls
being made for the Oligarchic Cell Phone company). If you go this way, then
your code above could be:
if variable_with_permissions.owner_write then
-- ...
end
This could be a candidate. It is clean and simple to use.
[2] I wrote my own POSIX wrapper:
https://github.com/spc476/lua-conmanorg/blob/master/src/fsys.c
I know I'm not the first one and certainly not the last that writes yet another filesystem wrapper. :-)
-- Jasper