nixio.bit.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. --- Bitfield operators and mainpulation functions.
  2. -- Can be used as a drop-in replacement for bitlib.
  3. module "nixio.bit"
  4. --- Bitwise OR several numbers.
  5. -- @class function
  6. -- @name bor
  7. -- @param oper1 First Operand
  8. -- @param oper2 Second Operand
  9. -- @param ... More Operands
  10. -- @return number
  11. --- Invert given number.
  12. -- @class function
  13. -- @name bnot
  14. -- @param oper Operand
  15. -- @return number
  16. --- Bitwise AND several numbers.
  17. -- @class function
  18. -- @name band
  19. -- @param oper1 First Operand
  20. -- @param oper2 Second Operand
  21. -- @param ... More Operands
  22. -- @return number
  23. --- Bitwise XOR several numbers.
  24. -- @class function
  25. -- @name bxor
  26. -- @param oper1 First Operand
  27. -- @param oper2 Second Operand
  28. -- @param ... More Operands
  29. -- @return number
  30. --- Left shift a number.
  31. -- @class function
  32. -- @name lshift
  33. -- @param oper number
  34. -- @param shift bits to shift
  35. -- @return number
  36. --- Right shift a number.
  37. -- @class function
  38. -- @name rshift
  39. -- @param oper number
  40. -- @param shift bits to shift
  41. -- @return number
  42. --- Arithmetically right shift a number.
  43. -- @class function
  44. -- @name arshift
  45. -- @param oper number
  46. -- @param shift bits to shift
  47. -- @return number
  48. --- Integer division of 2 or more numbers.
  49. -- @class function
  50. -- @name div
  51. -- @param oper1 Operand 1
  52. -- @param oper2 Operand 2
  53. -- @param ... More Operands
  54. -- @return number
  55. --- Cast a number to the bit-operating range.
  56. -- @class function
  57. -- @name cast
  58. -- @param oper number
  59. -- @return number
  60. --- Sets one or more flags of a bitfield.
  61. -- @class function
  62. -- @name set
  63. -- @param bitfield Bitfield
  64. -- @param flag1 First Flag
  65. -- @param ... More Flags
  66. -- @return altered bitfield
  67. --- Unsets one or more flags of a bitfield.
  68. -- @class function
  69. -- @name unset
  70. -- @param bitfield Bitfield
  71. -- @param flag1 First Flag
  72. -- @param ... More Flags
  73. -- @return altered bitfield
  74. --- Checks whether given flags are set in a bitfield.
  75. -- @class function
  76. -- @name check
  77. -- @param bitfield Bitfield
  78. -- @param flag1 First Flag
  79. -- @param ... More Flags
  80. -- @return true when all flags are set, otherwise false