2021-12-17 09:07:13 +01:00
|
|
|
//! Module defining script options.
|
|
|
|
|
2022-02-25 04:42:59 +01:00
|
|
|
use bitflags::bitflags;
|
2022-01-04 15:16:20 +01:00
|
|
|
#[cfg(feature = "no_std")]
|
|
|
|
use std::prelude::v1::*;
|
|
|
|
|
2022-02-26 10:41:27 +01:00
|
|
|
/// A type representing the access mode of a function.
|
|
|
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
2022-08-14 08:20:37 +02:00
|
|
|
#[cfg_attr(feature = "metadata", derive(serde::Serialize))]
|
|
|
|
#[cfg_attr(feature = "metadata", serde(rename_all = "camelCase"))]
|
2022-05-03 15:55:08 +02:00
|
|
|
#[non_exhaustive]
|
2022-02-26 10:41:27 +01:00
|
|
|
pub enum FnAccess {
|
|
|
|
/// Private function.
|
|
|
|
Private,
|
|
|
|
/// Public function.
|
|
|
|
Public,
|
|
|
|
}
|
|
|
|
|
2022-07-21 03:33:49 +02:00
|
|
|
impl FnAccess {
|
|
|
|
/// Is this function private?
|
|
|
|
#[inline(always)]
|
|
|
|
#[must_use]
|
|
|
|
pub fn is_private(self) -> bool {
|
|
|
|
match self {
|
|
|
|
Self::Private => true,
|
|
|
|
Self::Public => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// Is this function public?
|
|
|
|
#[inline(always)]
|
|
|
|
#[must_use]
|
|
|
|
pub fn is_public(self) -> bool {
|
|
|
|
match self {
|
|
|
|
Self::Private => false,
|
|
|
|
Self::Public => true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-25 04:42:59 +01:00
|
|
|
bitflags! {
|
2022-05-19 15:40:22 +02:00
|
|
|
/// _(internals)_ Bit-flags containing [`AST`][crate::AST] node configuration options.
|
2021-12-17 09:07:13 +01:00
|
|
|
/// Exported under the `internals` feature only.
|
2022-02-25 04:42:59 +01:00
|
|
|
pub struct ASTFlags: u8 {
|
|
|
|
/// No options for the [`AST`][crate::AST] node.
|
2022-03-09 02:25:55 +01:00
|
|
|
const NONE = 0b_0000_0000;
|
2022-02-25 04:42:59 +01:00
|
|
|
/// The [`AST`][crate::AST] node is read-only.
|
2022-03-09 02:25:55 +01:00
|
|
|
const CONSTANT = 0b_0000_0001;
|
2022-02-25 04:42:59 +01:00
|
|
|
/// The [`AST`][crate::AST] node is exposed to the outside (i.e. public).
|
2022-03-09 02:25:55 +01:00
|
|
|
const EXPORTED = 0b_0000_0010;
|
2022-02-25 04:42:59 +01:00
|
|
|
/// The [`AST`][crate::AST] node is negated (i.e. whatever information is the opposite).
|
2022-03-09 02:25:55 +01:00
|
|
|
const NEGATED = 0b_0000_0100;
|
2022-02-25 04:42:59 +01:00
|
|
|
/// The [`AST`][crate::AST] node breaks out of normal control flow.
|
2022-03-09 02:25:55 +01:00
|
|
|
const BREAK = 0b_0000_1000;
|
2021-12-17 09:07:13 +01:00
|
|
|
}
|
|
|
|
}
|