wiwi/lsl.rs
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 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
#![allow(dead_code, reason = "wip")]
#![allow(
clippy::missing_inline_in_public_items,
reason = "performance not highest priority (for now?), ignoring inline attrs for code simplicity"
)]
extern crate hashbrown;
extern crate wiwiwiwiwiwiwiwiwiwi;
use crate::prelude::*;
use crate::chain::GenericChainConversion as _;
use crate::rc::RcThread;
use self::ident::{ Ident, IdentIncrementer };
use self::private::{ SealedStruct, SealedTrait };
pub use wiwiwiwiwiwiwiwiwiwi::state;
mod ident;
fn script(f: impl FnOnce(ScriptCx)) -> Script {
Script::new()
.into_generic_chain()
.with_inner(|s| f(s.cx()))
.into_inner()
}
// /// LSL primitive `integer` type
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// struct primitive_integer { __private: () }
// impl Type for primitive_integer {
// fn new() -> Self {
// Self { __private: () }
// }
// }
// impl SealedTrait for primitive_integer {}
// /// LSL primitive `float` type
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// struct primitive_float { __private: () }
// impl Type for primitive_float {
// fn new() -> Self {
// Self { __private: () }
// }
// }
// impl SealedTrait for primitive_float {}
// /// LSL primitive `string` type
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// struct primitive_string { __private: () }
// impl Type for primitive_string {
// fn new() -> Self {
// Self { __private: () }
// }
// }
// impl SealedTrait for primitive_string {}
// /// LSL primitive `key` type
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// struct primitive_key { __private: () }
// impl Type for primitive_key {
// fn new() -> Self {
// Self { __private: () }
// }
// }
// impl SealedTrait for primitive_key {}
// /// LSL primitive `vector` type
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// struct primitive_vector { __private: () }
// impl Type for primitive_vector {
// fn new() -> Self {
// Self { __private: () }
// }
// }
// impl SealedTrait for primitive_vector {}
// /// LSL primitive `rotation` type
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// struct primitive_rotation { __private: () }
// impl Type for primitive_rotation {
// fn new() -> Self {
// Self { __private: () }
// }
// }
// impl SealedTrait for primitive_rotation {}
// /// LSL primitive `list` type
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// struct primitive_list { __private: () }
// impl Type for primitive_list {
// fn new() -> Self {
// Self { __private: () }
// }
// }
// impl SealedTrait for primitive_list {}
// /// LSL primitive `boolean` type
// ///
// /// Note: LSL does not actually have a `boolean` type, where all "`boolean`"
// /// values are represented by an integer. This `boolean` is represented
// /// underneath by an integer, so should work just as if LSL always had
// /// booleans to begin with.
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// struct primitive_boolean { __private: () }
// impl Type for primitive_boolean {
// fn new() -> Self {
// Self { __private: () }
// }
// }
// impl SealedTrait for primitive_boolean {}
// // #[expect(non_camel_case_types, reason = "lsl primitive")]
// // struct prim_unit { __private: () }
// struct VarContainer<T>
// where
// T: Type
// {
// // ctx: Box<dyn VarDeclCapability>,
// __something: PhantomData<T>
// }
// impl<T> VarContainer<T>
// where
// T: Type
// {}
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// type integer = VarContainer<primitive_integer>;
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// type float = VarContainer<primitive_float>;
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// type string = VarContainer<primitive_string>;
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// type key = VarContainer<primitive_key>;
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// type vector = VarContainer<primitive_vector>;
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// type rotation = VarContainer<primitive_rotation>;
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// type list = VarContainer<primitive_list>;
// #[expect(non_camel_case_types, reason = "lsl primitive")]
// type boolean = VarContainer<primitive_boolean>;
struct Script {
ident_incrementer: IdentIncrementer
}
impl Script {
fn new() -> Self {
Self {
ident_incrementer: IdentIncrementer::new()
}
}
fn cx(&self) -> ScriptCx {
ScriptCx { inner: self }
}
}
struct ScriptCx<'h> {
inner: &'h Script
}
impl ScriptCx<'_> {
fn mk_ident(&self) -> Ident {
self.inner.ident_incrementer.next()
}
// fn var<T>(&self, init: T) -> VarContainer<T::Type>
// where
// T: DefaultType
// {
// VarContainer { __something: () }
// }
}
struct State {}
struct StateCx<'h> {
inner: &'h State
}
// trait Type {
// #[doc(hidden)]
// fn __assert_dyn_compat(&self, _: &dyn Type, _: SealedStruct) {}
// fn new() -> Self
// where
// Self: Sized;
// }
// trait DefaultType
// where
// Self::Type: Type
// {
// type Type;
// }
// trait Var<T>
// where
// T: Type
// {
// #[doc(hidden)]
// fn __assert_dyn_compat(&self, _: &dyn Var<T>, _: SealedStruct) {}
// }
// trait Expr<T>
// where
// Self: ExprDyn,
// T: Type
// {
// #[doc(hidden)]
// fn __assert_dyn_compat(&self, _: &dyn Expr<T>, _: SealedStruct) {}
// fn into_dyn(self) -> Box<dyn ExprDyn>
// where
// Self: Sized + 'static
// {
// Box::new(self)
// }
// }
// trait ExprDyn {
// #[doc(hidden)]
// fn __assert_dyn_compat(&self, _: &dyn ExprDyn, _: SealedStruct) {}
// }
// // trait Stmt {
// // #[doc(hidden)]
// // fn __assert_dyn_compat(&self, _: &dyn Stmt, _: SealedStruct) {}
// // }
// // trait VarDeclCapability {
// // #[doc(hidden)]
// // fn __assert_dyn_compat(&self, _: &dyn VarDeclCapability, _: SealedStruct) {}
// // fn var<T>(&self, init: T) -> VarContainer<T::Type>
// // where
// // Self: Sized,
// // T: DefaultType;
// // }
// // trait StmtCapability {
// // #[doc(hidden)]
// // fn __assert_dyn_compat(&self, _: &dyn StmtCapability, _: SealedStruct) {}
// // }
mod private {
pub struct SealedStruct {
__private: ()
}
pub trait SealedTrait {}
}