Class: Seccomp::ArgCmp
- Inherits:
-
Object
- Object
- Seccomp::ArgCmp
- Defined in:
- lib/seccomp/arg.rb
Overview
Immutable syscall argument comparison.
Constant Summary collapse
- MAX_DATUM =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Largest accepted unsigned syscall datum.
(1 << 64) - 1
- OPERATORS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Symbol-to-C-operator lookup.
{ ne: Compare::NE, lt: Compare::LT, le: Compare::LE, eq: Compare::EQ, ge: Compare::GE, gt: Compare::GT, masked_eq: Compare::MASKED_EQ }.freeze
Instance Attribute Summary collapse
-
#arg ⇒ Object
readonly
Returns the value of attribute arg.
-
#datum_a ⇒ Object
readonly
Returns the value of attribute datum_a.
-
#datum_b ⇒ Object
readonly
Returns the value of attribute datum_b.
-
#op ⇒ Object
readonly
Returns the value of attribute op.
Instance Method Summary collapse
- #initialize(arg:, op:, datum_a:, datum_b: 0, width: 64) ⇒ void constructor
-
#to_a ⇒ Array<Integer>
Low-level comparison tuple.
Constructor Details
#initialize(arg:, op:, datum_a:, datum_b: 0, width: 64) ⇒ void
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/seccomp/arg.rb', line 31 def initialize(arg:, op:, datum_a:, datum_b: 0, width: 64) unless arg.is_a?(Integer) && (0..5).cover?(arg) raise ArgumentError, "arg must be an Integer between 0 and 5" end raise ArgumentError, "width must be 32 or 64" unless [32, 64].include?(width) @arg = arg operator = op.to_sym if op.respond_to?(:to_sym) @op = OPERATORS.fetch(operator) { raise ArgumentError, "unknown comparison: #{op.inspect}" } @datum_a = datum(datum_a, width) @datum_b = datum(datum_b, width) end |
Instance Attribute Details
#arg ⇒ Object (readonly)
Returns the value of attribute arg.
21 22 23 |
# File 'lib/seccomp/arg.rb', line 21 def arg @arg end |
#datum_a ⇒ Object (readonly)
Returns the value of attribute datum_a.
21 22 23 |
# File 'lib/seccomp/arg.rb', line 21 def datum_a @datum_a end |
#datum_b ⇒ Object (readonly)
Returns the value of attribute datum_b.
21 22 23 |
# File 'lib/seccomp/arg.rb', line 21 def datum_b @datum_b end |
#op ⇒ Object (readonly)
Returns the value of attribute op.
21 22 23 |
# File 'lib/seccomp/arg.rb', line 21 def op @op end |
Instance Method Details
#to_a ⇒ Array<Integer>
Returns low-level comparison tuple.
46 47 48 |
# File 'lib/seccomp/arg.rb', line 46 def to_a [arg, op, datum_a, datum_b] end |