Skip to content

Latest commit

 

History

History
252 lines (207 loc) · 5.51 KB

File metadata and controls

252 lines (207 loc) · 5.51 KB

Note: This document covers API impact only. For more details, see the ABI compatibility page

Remove a bits member

Overview

- init step 1 step 2
fidl link link
dart link link
go link link
hlcpp link link
llcpp link link
rust link link

Initial State {#init}

FIDL {#fidl-init}

type Flags = flexible bits {
    OPTION_A = 1;
    OPTION_B = 2;
    OPTION_C = 4;
};

Dart {#dart-init}

void useBits(fidllib.Flags bits) {
  if ((bits & fidllib.Flags.optionA).$value != 0) {
    print('option A is set');
  }
  if ((bits & fidllib.Flags.optionB).$value != 0) {
    print('option B is set');
  }
  if ((bits & fidllib.Flags.optionC).$value != 0) {
    print('option C is set');
  }
  if (bits.hasUnknownBits()) {
    print('unknown options: ${bits.getUnknownBits()}');
  }
}

Go {#go-init}

func useBits(bits lib.Flags) {
	if bits.HasBits(lib.FlagsOptionA) {
		fmt.Println("option C is set")
	}
	if bits.HasBits(lib.FlagsOptionB) {
		fmt.Println("option C is set")
	}
	if bits.HasBits(lib.FlagsOptionC) {
		fmt.Println("option C is set")
	}
	if bits.HasUnknownBits() {
		fmt.Printf("unknown options: 0x%x", bits.GetUnknownBits())
	}
}

HLCPP {#hlcpp-init}

void use_member(fidl_test::Flags bits) {
  if (bits & fidl_test::Flags::OPTION_A) {
    printf("option A is set\n");
  }
  if (bits & fidl_test::Flags::OPTION_B) {
    printf("option B is set\n");
  }
  if (bits & fidl_test::Flags::OPTION_C) {
    printf("option C is set\n");
  }
  if (bits.has_unknown_bits()) {
    printf("unknown options: 0x%04x", uint32_t(bits.unknown_bits()));
  }
}

LLCPP {#llcpp-init}

void use_member(fidl_test::wire::Flags bits) {
  if (bits & fidl_test::wire::Flags::kOptionA) {
    printf("option A is set\n");
  }
  if (bits & fidl_test::wire::Flags::kOptionB) {
    printf("option B is set\n");
  }
  if (bits & fidl_test::wire::Flags::kOptionC) {
    printf("option C is set\n");
  }
  if (bits.has_unknown_bits()) {
    printf("unknown options: 0x%04x", uint32_t(bits.unknown_bits()));
  }
}

Rust {#rust-init}

fn use_bits(bits: &fidl_lib::Flags) {
    if bits.contains(fidl_lib::Flags::OptionA) {
        println!("option A is set");
    }
    if bits.contains(fidl_lib::Flags::OptionB) {
        println!("option B is set");
    }
    if bits.contains(fidl_lib::Flags::OptionC) {
        println!("option C is set");
    }
    if bits.has_unknown_bits() {
        println!("unknown options: {:x}", bits.get_unknown_bits());
    }
}

Update Source Code {#step-1}

Dart {#dart-1}

  • Remove references to the soon-to-be-removed member
  void useBits(fidllib.Flags bits) {
    if ((bits & fidllib.Flags.optionA).$value != 0) {
      print('option A is set');
    }
    if ((bits & fidllib.Flags.optionB).$value != 0) {
      print('option B is set');
    }
-   if ((bits & fidllib.Flags.optionC).$value != 0) {
-     print('option C is set');
-   }
    if (bits.hasUnknownBits()) {
      print('unknown options: ${bits.getUnknownBits()}');
    }
  }

Go {#go-1}

  • Remove references to the soon-to-be-removed member
  func useBits(bits lib.Flags) {
  	if bits.HasBits(lib.FlagsOptionA) {
  		fmt.Println("option C is set")
  	}
  	if bits.HasBits(lib.FlagsOptionB) {
  		fmt.Println("option C is set")
  	}
- 	if bits.HasBits(lib.FlagsOptionC) {
- 		fmt.Println("option C is set")
- 	}
  	if bits.HasUnknownBits() {
  		fmt.Printf("unknown options: 0x%x", bits.GetUnknownBits())
  	}
  }
  

HLCPP {#hlcpp-1}

  • Remove references to the soon-to-be-removed member
  void use_member(fidl_test::Flags bits) {
    if (bits & fidl_test::Flags::OPTION_A) {
      printf("option A is set\n");
    }
    if (bits & fidl_test::Flags::OPTION_B) {
      printf("option B is set\n");
    }
-   if (bits & fidl_test::Flags::OPTION_C) {
-     printf("option C is set\n");
-   }
    if (bits.has_unknown_bits()) {
      printf("unknown options: 0x%04x", uint32_t(bits.unknown_bits()));
    }
  }

LLCPP {#llcpp-1}

  • Remove references to the soon-to-be-removed member
  void use_member(fidl_test::wire::Flags bits) {
    if (bits & fidl_test::wire::Flags::kOptionA) {
      printf("option A is set\n");
    }
    if (bits & fidl_test::wire::Flags::kOptionB) {
      printf("option B is set\n");
    }
-   if (bits & fidl_test::wire::Flags::kOptionC) {
-     printf("option C is set\n");
-   }
    if (bits.has_unknown_bits()) {
      printf("unknown options: 0x%04x", uint32_t(bits.unknown_bits()));
    }
  }

Rust {#rust-1}

  • Remove references to the soon-to-be-removed member
  fn use_bits(bits: &fidl_lib::Flags) {
      if bits.contains(fidl_lib::Flags::OptionA) {
          println!("option A is set");
      }
      if bits.contains(fidl_lib::Flags::OptionB) {
          println!("option B is set");
      }
-     if bits.contains(fidl_lib::Flags::OptionC) {
-         println!("option C is set");
-     }
      if bits.has_unknown_bits() {
          println!("unknown options: {:x}", bits.get_unknown_bits());
      }
  }

Update FIDL Library {#step-2}

  • Remove the bits member
  type Flags = flexible bits {
      OPTION_A = 1;
      OPTION_B = 2;
-     OPTION_C = 4;
  };