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
use prelude::*; use syn::*; use tyhandlers::ModelTypeSystem; pub fn with_ts( ident: &Ident, ts: ModelTypeSystem, ) -> Ident { Ident::new( &format!( "{}_{:?}", ident, ts ), Span::call_site() ) } pub fn clsid_path(struct_path: &Path) -> Path { let mut clsid_path = struct_path.clone(); if let Some( mut last ) = clsid_path.segments.last_mut() { let v = last.value_mut(); v.ident = clsid( &v.ident ); } clsid_path } pub fn clsid( struct_name: &Ident ) -> Ident { new_ident( &format!( "CLSID_{}", struct_name ) ) } pub fn iid( itf_name: &Ident ) -> Ident { new_ident( &format!( "IID_{}", itf_name ) ) } pub fn method_impl( struct_ident : &Ident, itf_ident : &Ident, method_name: &str ) -> Ident { new_ident( &format!( "__{}_{}_{}", struct_ident, itf_ident, method_name ) ) } pub fn vtable_struct( itf_ident : &Ident ) -> Ident { new_ident( &format!( "__{}Vtbl", itf_ident ) ) } pub fn vtable_instance( struct_name : &Ident, itf_ident : &Ident, ) -> Ident { new_ident( &format!( "__{}_{}Vtbl_INSTANCE", struct_name, itf_ident ) ) } pub fn vtable_list( struct_ident : &Ident ) -> Ident { new_ident( &format!( "__{}VtblList", struct_ident ) ) } pub fn vtable_offset( s : &Ident, i : &Ident ) -> Ident { new_ident( &format!( "__{}_{}Vtbl_offset", s, i ) ) } fn new_ident( s : &str ) -> Ident { Ident::new( s, Span::call_site() ) }