phper_macros/lib.rs
1// Copyright (c) 2022 PHPER Framework Team
2// PHPER is licensed under Mulan PSL v2.
3// You can use this software according to the terms and conditions of the Mulan
4// PSL v2. You may obtain a copy of Mulan PSL v2 at:
5// http://license.coscl.org.cn/MulanPSL2
6// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
7// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
8// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9// See the Mulan PSL v2 for more details.
10
11#![warn(rust_2018_idioms, missing_docs)]
12#![warn(clippy::dbg_macro, clippy::print_stdout)]
13#![doc = include_str!("../README.md")]
14#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/112468984?s=200&v=4")]
15
16// TODO Write a bridge macro for easy usage about register functions and
17// classes, like `cxx`.
18
19mod alloc;
20mod derives;
21mod globals;
22mod inner;
23mod log;
24mod utils;
25
26use proc_macro::TokenStream;
27
28/// PHP module entry, wrap the `phper::modules::Module` write operation.
29///
30/// # Examples
31///
32/// ```no_test
33/// use phper::{php_get_module, modules::Module};
34///
35/// #[php_get_module]
36/// pub fn get_module() -> Module {
37/// let mut module = Module::new(
38/// env!("CARGO_CRATE_NAME"),
39/// env!("CARGO_PKG_VERSION"),
40/// env!("CARGO_PKG_AUTHORS"),
41/// );
42///
43/// // ...
44///
45/// module
46/// }
47/// ```
48#[proc_macro_attribute]
49pub fn php_get_module(attr: TokenStream, input: TokenStream) -> TokenStream {
50 inner::php_get_module(attr, input)
51}