Skip to content

Commit

Permalink
Carbon codegen to use @cpp.EnumType
Browse files Browse the repository at this point in the history
Summary: `cpp.enum_type` is deprecated, and always include `cpp.thrift`.

Reviewed By: yoney

Differential Revision: D68079869

fbshipit-source-id: 8bca8d0686ba16ab96eed19870504cdfed15a433
  • Loading branch information
thedavekwon authored and facebook-github-bot committed Jan 13, 2025
1 parent efeaca4 commit b160fba
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 10 deletions.
4 changes: 3 additions & 1 deletion mcrouter/lib/carbon/example/gen/HelloGoodbye.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@
*/
include "mcrouter/lib/carbon/carbon.thrift"
include "mcrouter/lib/carbon/carbon_result.thrift"
include "thrift/annotation/cpp.thrift"
include "mcrouter/lib/network/gen/Common.thrift"

cpp_include "<mcrouter/lib/carbon/CarbonProtocolReader.h>"

namespace cpp2 hellogoodbye.thrift
namespace py3 hellogoodbye.thrift

@cpp.EnumType{type = cpp.EnumUnderlyingType.U32}
enum EnumUInt32 {
HIGH = 0,
URGENT = 1,
YESTERDAY = 2
} (cpp.enum_type="uint32_t")
}

struct HelloRequest {
1: carbon.IOBufKey key
Expand Down
1 change: 1 addition & 0 deletions mcrouter/lib/carbon/test/gen/A.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
include "mcrouter/lib/carbon/carbon.thrift"
include "mcrouter/lib/carbon/carbon_result.thrift"
include "thrift/annotation/cpp.thrift"
include "mcrouter/lib/network/gen/Common.thrift"
include "mcrouter/lib/carbon/test/gen/B.thrift"
include "graphene/ticket/if/ticket_rep.thrift"
Expand Down
1 change: 1 addition & 0 deletions mcrouter/lib/carbon/test/gen/B.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
include "mcrouter/lib/carbon/carbon.thrift"
include "mcrouter/lib/carbon/carbon_result.thrift"
include "thrift/annotation/cpp.thrift"
include "mcrouter/lib/network/gen/Common.thrift"
include "graphene/ticket/if/ticket_rep.thrift"

Expand Down
19 changes: 13 additions & 6 deletions mcrouter/lib/carbon/test/gen/CarbonTest.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
include "mcrouter/lib/carbon/carbon.thrift"
include "mcrouter/lib/carbon/carbon_result.thrift"
include "thrift/annotation/cpp.thrift"
include "mcrouter/lib/network/gen/Common.thrift"

cpp_include "<mcrouter/lib/carbon/CarbonProtocolReader.h>"
Expand Down Expand Up @@ -208,41 +209,47 @@ struct TestStdContainers {
void deserialize(carbon::CarbonProtocolReader& reader);

")
@cpp.EnumType{type = cpp.EnumUnderlyingType.U32}
enum EnumUInt32 {
AAA = 0,
BBB = 1,
CCC = 2
} (cpp.enum_type="uint32_t")
}

@cpp.EnumType{type = cpp.EnumUnderlyingType.U16}
enum EnumUInt16 {
AAA = 0,
BBB = 1,
CCC = 2
} (cpp.enum_type="uint16_t")
}

@cpp.EnumType{type = cpp.EnumUnderlyingType.U8}
enum EnumUInt8 {
AAA = 0,
BBB = 1,
CCC = 2
} (cpp.enum_type="uint8_t")
}


enum EnumInt32 {
AAA = 0,
BBB = 1,
CCC = 2
} (cpp.enum_type="int32_t")
}

@cpp.EnumType{type = cpp.EnumUnderlyingType.I16}
enum EnumInt16 {
AAA = 0,
BBB = 1,
CCC = 2
} (cpp.enum_type="int16_t")
}

@cpp.EnumType{type = cpp.EnumUnderlyingType.I8}
enum EnumInt8 {
AAA = 0,
BBB = 1,
CCC = 2
} (cpp.enum_type="int8_t")
}

struct StructWithEnumUInt32 {
1: EnumUInt32 testEnum
Expand Down
3 changes: 2 additions & 1 deletion mcrouter/lib/carbon/test/gen/CarbonThriftTest.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ typedef i64 CustomAdapterTypeI64
@cpp.Adapter{name = "::carbon::test::DummyPairAdapter<::carbon::test::Timestamp,uint32_t>"}
typedef binary (cpp.type = "::folly::IOBuf") CustomAdapterTypeBinary


enum MyEnum {
A = 0,
B = 1,
C = 2
} (cpp.enum_type="int32_t")
}

union TestUnionThrift {
1: i64_3264 a
Expand Down
2 changes: 1 addition & 1 deletion mcrouter/lib/network/gen/Common.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
include "mcrouter/lib/carbon/carbon.thrift"
include "mcrouter/lib/carbon/carbon_result.thrift"

include "thrift/annotation/cpp.thrift"

cpp_include "<mcrouter/lib/carbon/CarbonProtocolReader.h>"

Expand Down
1 change: 1 addition & 0 deletions mcrouter/lib/network/gen/Memcache.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
include "mcrouter/lib/carbon/carbon.thrift"
include "mcrouter/lib/carbon/carbon_result.thrift"
include "thrift/annotation/cpp.thrift"
include "mcrouter/lib/network/gen/Common.thrift"

cpp_include "<mcrouter/lib/carbon/CarbonProtocolReader.h>"
Expand Down
2 changes: 1 addition & 1 deletion mcrouter/lib/network/test/gen/CarbonTest.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
include "mcrouter/lib/carbon/carbon.thrift"
include "mcrouter/lib/carbon/carbon_result.thrift"

include "thrift/annotation/cpp.thrift"

cpp_include "<mcrouter/lib/carbon/CarbonProtocolReader.h>"

Expand Down

0 comments on commit b160fba

Please sign in to comment.