Skip to content

Commit

Permalink
Add @cpp.UseOpEncode fixtures
Browse files Browse the repository at this point in the history
Summary: Add missing fixtures

Reviewed By: Filip-F

Differential Revision: D68918587

fbshipit-source-id: fb48b6bcfa0430a23d84d2d78d715205bfe88cbf
  • Loading branch information
thedavekwon authored and facebook-github-bot committed Jan 31, 2025
1 parent 0b16928 commit ab6dd9d
Show file tree
Hide file tree
Showing 19 changed files with 1,214 additions and 0 deletions.
1 change: 1 addition & 0 deletions thrift/compiler/test/fixtures/use_op_encode/cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpp2: mstch_cpp2 src/module.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Autogenerated by Thrift for
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated @nocommit
*/
#pragma once

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Autogenerated by Thrift for thrift/compiler/test/fixtures/use_op_encode/src/module.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated @nocommit
*/

#include "thrift/compiler/test/fixtures/use_op_encode/gen-cpp2/module_constants.h"

#include <thrift/lib/cpp2/gen/module_constants_cpp.h>


namespace facebook::thrift::compiler::test {
namespace module_constants {


::std::string_view _fbthrift_schema_709b2525c0eb9689() {
return "";
}
::folly::Range<const ::std::string_view*> _fbthrift_schema_709b2525c0eb9689_includes() {
return {};
}

} // namespace module_constants
} // namespace facebook::thrift::compiler::test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Autogenerated by Thrift for thrift/compiler/test/fixtures/use_op_encode/src/module.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated @nocommit
*/
#pragma once

#include <thrift/lib/cpp2/gen/module_constants_h.h>

#include "thrift/compiler/test/fixtures/use_op_encode/gen-cpp2/module_types.h"

namespace facebook::thrift::compiler::test {
/** Glean {"file": "thrift/compiler/test/fixtures/use_op_encode/src/module.thrift"} */
namespace module_constants {

FOLLY_EXPORT ::std::string_view _fbthrift_schema_709b2525c0eb9689();
FOLLY_EXPORT ::folly::Range<const ::std::string_view*> _fbthrift_schema_709b2525c0eb9689_includes();

} // namespace module_constants
} // namespace facebook::thrift::compiler::test
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Autogenerated by Thrift for thrift/compiler/test/fixtures/use_op_encode/src/module.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated @nocommit
*/

#include "thrift/compiler/test/fixtures/use_op_encode/gen-cpp2/module_data.h"

#include <thrift/lib/cpp2/gen/module_data_cpp.h>

FOLLY_CLANG_DISABLE_WARNING("-Wunused-macros")

#if defined(__GNUC__) && defined(__linux__) && !FOLLY_MOBILE
// These attributes are applied to the static data members to ensure that they
// are not stripped from the compiled binary, in order to keep them available
// for use by debuggers at runtime.
//
// The "used" attribute is required to ensure the compiler always emits unused
// data.
//
// The "section" attribute is required to stop the linker from stripping used
// data. It works by forcing all of the data members (both used and unused ones)
// into the same section. As the linker strips data on a per-section basis, it
// is then unable to remove unused data without also removing used data.
// This has a similar effect to the "retain" attribute, but works with older
// toolchains.
#define THRIFT_DATA_MEMBER [[gnu::used]] [[gnu::section(".rodata.thrift.data")]]
#else
#define THRIFT_DATA_MEMBER
#endif

namespace apache {
namespace thrift {

THRIFT_DATA_MEMBER const std::string_view TStructDataStorage<::facebook::thrift::compiler::test::MyStruct>::name = "MyStruct";
THRIFT_DATA_MEMBER const std::array<std::string_view, 4> TStructDataStorage<::facebook::thrift::compiler::test::MyStruct>::fields_names = { {
"def_field"sv,
"opt_field"sv,
"req_field"sv,
"terse_field"sv,
}};
THRIFT_DATA_MEMBER const std::array<int16_t, 4> TStructDataStorage<::facebook::thrift::compiler::test::MyStruct>::fields_ids = { {
1,
2,
3,
4,
}};
THRIFT_DATA_MEMBER const std::array<protocol::TType, 4> TStructDataStorage<::facebook::thrift::compiler::test::MyStruct>::fields_types = { {
TType::T_I32,
TType::T_I32,
TType::T_I32,
TType::T_I32,
}};
THRIFT_DATA_MEMBER const std::array<std::string_view, 4> TStructDataStorage<::facebook::thrift::compiler::test::MyStruct>::storage_names = { {
"__fbthrift_field_def_field"sv,
"__fbthrift_field_opt_field"sv,
"__fbthrift_field_req_field"sv,
"__fbthrift_field_terse_field"sv,
}};
THRIFT_DATA_MEMBER const std::array<int, 4> TStructDataStorage<::facebook::thrift::compiler::test::MyStruct>::isset_indexes = { {
0,
1,
-1,
-1,
}};

} // namespace thrift
} // namespace apache
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Autogenerated by Thrift for thrift/compiler/test/fixtures/use_op_encode/src/module.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated @nocommit
*/
#pragma once

#include <thrift/lib/cpp2/gen/module_data_h.h>

#include "thrift/compiler/test/fixtures/use_op_encode/gen-cpp2/module_types.h"

namespace apache { namespace thrift {

template <> struct TStructDataStorage<::facebook::thrift::compiler::test::MyStruct> {
static constexpr const std::size_t fields_size = 4;
static const std::string_view name;
static const std::array<std::string_view, fields_size> fields_names;
static const std::array<int16_t, fields_size> fields_ids;
static const std::array<protocol::TType, fields_size> fields_types;

private:
// The following fields describe internal storage metadata, and are private to
// prevent user logic from accessing them, but they can be inspected by
// debuggers.
static const std::array<std::string_view, fields_size> storage_names;
// -1 if the field has no isset.
static const std::array<int, fields_size> isset_indexes;
};

}} // apache::thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Autogenerated by Thrift for thrift/compiler/test/fixtures/use_op_encode/src/module.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated @nocommit
*/
#pragma once

#include "thrift/compiler/test/fixtures/use_op_encode/gen-cpp2/module_metadata.h"
#include <thrift/lib/cpp2/visitation/for_each.h>

namespace apache {
namespace thrift {
namespace detail {

template <>
struct ForEachField<::facebook::thrift::compiler::test::MyStruct> {
template <typename F, typename... T>
void operator()([[maybe_unused]] F&& f, [[maybe_unused]] T&&... t) const {
f(0, static_cast<T&&>(t).def_field_ref()...);
f(1, static_cast<T&&>(t).opt_field_ref()...);
f(2, static_cast<T&&>(t).req_field_ref()...);
f(3, static_cast<T&&>(t).terse_field_ref()...);
}
};
} // namespace detail
} // namespace thrift
} // namespace apache
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Autogenerated by Thrift for
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated @nocommit
*/
#pragma once

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* Autogenerated by Thrift for thrift/compiler/test/fixtures/use_op_encode/src/module.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated @nocommit
*/
#include <thrift/lib/cpp2/gen/module_metadata_cpp.h>
#include "thrift/compiler/test/fixtures/use_op_encode/gen-cpp2/module_metadata.h"

// some of these functions can be so large that the compiler gives up optimizing
// them - and issues a warning which may be treated as an error!
//
// these functions are so rarely called that it is probably okay for them not to
// be optimized in practice
FOLLY_CLANG_DISABLE_WARNING("-Wignored-optimization-argument")

namespace apache {
namespace thrift {
namespace detail {
namespace md {
using ThriftMetadata = ::apache::thrift::metadata::ThriftMetadata;
using ThriftPrimitiveType = ::apache::thrift::metadata::ThriftPrimitiveType;
using ThriftType = ::apache::thrift::metadata::ThriftType;
using ThriftService = ::apache::thrift::metadata::ThriftService;
using ThriftServiceContext = ::apache::thrift::metadata::ThriftServiceContext;
using ThriftFunctionGenerator = void (*)(ThriftMetadata&, ThriftService&);


const ::apache::thrift::metadata::ThriftStruct&
StructMetadata<::facebook::thrift::compiler::test::MyStruct>::gen(ThriftMetadata& metadata) {
auto res = metadata.structs()->emplace("module.MyStruct", ::apache::thrift::metadata::ThriftStruct{});
if (!res.second) {
return res.first->second;
}
::apache::thrift::metadata::ThriftStruct& module_MyStruct = res.first->second;
module_MyStruct.name() = "module.MyStruct";
module_MyStruct.is_union() = false;
static const auto* const
module_MyStruct_fields = new std::array<EncodedThriftField, 4>{ {
{ 1, "def_field", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{ }}, { 2, "opt_field", true, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{ }}, { 3, "req_field", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{ }}, { 4, "terse_field", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{ *cvStruct("thrift.TerseWrite", { }).cv_struct_ref(), }}, }};
for (const auto& f : *module_MyStruct_fields) {
::apache::thrift::metadata::ThriftField field;
field.id() = f.id;
field.name() = f.name;
field.is_optional() = f.is_optional;
f.metadata_type_interface->writeAndGenType(*field.type(), metadata);
field.structured_annotations() = f.structured_annotations;
module_MyStruct.fields()->push_back(std::move(field));
}
return res.first->second;
}

} // namespace md
} // namespace detail
} // namespace thrift
} // namespace apache
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Autogenerated by Thrift for thrift/compiler/test/fixtures/use_op_encode/src/module.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated @nocommit
*/
#pragma once

#include <vector>

#include <thrift/lib/cpp2/gen/module_metadata_h.h>
#include "thrift/compiler/test/fixtures/use_op_encode/gen-cpp2/module_types.h"


namespace apache {
namespace thrift {
namespace detail {
namespace md {

template <>
class StructMetadata<::facebook::thrift::compiler::test::MyStruct> {
public:
static const ::apache::thrift::metadata::ThriftStruct& gen(ThriftMetadata& metadata);
};
} // namespace md
} // namespace detail
} // namespace thrift
} // namespace apache
Loading

0 comments on commit ab6dd9d

Please sign in to comment.