NAME
App::EvalServerAdvanced::ConstantCalc - A basic bitwise calculator supporting bitwise operations
DESCRIPTION
This module handles calculating bitwise expressions using constant values. Things like O_CREAT|O_RDWR|O_EXCL|O_CLOEXEC. Mainly intended to be used for parsing rules/values for Seccomp plugins for App::EvalServerAdvanced but does not depend on it.
FEATURES
- Bitwise operators
-
All bitwise operators | & ~ and ^ are supported. Along with a special bitwise inverse with built in masking, ~[16] will negate all the bits, and apply a 16 bit mask to the resulting value.
Precedence is the same as Perl and C, where & has higher precedence and | and ^ are the same. ~ has the highest precedence.
- Constant value definition
-
You can predefine constants to be available to expressions so that you don't have to remember that O_RDONLY is 0, O_RDRW is 4. This means that your expressions can be made to show your intent rather than just some magic number.
METHODS
- new
-
Constructor, can take a single argument
constants
that is a has of any constants you want to define. - add_constant
-
Add a constant at runtime, takes two arguments
$key
and$value
. Will prevent you from setting up invalid constants or ones with an invalid value.Valid keys begin with
/[a-z_]/i
and are followed by/[a-z0-9_]/i
. Valid values are any integer. - get_value
-
Takes a
$key
gives back the corrosponding value for the constant. Most likely not useful for anybody, but used internally to do the lookup. Will die if the constant doesn't exist.
SEE ALSO
App::EvalServerAdvanced, Parser::MGC
AUTHOR
Ryan Voots <simcop@cpan.org>