mlua_codemp_patch/
stdlib.rs1use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign};
2
3#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
5pub struct StdLib(u32);
6
7impl StdLib {
8 #[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52", feature = "luau"))]
12 pub const COROUTINE: StdLib = StdLib(1);
13
14 pub const TABLE: StdLib = StdLib(1 << 1);
16
17 #[cfg(not(feature = "luau"))]
19 #[cfg_attr(docsrs, doc(cfg(not(feature = "luau"))))]
20 pub const IO: StdLib = StdLib(1 << 2);
21
22 pub const OS: StdLib = StdLib(1 << 3);
24
25 pub const STRING: StdLib = StdLib(1 << 4);
27
28 #[cfg(any(feature = "lua54", feature = "lua53", feature = "luau"))]
32 pub const UTF8: StdLib = StdLib(1 << 5);
33
34 #[cfg(any(feature = "lua52", feature = "luajit", feature = "luau", doc))]
38 pub const BIT: StdLib = StdLib(1 << 6);
39
40 pub const MATH: StdLib = StdLib(1 << 7);
42
43 pub const PACKAGE: StdLib = StdLib(1 << 8);
45
46 #[cfg(any(feature = "luau", doc))]
48 #[cfg_attr(docsrs, doc(cfg(feature = "luau")))]
49 pub const BUFFER: StdLib = StdLib(1 << 9);
50
51 #[cfg(any(feature = "luajit", doc))]
55 #[cfg_attr(docsrs, doc(cfg(feature = "luajit")))]
56 pub const JIT: StdLib = StdLib(1 << 9);
57
58 #[cfg(any(feature = "luajit", doc))]
62 #[cfg_attr(docsrs, doc(cfg(feature = "luajit")))]
63 pub const FFI: StdLib = StdLib(1 << 30);
64
65 pub const DEBUG: StdLib = StdLib(1 << 31);
67
68 pub const NONE: StdLib = StdLib(0);
70 pub const ALL: StdLib = StdLib(u32::MAX);
72 #[cfg(not(feature = "luau"))]
74 pub const ALL_SAFE: StdLib = StdLib((1 << 30) - 1);
75 #[cfg(feature = "luau")]
76 pub const ALL_SAFE: StdLib = StdLib(u32::MAX);
77
78 pub fn contains(self, lib: Self) -> bool {
79 (self & lib).0 != 0
80 }
81}
82
83impl BitAnd for StdLib {
84 type Output = Self;
85 fn bitand(self, rhs: Self) -> Self::Output {
86 StdLib(self.0 & rhs.0)
87 }
88}
89
90impl BitAndAssign for StdLib {
91 fn bitand_assign(&mut self, rhs: Self) {
92 *self = StdLib(self.0 & rhs.0)
93 }
94}
95
96impl BitOr for StdLib {
97 type Output = Self;
98 fn bitor(self, rhs: Self) -> Self::Output {
99 StdLib(self.0 | rhs.0)
100 }
101}
102
103impl BitOrAssign for StdLib {
104 fn bitor_assign(&mut self, rhs: Self) {
105 *self = StdLib(self.0 | rhs.0)
106 }
107}
108
109impl BitXor for StdLib {
110 type Output = Self;
111 fn bitxor(self, rhs: Self) -> Self::Output {
112 StdLib(self.0 ^ rhs.0)
113 }
114}
115
116impl BitXorAssign for StdLib {
117 fn bitxor_assign(&mut self, rhs: Self) {
118 *self = StdLib(self.0 ^ rhs.0)
119 }
120}