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
////////////////////////////////////////////////////////////////////////////////
// This file is part of "Ad Astra", an embeddable scripting programming //
// language platform. //
// //
// This work is proprietary software with source-available code. //
// //
// To copy, use, distribute, or contribute to this work, you must agree to //
// the terms of the General License Agreement: //
// //
// https://github.com/Eliah-Lakhin/ad-astra/blob/master/EULA.md //
// //
// The agreement grants a Basic Commercial License, allowing you to use //
// this work in non-commercial and limited commercial products with a total //
// gross revenue cap. To remove this commercial limit for one of your //
// products, you must acquire a Full Commercial License. //
// //
// If you contribute to the source code, documentation, or related materials, //
// you must grant me an exclusive license to these contributions. //
// Contributions are governed by the "Contributions" section of the General //
// License Agreement. //
// //
// Copying the work in parts is strictly forbidden, except as permitted //
// under the General License Agreement. //
// //
// If you do not or cannot agree to the terms of this Agreement, //
// do not use this work. //
// //
// This work is provided "as is", without any warranties, express or implied, //
// except where such disclaimers are legally invalid. //
// //
// Copyright (c) 2024 Ilya Lakhin (Илья Александрович Лахин). //
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
// This module is hidden.
//
// You should never use it directly, as its API is not part of the official
// public API of the crate.
/// Low-level exporting interfaces.
///
/// This module's API allows you to manually implement semantics for the
/// [exported types](ScriptType), which might not exist in the original
/// Rust API. This enables you to model more complex domain-specific APIs
/// within script environments.
///
/// Typically, the [export](crate::export) macro automatically exports
/// various elements using [ops] APIs based on item introspection.
///
/// You can override this behavior by manually exporting the type. In this case,
/// you need to export a type alias for the underlying type.
///
/// ```
/// use ad_astra::{export, runtime::ScriptType};
///
/// #[derive(Debug)]
/// struct Foo;
///
/// #[export]
/// type FooAlias = Foo;
///
/// // This Script type lacks debugging capabilities because the export
/// // macro does not export any semantics when applied to type aliases.
/// assert!(!<Foo>::type_meta().prototype().implements_debug());
/// ```
///
/// When the export macro is applied to a type alias, it only registers
/// the type in the Script Engine without inspecting it further. It does not
/// export any operators or runtime traits for this type. Specifically, the macro
/// does not implement [Downcast], [Upcast], or the
/// [assignment](Prototype::implements_assign) operator automatically. You can
/// implement them manually if needed.
///
/// To implement a low-level operator for the type, implement the corresponding
/// [ops] trait and export this implementation.
///
/// ```
/// use ad_astra::{
/// export,
/// runtime::{ops::ScriptDebug, ScriptType},
/// };
///
/// #[derive(Debug)]
/// struct Foo;
///
/// #[export]
/// type FooAlias = Foo;
///
/// #[export]
/// impl ScriptDebug for Foo {}
///
/// assert!(<Foo>::type_meta().prototype().implements_debug());
/// ```
///
/// Note that you can export low-level operations for any
/// registered type, not just type aliases. In such cases, you must
/// ensure that these operations do not conflict with higher-level exports.
/// The Script Engine will panic if there are conflicts between export points.
pub use crate;