wiwi/lsl.rs
1#![allow(dead_code, reason = "wip")]
2#![allow(
3 clippy::missing_inline_in_public_items,
4 reason = "performance not highest priority (for now?), ignoring inline attrs for code simplicity"
5)]
6
7extern crate hashbrown;
8extern crate wiwi_macro_decl;
9use crate::prelude::*;
10
11use crate::chain::WithSelf as _;
12use self::ident::{ Ident, IdentIncrementer };
13// use self::private::{ SealedStruct, SealedTrait };
14
15pub use wiwi_macro_decl::state;
16
17mod ident;
18
19fn script(f: impl FnOnce(ScriptCx)) -> Script {
20 Script::new()
21 .with_self(|s| f(s.cx()))
22}
23
24// /// LSL primitive `integer` type
25// #[expect(non_camel_case_types, reason = "lsl primitive")]
26// struct primitive_integer { __private: () }
27
28// impl Type for primitive_integer {
29// fn new() -> Self {
30// Self { __private: () }
31// }
32// }
33
34// impl SealedTrait for primitive_integer {}
35
36// /// LSL primitive `float` type
37// #[expect(non_camel_case_types, reason = "lsl primitive")]
38// struct primitive_float { __private: () }
39
40// impl Type for primitive_float {
41// fn new() -> Self {
42// Self { __private: () }
43// }
44// }
45
46// impl SealedTrait for primitive_float {}
47
48// /// LSL primitive `string` type
49// #[expect(non_camel_case_types, reason = "lsl primitive")]
50// struct primitive_string { __private: () }
51
52// impl Type for primitive_string {
53// fn new() -> Self {
54// Self { __private: () }
55// }
56// }
57
58// impl SealedTrait for primitive_string {}
59
60// /// LSL primitive `key` type
61// #[expect(non_camel_case_types, reason = "lsl primitive")]
62// struct primitive_key { __private: () }
63
64// impl Type for primitive_key {
65// fn new() -> Self {
66// Self { __private: () }
67// }
68// }
69
70// impl SealedTrait for primitive_key {}
71
72// /// LSL primitive `vector` type
73// #[expect(non_camel_case_types, reason = "lsl primitive")]
74// struct primitive_vector { __private: () }
75
76// impl Type for primitive_vector {
77// fn new() -> Self {
78// Self { __private: () }
79// }
80// }
81
82// impl SealedTrait for primitive_vector {}
83
84// /// LSL primitive `rotation` type
85// #[expect(non_camel_case_types, reason = "lsl primitive")]
86// struct primitive_rotation { __private: () }
87
88// impl Type for primitive_rotation {
89// fn new() -> Self {
90// Self { __private: () }
91// }
92// }
93
94// impl SealedTrait for primitive_rotation {}
95
96// /// LSL primitive `list` type
97// #[expect(non_camel_case_types, reason = "lsl primitive")]
98// struct primitive_list { __private: () }
99
100// impl Type for primitive_list {
101// fn new() -> Self {
102// Self { __private: () }
103// }
104// }
105
106// impl SealedTrait for primitive_list {}
107
108// /// LSL primitive `boolean` type
109// ///
110// /// Note: LSL does not actually have a `boolean` type, where all "`boolean`"
111// /// values are represented by an integer. This `boolean` is represented
112// /// underneath by an integer, so should work just as if LSL always had
113// /// booleans to begin with.
114// #[expect(non_camel_case_types, reason = "lsl primitive")]
115// struct primitive_boolean { __private: () }
116
117// impl Type for primitive_boolean {
118// fn new() -> Self {
119// Self { __private: () }
120// }
121// }
122
123// impl SealedTrait for primitive_boolean {}
124
125// // #[expect(non_camel_case_types, reason = "lsl primitive")]
126// // struct prim_unit { __private: () }
127
128// struct VarContainer<T>
129// where
130// T: Type
131// {
132// // ctx: Box<dyn VarDeclCapability>,
133// __something: PhantomData<T>
134// }
135
136// impl<T> VarContainer<T>
137// where
138// T: Type
139// {}
140
141// #[expect(non_camel_case_types, reason = "lsl primitive")]
142// type integer = VarContainer<primitive_integer>;
143
144// #[expect(non_camel_case_types, reason = "lsl primitive")]
145// type float = VarContainer<primitive_float>;
146
147// #[expect(non_camel_case_types, reason = "lsl primitive")]
148// type string = VarContainer<primitive_string>;
149
150// #[expect(non_camel_case_types, reason = "lsl primitive")]
151// type key = VarContainer<primitive_key>;
152
153// #[expect(non_camel_case_types, reason = "lsl primitive")]
154// type vector = VarContainer<primitive_vector>;
155
156// #[expect(non_camel_case_types, reason = "lsl primitive")]
157// type rotation = VarContainer<primitive_rotation>;
158
159// #[expect(non_camel_case_types, reason = "lsl primitive")]
160// type list = VarContainer<primitive_list>;
161
162// #[expect(non_camel_case_types, reason = "lsl primitive")]
163// type boolean = VarContainer<primitive_boolean>;
164
165struct Script {
166 ident_incrementer: IdentIncrementer
167}
168
169impl Script {
170 fn new() -> Self {
171 Self {
172 ident_incrementer: IdentIncrementer::new()
173 }
174 }
175
176 fn cx(&self) -> ScriptCx {
177 ScriptCx { inner: self }
178 }
179}
180
181struct ScriptCx<'h> {
182 inner: &'h Script
183}
184
185impl ScriptCx<'_> {
186 fn mk_ident(&self) -> Ident {
187 self.inner.ident_incrementer.next()
188 }
189
190 // fn var<T>(&self, init: T) -> VarContainer<T::Type>
191 // where
192 // T: DefaultType
193 // {
194 // VarContainer { __something: () }
195 // }
196}
197
198struct State {}
199
200struct StateCx<'h> {
201 inner: &'h State
202}
203
204// trait Type {
205// #[doc(hidden)]
206// fn __assert_dyn_compat(&self, _: &dyn Type, _: SealedStruct) {}
207// fn new() -> Self
208// where
209// Self: Sized;
210// }
211
212// trait DefaultType
213// where
214// Self::Type: Type
215// {
216// type Type;
217// }
218
219// trait Var<T>
220// where
221// T: Type
222// {
223// #[doc(hidden)]
224// fn __assert_dyn_compat(&self, _: &dyn Var<T>, _: SealedStruct) {}
225// }
226
227// trait Expr<T>
228// where
229// Self: ExprDyn,
230// T: Type
231// {
232// #[doc(hidden)]
233// fn __assert_dyn_compat(&self, _: &dyn Expr<T>, _: SealedStruct) {}
234
235// fn into_dyn(self) -> Box<dyn ExprDyn>
236// where
237// Self: Sized + 'static
238// {
239// Box::new(self)
240// }
241// }
242
243// trait ExprDyn {
244// #[doc(hidden)]
245// fn __assert_dyn_compat(&self, _: &dyn ExprDyn, _: SealedStruct) {}
246// }
247
248// // trait Stmt {
249// // #[doc(hidden)]
250// // fn __assert_dyn_compat(&self, _: &dyn Stmt, _: SealedStruct) {}
251// // }
252
253// // trait VarDeclCapability {
254// // #[doc(hidden)]
255// // fn __assert_dyn_compat(&self, _: &dyn VarDeclCapability, _: SealedStruct) {}
256
257// // fn var<T>(&self, init: T) -> VarContainer<T::Type>
258// // where
259// // Self: Sized,
260// // T: DefaultType;
261// // }
262
263// // trait StmtCapability {
264// // #[doc(hidden)]
265// // fn __assert_dyn_compat(&self, _: &dyn StmtCapability, _: SealedStruct) {}
266// // }
267
268mod private {
269 pub struct SealedStruct {
270 __private: ()
271 }
272
273 pub trait SealedTrait {}
274}