fn transform_arg(arg: &PatType) -> TransformedArg {
    //  `arg` contains `pat : ty` e.g. `t : * mut os_task`
    //  println!("arg: {:#?}", arg);
    let syn::PatType { pat, ty, .. } = arg;
    //  println!("pat: {}, ty: {}", quote!{ #pat }, quote!{ #ty });
    let pat_span = pat.span();  //  syn::Pat
    let ty_span = ty.span();    //  syn::Type
    let ident = quote!{ #pat }.to_string();
    let extern_type = quote!{ #ty }.to_string();
    let mut wrap_type = quote!{ #ty }.to_string();
    let mut validation_stmt = "".to_string();
    let mut call_expr = quote!{ #pat }.to_string();
    //  Match the type and transform accordingly.
    match extern_type.as_str() {
        //  * const :: cty :: c_char => &Strn
        "* const :: cty :: c_char" => {
            wrap_type = "&Strn".to_string();
            //  e.g. `name.validate()`
            validation_stmt = format!("{}.validate()", ident);
            //  e.g. `name.as_ptr()`
            call_expr = format!("{}.as_ptr()", ident);
        }
        //  * mut :: cty :: c_void => Ptr
        "* mut :: cty :: c_void" => {
            wrap_type = "Ptr".to_string();
        }
        //  * mut os_task => Out<os_task>
        "* mut os_task" => {
            //  TODO: Use regex to match any `os_*`: https://rust-lang-nursery.github.io/rust-cookbook/text/regex.html
            wrap_type = "Out<os_task>".to_string();
        }
        //  * mut os_stack_t => Out<[os_stack_t]>
        "* mut os_stack_t" => {
            wrap_type = "Out<[os_stack_t]>".to_string();
            //  e.g. stack_bottom.as_ptr()
            call_expr = format!("{}.as_ptr()", ident);
        }
        _ => {}
    }
    //  Return the transformed arg.
    TransformedArg {
        ident:           Box::new(ident),
        extern_type:     Box::new(extern_type),
        wrap_type:       Box::new(wrap_type),
        validation_stmt: Box::new(validation_stmt),
        call_expr:       Box::new(call_expr),
        ident_span:      Box::new(pat_span),
        type_span:       Box::new(ty_span),
    }
}
/// Transform the extern arg for Wrap declaration, Validation statement and Call expression.
Transform the extern arg for Wrap declaration, Validation statement and Call expression.
Transform the extern arg for Wrap declaration Validation statement and Call expression .
fn transform_arg(arg: &PatType) -> TransformedArg {
    //  `arg` contains `pat : ty` e.g. `t : * mut os_task`
    //  println!("arg: {:#?}", arg);
    let syn::PatType { pat, ty, .. } = arg;
    //  println!("pat: {}, ty: {}", quote!{ #pat }, quote!{ #ty });
    let pat_span = pat.span();  //  syn::Pat
    let ty_span = ty.span();    //  syn::Type
    let ident = quote!{ #pat }.to_string();
    let extern_type = quote!{ #ty }.to_string();
    let mut wrap_type = quote!{ #ty }.to_string();
    let mut validation_stmt = "".to_string();
    let mut call_expr = quote!{ #pat }.to_string();
    //  Match the type and transform accordingly.
    match extern_type.as_str() {
        //  * const :: cty :: c_char => &Strn
        "* const :: cty :: c_char" => {
            wrap_type = "&Strn".to_string();
            //  e.g. `name.validate()`
            validation_stmt = format!("{}.validate()", ident);
            //  e.g. `name.as_ptr()`
            call_expr = format!("{}.as_ptr()", ident);
        }
        //  * mut :: cty :: c_void => Ptr
        "* mut :: cty :: c_void" => {
            wrap_type = "Ptr".to_string();
        }
        //  * mut os_task => Out<os_task>
        "* mut os_task" => {
            //  TODO: Use regex to match any `os_*`: https://rust-lang-nursery.github.io/rust-cookbook/text/regex.html
            wrap_type = "Out<os_task>".to_string();
        }
        //  * mut os_stack_t => Out<[os_stack_t]>
        "* mut os_stack_t" => {
            wrap_type = "Out<[os_stack_t]>".to_string();
            //  e.g. stack_bottom.as_ptr()
            call_expr = format!("{}.as_ptr()", ident);
        }
        _ => {}
    }
    //  Return the transformed arg.
    TransformedArg {
        ident:           Box::new(ident),
        extern_type:     Box::new(extern_type),
        wrap_type:       Box::new(wrap_type),
        validation_stmt: Box::new(validation_stmt),
        call_expr:       Box::new(call_expr),
        ident_span:      Box::new(pat_span),
        type_span:       Box::new(ty_span),
    }
}
fn transform_arg ( arg : & PatType ) -> TransformedArg { //  `arg` contains `pat : ty` e.g. `t : * mut os_task` //  println!("arg: {:#?}", arg); let syn :: PatType { pat , ty , .. } = arg ; //  println!("pat: {}, ty: {}", quote!{ #pat }, quote!{ #ty }); let pat_span = pat . span ( ) ; //  syn::Pat let ty_span = ty . span ( ) ; //  syn::Type let ident = quote ! { pat } . to_string ( ) ; let extern_type = quote ! { ty } . to_string ( ) ; let mut wrap_type = quote ! { ty } . to_string ( ) ; let mut validation_stmt = " " . to_string ( ) ; let mut call_expr = quote ! { pat } . to_string ( ) ; //  Match the type and transform accordingly. match extern_type . as_str ( ) { //  * const :: cty :: c_char => &Strn " " => { wrap_type = " " . to_string ( ) ; //  e.g. `name.validate()` validation_stmt = format ! ( " " ident ) ; //  e.g. `name.as_ptr()` call_expr = format ! ( " " ident ) ; } //  * mut :: cty :: c_void => Ptr " " => { wrap_type = " " . to_string ( ) ; } //  * mut os_task => Out<os_task> " " => { //  TODO: Use regex to match any `os_*`: https://rust-lang-nursery.github.io/rust-cookbook/text/regex.html wrap_type = " " . to_string ( ) ; } //  * mut os_stack_t => Out<[os_stack_t]> " " => { wrap_type = " " . to_string ( ) ; //  e.g. stack_bottom.as_ptr() call_expr = format ! ( " " ident ) ; } _ => { } } //  Return the transformed arg. TransformedArg { ident : Box :: new ( ident ) , extern_type : Box :: new ( extern_type ) , wrap_type : Box :: new ( wrap_type ) , validation_stmt : Box :: new ( validation_stmt ) , call_expr : Box :: new ( call_expr ) , ident_span : Box :: new ( pat_span ) , type_span : Box :: new ( ty_span ) , } }
Transform the extern arg for Wrap declaration, Validation statement and Call expression.
Transform the extern arg for Wrap declaration Validation statement and Call expression .
arg
&PatType
arg
&PatType