1#![allow(non_snake_case, non_camel_case_types)]
9#![allow(dead_code)]
10
11use capi::sctypes::*;
12use capi::scvalue::VALUE;
13
14pub type som_atom_t = u64;
16
17
18#[repr(C)]
20#[derive(Debug)]
21pub struct som_asset_t {
22 pub(crate) isa: &'static som_asset_class_t,
23}
24
25impl som_asset_t {
26 pub(crate) fn get_passport(&self) -> *const som_passport_t {
27 (self.isa.get_passport)(self as *const _ as *mut _)
28 }
29}
30
31#[repr(C)]
33#[derive(Debug)]
34pub(crate) struct som_asset_class_t {
35 pub add_ref: extern "C" fn(thing: *mut som_asset_t) -> i32,
37
38 pub release: extern "C" fn(thing: *mut som_asset_t) -> i32,
40
41 pub get_interface: extern "C" fn(thing: *mut som_asset_t, name: LPCSTR, out: *mut *mut som_asset_t) -> bool,
43
44 pub get_passport: extern "C" fn(thing: *mut som_asset_t) -> *const som_passport_t,
46}
47
48
49#[repr(C)]
51pub struct som_passport_t {
52 pub flags: u64,
54
55 pub name: som_atom_t,
57
58 pub properties: *const som_property_def_t,
80
81 pub n_properties: usize,
83
84 pub methods: *const som_method_def_t,
89
90 pub n_methods: usize,
92
93 pub item_getter: Option<som_item_getter_t>,
95
96 pub item_setter: Option<som_item_setter_t>,
98
99 pub item_next: Option<som_item_next_t>,
101
102 pub prop_getter: Option<som_any_prop_getter_t>,
104
105 pub prop_setter: Option<som_any_prop_setter_t>,
107}
108
109impl Default for som_passport_t {
111 fn default() -> Self {
112 use std::ptr;
113 Self {
114 flags: 0,
115 name: 0,
116
117 prop_getter: None,
118 prop_setter: None,
119
120 item_getter: None,
121 item_setter: None,
122 item_next: None,
123
124 properties: ptr::null(),
125 n_properties: 0,
126
127 methods: ptr::null(),
128 n_methods: 0,
129 }
130 }
131}
132
133
134#[repr(u64)]
136#[derive(Debug, PartialOrd, PartialEq)]
137pub enum som_passport_flags {
138 SEALED = 0,
140
141 EXTENDABLE = 1,
145}
146
147
148#[repr(C)]
150pub struct som_property_def_t {
151 pub reserved: LPVOID,
152
153 pub name: som_atom_t,
155
156 pub getter: Option<som_prop_getter_t>,
158
159 pub setter: Option<som_prop_setter_t>,
161}
162
163impl Default for som_property_def_t {
165 fn default() -> Self {
166 Self {
167 reserved: std::ptr::null_mut(),
168 name: 0,
169 getter: None,
170 setter: None,
171 }
172 }
173}
174
175#[repr(C)]
177pub struct som_method_def_t {
178 pub reserved: LPVOID,
179
180 pub name: som_atom_t,
182
183 pub params: usize,
193
194 pub func: Option<som_method_t>,
196}
197
198impl Default for som_method_def_t {
200 fn default() -> Self {
201 Self {
202 reserved: std::ptr::null_mut(),
203 name: 0,
204 params: 0,
205 func: None,
206 }
207 }
208}
209
210type som_dispose_t = extern "C" fn(thing: *mut som_asset_t);
211
212type som_prop_getter_t = extern "C" fn(thing: *mut som_asset_t, p_value: &mut VALUE) -> BOOL;
213type som_prop_setter_t = extern "C" fn(thing: *mut som_asset_t, p_value: &VALUE) -> BOOL;
214
215type som_any_prop_getter_t = extern "C" fn(thing: *mut som_asset_t, propSymbol: som_atom_t, p_value: &mut VALUE) -> BOOL;
216type som_any_prop_setter_t = extern "C" fn(thing: *mut som_asset_t, propSymbol: som_atom_t, p_value: &VALUE) -> BOOL;
217
218type som_item_getter_t = extern "C" fn(thing: *mut som_asset_t, p_key: &VALUE, p_value: &mut VALUE) -> BOOL;
219type som_item_setter_t = extern "C" fn(thing: *mut som_asset_t, p_key: &VALUE, p_value: &VALUE) -> BOOL;
220
221type som_item_next_t = extern "C" fn(thing: *mut som_asset_t, p_idx: &mut VALUE, p_value: &mut VALUE) -> BOOL;
222
223type som_method_t = extern "C" fn(thing: *mut som_asset_t, argc: u32, argv: *const VALUE, p_result: &mut VALUE) -> BOOL;