@@ -67,6 +67,9 @@ pub fn construct_type_check(
6767 }
6868 }
6969 DataType :: Native ( dtrace_parser:: DataType :: String ) => quote ! { _: impl AsRef <str > } ,
70+ DataType :: Native ( dtrace_parser:: DataType :: CString ) => {
71+ quote ! { _: impl AsRef <:: core:: ffi:: CStr > }
72+ }
7073 _ => {
7174 let arg = typ. to_rust_type ( ) ;
7275 quote ! { _: impl :: std:: borrow:: Borrow <#arg> }
@@ -181,6 +184,10 @@ fn asm_type_convert(typ: &DataType, input: TokenStream) -> (TokenStream, TokenSt
181184 } ,
182185 quote ! { . as_ptr( ) as usize } ,
183186 ) ,
187+ DataType :: Native ( dtrace_parser:: DataType :: CString ) => (
188+ quote ! { #input. as_ref( ) as & :: core:: ffi:: CStr } ,
189+ quote ! { . as_ptr( ) as usize } ,
190+ ) ,
184191 DataType :: Native ( dtrace_parser:: DataType :: String ) => (
185192 quote ! {
186193 [ ( #input. as_ref( ) as & str ) . as_bytes( ) , & [ 0_u8 ] ] . concat( )
@@ -397,5 +404,15 @@ mod tests {
397404 quote! { [ ( foo. as_ref( ) as & str ) . as_bytes( ) , & [ 0_u8 ] ] . concat( ) } . to_string( )
398405 ) ;
399406 assert_eq ! ( post. to_string( ) , quote! { . as_ptr( ) as usize } . to_string( ) ) ;
407+
408+ let ( out, post) = asm_type_convert (
409+ & DataType :: Native ( dtrace_parser:: DataType :: CString ) ,
410+ TokenStream :: from_str ( "foo" ) . unwrap ( ) ,
411+ ) ;
412+ assert_eq ! (
413+ out. to_string( ) ,
414+ quote! { foo. as_ref( ) as & :: core:: ffi:: CStr } . to_string( )
415+ ) ;
416+ assert_eq ! ( post. to_string( ) , quote! { . as_ptr( ) as usize } . to_string( ) ) ;
400417 }
401418}
0 commit comments