1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
pub mod core;
macro_rules! declare_module_apis {
(
$(
#[feature = $feature:expr] mod $name:ident:
macro $macro_name:ident ($($macro_args:tt)*) { $($macro_block:tt)* }
)+
) => {
$(
#[cfg(feature = $feature)]
pub mod $name;
#[macro_export]
#[cfg(not(feature = $feature))]
macro_rules! $macro_name {
($($macro_args)*) => {
compile_error!(
concat!(
"Feature `",
stringify!($name),
"` not enabled. You must enable the feature in \
`ark` in your `Cargo.toml` to be able to use this API."
)
);
}
}
#[macro_export]
#[cfg(feature = $feature)]
macro_rules! $macro_name {
($($macro_args)*) => { $($macro_block)* }
}
)+
}
}
declare_module_apis! {
#[feature = "applet"] mod applet: macro require_applet_api() {
#[no_mangle]
#[used]
pub static ARK_API_APPLET: u64 = $crate::applet::FFI_API.id;
pub fn applet() -> &'static $crate::applet::Applet {
&$crate::applet::Applet {}
}
}
#[feature = "behavior_controller"] mod behavior_controller: macro require_behavior_controller_api() {
#[no_mangle]
#[used]
pub static ARK_API_BEHAVIOR_CONTROLLER: u64 = $crate::behavior_controller::FFI_API.id;
pub fn behavior_controller() -> &'static $crate::behavior_controller::BehaviorController {
&$crate::behavior_controller::BehaviorController {}
}
}
#[feature = "behavior"] mod behavior: macro require_behavior_api() {
#[no_mangle]
#[used]
pub static ARK_API_BEHAVIOR: u64 = $crate::behavior::FFI_API.id;
pub fn behavior() -> &'static $crate::behavior::Behavior {
&$crate::behavior::Behavior
}
}
#[feature = "file_ux"] mod file_ux: macro require_file_ux_api() {
#[no_mangle]
#[used]
pub static ARK_API_FILE_UX: u64 = $crate::file_ux::FFI_API.id;
pub fn file_ux() -> &'static $crate::file_ux::FileUX {
&$crate::file_ux::FileUX {}
}
}
#[feature = "http_request"] mod http_request: macro require_http_request_api() {
#[no_mangle]
#[used]
pub static ARK_API_HTTP_REQUEST: u64 = $crate::http_request::FFI_API.id;
}
#[feature = "ml"] mod ml: macro require_ml_api() {
#[no_mangle]
#[used]
pub static ARK_API_ML: u64 = $crate::ml::FFI_API.id;
}
#[feature = "module_run"] mod module_run: macro require_module_run_api() {
#[no_mangle]
#[used]
pub static ARK_API_MODULE_RUN: u64 = $crate::module_run::FFI_API.id;
}
#[feature = "profiler"] mod profiler: macro require_profiler_api() {
#[no_mangle]
#[used]
pub static ARK_API_PROFILER: u64 = $crate::profiler::FFI_API.id;
}
#[feature = "render"] mod render: macro require_render_api() {
#[no_mangle]
#[used]
pub static ARK_API_RENDER: u64 = $crate::render::FFI_API.id;
pub fn render() -> $crate::render::Render {
$crate::render::Render::__create()
}
}
#[feature = "resource"] mod resource: macro require_resource_api() {
#[no_mangle]
#[used]
pub static ARK_API_RESOURCE: u64 = $crate::resource::FFI_API.id;
}
#[feature = "storage"] mod storage: macro require_storage_api() {
#[no_mangle]
#[used]
pub static ARK_API_STORAGE: u64 = $crate::storage::FFI_API.id;
}
#[feature = "telemetry"] mod telemetry: macro require_telemetry_api() {
#[no_mangle]
#[used]
pub static ARK_API_TELEMETRY: u64 = $crate::telemetry::FFI_API.id;
}
#[feature = "time"] mod time: macro require_time_api() {
#[no_mangle]
#[used]
pub static ARK_API_TIME: u64 = $crate::time::FFI_API.id;
pub fn time() -> &'static $crate::time::Time {
&$crate::time::Time {}
}
}
#[feature = "user"] mod user: macro require_user_api() {
#[no_mangle]
#[used]
pub static ARK_API_USER: u64 = $crate::user::FFI_API.id;
pub fn user() -> &'static $crate::user::User {
&$crate::user::User {}
}
}
#[feature = "world"] mod world: macro require_world_api() {
#[no_mangle]
#[used]
pub static ARK_API_WORLD: u64 = $crate::world::FFI_API.id;
#[inline]
pub fn entity_messenger() -> &'static mut $crate::world::EntityMessenger {
$crate::world::EntityMessenger::get()
}
}
}