cala_core/lib.rs
1// cala_core
2//
3// Copyright (c) 2020 Jeron Aldaron Lau
4//
5// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
6// https://apache.org/licenses/LICENSE-2.0>, or the Zlib License, <LICENSE-ZLIB
7// or http://opensource.org/licenses/Zlib>, at your option. This file may not be
8// copied, modified, or distributed except according to those terms.
9
10//! # Getting Started
11//! Add the following to your `Cargo.toml`:
12//! ```toml
13//! [dependencies.cala_core]
14//! version = "0.1.0"
15//! ```
16//!
17//! ```rust
18//! // TODO
19//! ```
20
21#![doc(
22 html_logo_url = "https://raw.githubusercontent.com/libcala/cala_core/master/res/logo.svg",
23 html_favicon_url = "https://raw.githubusercontent.com/libcala/cala_core/master/res/logo.svg",
24 html_root_url = "https://docs.rs/cala_core"
25)]
26#![deny(unsafe_code)]
27#![warn(
28 anonymous_parameters,
29 missing_copy_implementations,
30 missing_debug_implementations,
31 missing_docs,
32 nonstandard_style,
33 rust_2018_idioms,
34 single_use_lifetimes,
35 trivial_casts,
36 trivial_numeric_casts,
37 unreachable_pub,
38 unused_extern_crates,
39 unused_qualifications,
40 variant_size_differences
41)]
42
43#[cfg(all(feature = "stdweb", not(feature = "wasm-bindgen")))]
44#[macro_use]
45extern crate stdweb;
46
47#[cfg(all(feature = "cala", not(target_arch = "wasm32")))]
48#[doc(hidden)]
49pub extern crate pasts;
50
51pub mod os;
52
53/// **cala**: Set an asynchronous function as the entry point for the program.
54#[cfg(all(feature = "cala", not(target_arch = "wasm32")))]
55#[macro_export]
56macro_rules! exec {
57 ($main:ident) => {
58 fn main() {
59 use $crate::pasts::Executor;
60 static EXECUTOR: $crate::pasts::CvarExec
61 = $crate::pasts::CvarExec::new();
62 EXECUTOR.block_on($main());
63 }
64 };
65}
66
67/// **cala**: Set an asynchronous function as the entry point for the program.
68#[cfg(all(feature = "cala", target_arch = "wasm32"))]
69#[macro_export]
70macro_rules! exec {
71 ($main:ident) => {
72 mod main {
73 // Web Assembly "main" function
74 #[no_mangle]
75 extern "C" fn wasm_main() {
76 $crate::os::web::panic_hook();
77 $crate::os::web::block_on(super::$main());
78 }
79 }
80 };
81}
82
83/*/// Set a function as the entry point for the program.
84#[cfg(all(target_os = "android", not(target_arch = "wasm32")))]
85#[macro_export]
86macro_rules! main {
87 ($main:expr) => {
88 mod __cala_core_macro_generated {
89 use super::*;
90
91 /// Called from NativeActivity JNI
92 #[no_mangle]
93 pub extern "C" fn android_main(
94 state: *mut c_void, /*AndroidApp*/
95 ) -> () {
96 $main($crate::System);
97 }
98 }
99 };
100}
101/// Set a function as the entry point for the program.
102#[cfg(all(target_os = "windows", not(target_arch = "wasm32")))]
103#[macro_export]
104macro_rules! main {
105 ($main:expr) => {
106 mod __cala_core_macro_generated {
107 use super::*;
108
109 /// Called from Windows Runtime
110 #[no_mangle]
111 pub extern "C" fn wWinMain(
112 _h_instance: *mut c_void,
113 _h_prev_instance: *mut c_void,
114 _p_cmd_line: *mut u16,
115 _n_cmd_show: c_int,
116 ) -> c_int {
117 $main($crate::System);
118 0
119 }
120 }
121 };
122}
123/// Set a function as the entry point for the program.
124#[cfg(not(any(
125 target_arch = "wasm32",
126 target_os = "android",
127 target_os = "windows",
128)))]
129#[macro_export]
130macro_rules! main {
131 ($main:expr) => {
132 fn main() {
133 $main($crate::System);
134 }
135 };
136}*/