You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use syn::{parse_macro_input,DeriveInput,ItemFn,ItemForeignMod,ItemMod};
26
19
27
20
externcrate proc_macro;
28
21
29
-
#[derive(Default,Debug)]
30
-
structState{
31
-
functions:Vec<function::Function>,
32
-
classes:HashMap<String, class::Class>,
33
-
constants:Vec<Constant>,
34
-
}
35
-
36
-
implState{
37
-
fnparse_from_meta<T>(
38
-
meta:&Vec<NestedMeta>,
39
-
call_site:Option<Span>,
40
-
) -> Result<T,TokenStream2>
41
-
where
42
-
T:FromMeta,
43
-
{
44
-
T::from_list(&meta).map_err(|e| {
45
-
syn::Error::new(
46
-
call_site.unwrap_or_else(Span::call_site),
47
-
format!("Unable to parse attribute arguments: {:?}", e),
48
-
)
49
-
.to_compile_error()
50
-
.into()
51
-
})
52
-
}
53
-
}
54
-
22
+
/// Structs can be exported to PHP as classes with the #[php_class] attribute macro. This attribute derives the RegisteredClass trait on your struct, as well as registering the class to be registered with the #[php_module] macro.
syn::Error::new(Span::call_site(),"php_class is not supported")
66
-
.to_compile_error()
67
-
.into()
25
+
syn::Error::new(
26
+
Span::call_site(),
27
+
"php_class can only be used inside a #[php_module] module",
28
+
)
29
+
.to_compile_error()
30
+
.into()
68
31
}
69
32
33
+
/// Used to annotate functions which should be exported to PHP. Note that this should not be used on class methods - see the #[php_impl] macro for that.
"php_function can only be used inside a #[php_module] module",
39
+
)
40
+
.to_compile_error()
83
41
.into()
84
42
}
85
43
44
+
/// The module macro is used to annotate the get_module function, which is used by the PHP interpreter to retrieve information about your extension, including the name, version, functions and extra initialization functions. Regardless if you use this macro, your extension requires a extern "C" fn get_module() so that PHP can get this information.
"php_startup can only be used inside a #[php_module] module",
62
+
)
63
+
.to_compile_error()
64
+
.into()
114
65
}
115
66
67
+
/// You can export an entire impl block to PHP. This exports all methods as well as constants to PHP on the class that it is implemented on. This requires the #[php_class] macro to already be used on the underlying struct. Trait implementations cannot be exported to PHP.
0 commit comments