Skip to content

Commit

Permalink
Add explicit keyword for generated constructor (#386)
Browse files Browse the repository at this point in the history
* Add explicit keyword for generated constructor

* Update feature_tests headers after cargo make gen.
  • Loading branch information
makotokato authored Dec 11, 2023
1 parent 6085136 commit 5056b7b
Show file tree
Hide file tree
Showing 32 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion example/cpp/include/ICU4XDataProvider.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/cpp/include/ICU4XFixedDecimal.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/cpp/include/ICU4XFixedDecimalFormatter.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/cpp/include/ICU4XLocale.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_tests/cpp/include/AttrOpaque1.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_tests/cpp/include/AttrOpaque2.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_tests/cpp/include/Bar.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_tests/cpp/include/Float64Vec.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_tests/cpp/include/Foo.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_tests/cpp/include/MyString.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_tests/cpp/include/One.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_tests/cpp/include/Opaque.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_tests/cpp/include/OptionOpaque.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_tests/cpp/include/OptionOpaqueChar.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_tests/cpp/include/RefList.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_tests/cpp/include/RefListParameter.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_tests/cpp/include/ResultOpaque.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion feature_tests/cpp/include/Two.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Foo {
MyStruct get_struct() const;
inline const capi::Foo* AsFFI() const { return this->inner.get(); }
inline capi::Foo* AsFFIMut() { return this->inner.get(); }
inline Foo(capi::Foo* i) : inner(i) {}
inline explicit Foo(capi::Foo* i) : inner(i) {}
Foo() = default;
Foo(Foo&&) noexcept = default;
Foo& operator=(Foo&& other) noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MyStruct {
std::optional<MyStruct> create() const;
inline const capi::MyStruct* AsFFI() const { return this->inner.get(); }
inline capi::MyStruct* AsFFIMut() { return this->inner.get(); }
inline MyStruct(capi::MyStruct* i) : inner(i) {}
inline explicit MyStruct(capi::MyStruct* i) : inner(i) {}
MyStruct() = default;
MyStruct(MyStruct&&) noexcept = default;
MyStruct& operator=(MyStruct&& other) noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MyStruct {
mozilla::Maybe<MyStruct> create() const;
inline const capi::MyStruct* AsFFI() const { return this->inner.get(); }
inline capi::MyStruct* AsFFIMut() { return this->inner.get(); }
inline MyStruct(capi::MyStruct* i) : inner(i) {}
inline explicit MyStruct(capi::MyStruct* i) : inner(i) {}
MyStruct() = default;
MyStruct(MyStruct&&) noexcept = default;
MyStruct& operator=(MyStruct&& other) noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MyStruct {
void set_slice(const diplomat::span<const double> new_slice);
inline const capi::MyStruct* AsFFI() const { return this->inner.get(); }
inline capi::MyStruct* AsFFIMut() { return this->inner.get(); }
inline MyStruct(capi::MyStruct* i) : inner(i) {}
inline explicit MyStruct(capi::MyStruct* i) : inner(i) {}
MyStruct() = default;
MyStruct(MyStruct&&) noexcept = default;
MyStruct& operator=(MyStruct&& other) noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MyStruct {
void set_slice(const mozilla::Span<const double> new_slice);
inline const capi::MyStruct* AsFFI() const { return this->inner.get(); }
inline capi::MyStruct* AsFFIMut() { return this->inner.get(); }
inline MyStruct(capi::MyStruct* i) : inner(i) {}
inline explicit MyStruct(capi::MyStruct* i) : inner(i) {}
MyStruct() = default;
MyStruct(MyStruct&&) noexcept = default;
MyStruct& operator=(MyStruct&& other) noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MyStruct {
void set_str(const std::string_view new_str);
inline const capi::MyStruct* AsFFI() const { return this->inner.get(); }
inline capi::MyStruct* AsFFIMut() { return this->inner.get(); }
inline MyStruct(capi::MyStruct* i) : inner(i) {}
inline explicit MyStruct(capi::MyStruct* i) : inner(i) {}
MyStruct() = default;
MyStruct(MyStruct&&) noexcept = default;
MyStruct& operator=(MyStruct&& other) noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MyStruct {
uint8_t write_no_rearrange(capi::DiplomatWriteable& out) const;
inline const capi::MyStruct* AsFFI() const { return this->inner.get(); }
inline capi::MyStruct* AsFFIMut() { return this->inner.get(); }
inline MyStruct(capi::MyStruct* i) : inner(i) {}
inline explicit MyStruct(capi::MyStruct* i) : inner(i) {}
MyStruct() = default;
MyStruct(MyStruct&&) noexcept = default;
MyStruct& operator=(MyStruct&& other) noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MyStruct {
void set_b(uint8_t b);
inline const capi::MyStruct* AsFFI() const { return this->inner.get(); }
inline capi::MyStruct* AsFFIMut() { return this->inner.get(); }
inline MyStruct(capi::MyStruct* i) : inner(i) {}
inline explicit MyStruct(capi::MyStruct* i) : inner(i) {}
MyStruct() = default;
MyStruct(MyStruct&&) noexcept = default;
MyStruct& operator=(MyStruct&& other) noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Foo {
Bar to_bar() const;
inline const capi::Foo* AsFFI() const { return this->inner.get(); }
inline capi::Foo* AsFFIMut() { return this->inner.get(); }
inline Foo(capi::Foo* i) : inner(i) {}
inline explicit Foo(capi::Foo* i) : inner(i) {}
Foo() = default;
Foo(Foo&&) noexcept = default;
Foo& operator=(Foo&& other) noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MyOpaqueStruct {
public:
inline const capi::MyOpaqueStruct* AsFFI() const { return this->inner.get(); }
inline capi::MyOpaqueStruct* AsFFIMut() { return this->inner.get(); }
inline MyOpaqueStruct(capi::MyOpaqueStruct* i) : inner(i) {}
inline explicit MyOpaqueStruct(capi::MyOpaqueStruct* i) : inner(i) {}
MyOpaqueStruct() = default;
MyOpaqueStruct(MyOpaqueStruct&&) noexcept = default;
MyOpaqueStruct& operator=(MyOpaqueStruct&& other) noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MyOpaqueStruct {
public:
inline const capi::MyOpaqueStruct* AsFFI() const { return this->inner.get(); }
inline capi::MyOpaqueStruct* AsFFIMut() { return this->inner.get(); }
inline MyOpaqueStruct(capi::MyOpaqueStruct* i) : inner(i) {}
inline explicit MyOpaqueStruct(capi::MyOpaqueStruct* i) : inner(i) {}
MyOpaqueStruct() = default;
MyOpaqueStruct(MyOpaqueStruct&&) noexcept = default;
MyOpaqueStruct& operator=(MyOpaqueStruct&& other) noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MyOpaqueStruct {
public:
inline const capi::MyOpaqueStruct* AsFFI() const { return this->inner.get(); }
inline capi::MyOpaqueStruct* AsFFIMut() { return this->inner.get(); }
inline MyOpaqueStruct(capi::MyOpaqueStruct* i) : inner(i) {}
inline explicit MyOpaqueStruct(capi::MyOpaqueStruct* i) : inner(i) {}
MyOpaqueStruct() = default;
MyOpaqueStruct(MyOpaqueStruct&&) noexcept = default;
MyOpaqueStruct& operator=(MyOpaqueStruct&& other) noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MyOpaqueStruct {
public:
inline const capi::MyOpaqueStruct* AsFFI() const { return this->inner.get(); }
inline capi::MyOpaqueStruct* AsFFIMut() { return this->inner.get(); }
inline MyOpaqueStruct(capi::MyOpaqueStruct* i) : inner(i) {}
inline explicit MyOpaqueStruct(capi::MyOpaqueStruct* i) : inner(i) {}
MyOpaqueStruct() = default;
MyOpaqueStruct(MyOpaqueStruct&&) noexcept = default;
MyOpaqueStruct& operator=(MyOpaqueStruct&& other) noexcept = default;
Expand Down
2 changes: 1 addition & 1 deletion tool/src/cpp/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn gen_struct<W: fmt::Write>(

writeln!(
&mut public_body,
"inline {}(capi::{}* i) : inner(i) {{}}",
"inline explicit {}(capi::{}* i) : inner(i) {{}}",
opaque.name, opaque.name
)?;
writeln!(
Expand Down

0 comments on commit 5056b7b

Please sign in to comment.