/// Construct an expression for a NULL at any type, including forward declarations,
/// function pointers, and normal pointers.
Construct an expression for a NULL at any type, including forward declarations,
function pointers, and normal pointers.
Construct an expression for a NULL at any type including forward declarations function pointers and normal pointers .
fn null_ptr(&self, type_id: CTypeId, is_static: bool) -> Result<P<Expr>, String> {
        if self.ast_context.is_function_pointer(type_id) {
            return Ok(mk().path_expr(vec!["None"]))
        }
        let pointee = match self.ast_context.resolve_type(type_id).kind {
            CTypeKind::Pointer(pointee) => pointee,
            _ => return Err(format!("null_ptr requires a pointer")),
        };
        let ty = self.convert_type(type_id)?;
        let mut zero = mk().lit_expr(mk().int_lit(0, LitIntType::Unsuffixed));
        if is_static && !pointee.qualifiers.is_const {
            let mut qtype = pointee;
            qtype.qualifiers.is_const = true;
            let ty_ = self.type_converter.borrow_mut().convert_pointer(&self.ast_context, qtype)?;
            zero = mk().cast_expr(zero, ty_);
        }
        Ok(mk().cast_expr(zero, ty))
    }
fn null_ptr ( & self , type_id : CTypeId , is_static : bool ) -> Result < P < Expr > , String > { if self . ast_context . is_function_pointer ( type_id ) { return Ok ( mk ( ) . path_expr ( vec ! [ " " ] ) ) } let pointee = match self . ast_context . resolve_type ( type_id ) . kind { CTypeKind :: Pointer ( pointee ) => pointee , _ => return Err ( format ! ( " " ) ) , } ; let ty = self . convert_type ( type_id ) ? ; let mut zero = mk ( ) . lit_expr ( mk ( ) . int_lit ( 0 , LitIntType :: Unsuffixed ) ) ; if is_static && ! pointee . qualifiers . is_const { let mut qtype = pointee ; qtype . qualifiers . is_const = true ; let ty_ = self . type_converter . borrow_mut ( ) . convert_pointer ( & self . ast_context , qtype ) ? ; zero = mk ( ) . cast_expr ( zero , ty_ ) ; } Ok ( mk ( ) . cast_expr ( zero , ty ) ) }
Construct an expression for a NULL at any type, including forward declarations,
function pointers, and normal pointers.
Construct an expression for a NULL at any type including forward declarations function pointers and normal pointers .
&self
type_id
CTypeId
is_static
bool