#![deny(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
#![cfg_attr(
not(test),
deny(
clippy::expect_used,
clippy::panic,
clippy::todo,
clippy::unimplemented,
clippy::unreachable,
clippy::unwrap_used
)
)]
use proc_macro::TokenStream;
use quote::quote;
use syn::{Expr, parse_macro_input};
#[proc_macro]
pub fn export_plugin(input: TokenStream) -> TokenStream {
let constructor = parse_macro_input!(input as Expr);
quote! {
static __SCS_SDK_PLUGIN_RUNTIME: ::scs_sdk_plugin::__private::Runtime =
::scs_sdk_plugin::__private::Runtime::new();
#[doc = "Initializes the telemetry plugin through the safe scs-sdk-plugin runtime."]
#[doc = ""]
#[doc = "# Safety"]
#[doc = ""]
#[doc = "The game must pass the live initialization structure matching `version`"]
#[doc = "and obey the SCS Telemetry SDK main-thread lifecycle contract."]
#[unsafe(no_mangle)]
pub unsafe extern "system" fn scs_telemetry_init(
version: ::scs_sdk_plugin::__private::ScsU32,
params: *const ::scs_sdk_plugin::__private::ScsTelemetryInitParams,
) -> ::scs_sdk_plugin::__private::ScsResult {
unsafe {
__SCS_SDK_PLUGIN_RUNTIME.initialize(version, params, || {
::std::boxed::Box::new(#constructor)
})
}
}
#[doc = "Stops the active telemetry plugin and releases SDK registrations."]
#[doc = ""]
#[doc = "SCS calls this entry point during its serialized shutdown lifecycle."]
#[doc = "The framework invokes the product shutdown hook, unregisters callbacks"]
#[doc = "in reverse order, and retains any context whose SDK unregistration fails."]
#[unsafe(no_mangle)]
pub extern "system" fn scs_telemetry_shutdown() {
__SCS_SDK_PLUGIN_RUNTIME.shutdown();
}
}
.into()
}
#[proc_macro]
pub fn export_input_plugin(input: TokenStream) -> TokenStream {
let constructor = parse_macro_input!(input as Expr);
quote! {
static __SCS_SDK_INPUT_PLUGIN_RUNTIME: ::scs_sdk_plugin::__private::InputRuntime =
::scs_sdk_plugin::__private::InputRuntime::new();
#[doc = "Initializes the input plugin through the safe scs-sdk-plugin runtime."]
#[doc = ""]
#[doc = "# Safety"]
#[doc = ""]
#[doc = "The game must pass the live input initialization structure matching"]
#[doc = "version and obey the SCS Input SDK main-thread lifecycle contract."]
#[unsafe(no_mangle)]
pub unsafe extern "system" fn scs_input_init(
version: ::scs_sdk_plugin::__private::ScsU32,
params: *const ::scs_sdk_plugin::__private::ScsInputInitParams,
) -> ::scs_sdk_plugin::__private::ScsResult {
unsafe {
__SCS_SDK_INPUT_PLUGIN_RUNTIME.initialize(version, params, || {
::std::boxed::Box::new(#constructor)
})
}
}
#[doc = "Stops the active input plugin after SCS unregisters its devices."]
#[doc = ""]
#[doc = "The framework invokes the product shutdown hook and releases the"]
#[doc = "successful generation's callback contexts."]
#[unsafe(no_mangle)]
pub extern "system" fn scs_input_shutdown() {
__SCS_SDK_INPUT_PLUGIN_RUNTIME.shutdown();
}
}
.into()
}