abi_stable_derive/stable_abi/
tl_multi_tl.rs1use super::*;
2
3use crate::fn_pointer_extractor::FnParamRet;
4
5abi_stable_shared::declare_type_layout_index! {
6 attrs=[]
7}
8
9impl TypeLayoutIndex {
10 pub const DUMMY: Self = Self::from_u10(!0);
14}
15
16abi_stable_shared::declare_multi_tl_types! {
17 attrs=[]
18}
19
20impl TypeLayoutRange {
21 pub(crate) fn compress_params<'a>(
22 params: &[FnParamRet<'a>],
23 shared_vars: &mut SharedVars<'a>,
24 ) -> Self {
25 let param_len = params.len();
26 if param_len <= TypeLayoutRange::STORED_INLINE {
27 let mut arr = [0u16; TypeLayoutRange::STORED_INLINE];
28
29 for (p_i, param) in params.iter().enumerate() {
30 let ty: &'a syn::Type = param.ty;
31 arr[p_i] = shared_vars
32 .push_type(LayoutConstructor::Regular, ty)
33 .to_u10();
34 }
35
36 Self::with_up_to_5(param_len, arr)
37 } else {
38 const I_BEFORE: usize = TypeLayoutRange::STORED_INLINE - 1;
39 let mut arr = [0u16; TypeLayoutRange::STORED_INLINE];
40
41 let mut iter = params.iter().map(|p| -> &'a syn::Type { p.ty });
42 for (p_i, ty) in iter.by_ref().take(I_BEFORE).enumerate() {
43 arr[p_i] = shared_vars
44 .push_type(LayoutConstructor::Regular, ty)
45 .to_u10();
46 }
47
48 arr[I_BEFORE] = shared_vars
49 .extend_type(LayoutConstructor::Regular, iter)
50 .start;
51
52 Self::with_more_than_5(param_len, arr)
53 }
54 }
55}