This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git
The following commit(s) were added to refs/heads/main by this push:
new 7f949611e chore(c++): move meta string to meta dir (#2940)
7f949611e is described below
commit 7f949611e82fced8b68c090d73e44b9756c9793d
Author: Shawn Yang <[email protected]>
AuthorDate: Thu Nov 27 19:27:46 2025 +0800
chore(c++): move meta string to meta dir (#2940)
## What does this PR do?
move meta string to meta dir
## Related issues
<!--
Is there any related issue? If this PR closes them you say say
fix/closes:
- #xxxx0
- #xxxx1
- Fixes #xxxx2
-->
## Does this PR introduce any user-facing change?
<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fory/issues/new/choose) describing the
need to do so and update the document if necessary.
Delete section if not applicable.
-->
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
Delete section if not applicable.
-->
---
cpp/fory/meta/BUILD | 13 +++++++++++++
cpp/fory/{serialization => meta}/meta_string.cc | 6 +++---
cpp/fory/{serialization => meta}/meta_string.h | 4 ++--
cpp/fory/{serialization => meta}/meta_string_test.cc | 6 +++---
cpp/fory/row/schema.cc | 4 ++--
cpp/fory/serialization/BUILD | 11 -----------
cpp/fory/serialization/context.cc | 4 +++-
cpp/fory/serialization/context.h | 4 ++--
cpp/fory/serialization/type_resolver.cc | 4 +++-
cpp/fory/util/BUILD | 1 -
cpp/fory/util/bit_util.h | 8 ++++----
cpp/fory/util/buffer.h | 10 ++++++----
12 files changed, 41 insertions(+), 34 deletions(-)
diff --git a/cpp/fory/meta/BUILD b/cpp/fory/meta/BUILD
index c595c7d37..1691199f0 100644
--- a/cpp/fory/meta/BUILD
+++ b/cpp/fory/meta/BUILD
@@ -5,6 +5,9 @@ cc_library(
srcs = glob(["*.cc"], exclude=["*test.cc"], allow_empty = True),
hdrs = glob(["*.h"]),
strip_include_prefix = "/cpp",
+ deps = [
+ "//cpp/fory/util:fory_util",
+ ],
visibility = ["//visibility:public"],
)
@@ -43,3 +46,13 @@ cc_test(
"@googletest//:gtest",
],
)
+
+cc_test(
+ name = "meta_string_test",
+ srcs = ["meta_string_test.cc"],
+ deps = [
+ ":fory_meta",
+ "@googletest//:gtest",
+ "@googletest//:gtest_main",
+ ],
+)
diff --git a/cpp/fory/serialization/meta_string.cc
b/cpp/fory/meta/meta_string.cc
similarity index 99%
rename from cpp/fory/serialization/meta_string.cc
rename to cpp/fory/meta/meta_string.cc
index 63303beae..2aa8012a8 100644
--- a/cpp/fory/serialization/meta_string.cc
+++ b/cpp/fory/meta/meta_string.cc
@@ -17,7 +17,7 @@
* under the License.
*/
-#include "fory/serialization/meta_string.h"
+#include "fory/meta/meta_string.h"
#include "fory/util/buffer.h"
@@ -25,7 +25,7 @@
#include <cctype>
namespace fory {
-namespace serialization {
+namespace meta {
MetaStringDecoder::MetaStringDecoder(char special_char1, char special_char2)
: special_char1_(special_char1), special_char2_(special_char2) {}
@@ -567,5 +567,5 @@ MetaStringEncoder::encode(const std::string &input,
return result;
}
-} // namespace serialization
+} // namespace meta
} // namespace fory
diff --git a/cpp/fory/serialization/meta_string.h b/cpp/fory/meta/meta_string.h
similarity index 98%
rename from cpp/fory/serialization/meta_string.h
rename to cpp/fory/meta/meta_string.h
index 6087006f4..336cbea88 100644
--- a/cpp/fory/serialization/meta_string.h
+++ b/cpp/fory/meta/meta_string.h
@@ -29,7 +29,7 @@
#include <vector>
namespace fory {
-namespace serialization {
+namespace meta {
// Encoding for meta strings, aligned with Rust/Java Encoding
// definitions in fory-core.
@@ -146,5 +146,5 @@ private:
int lower_upper_digit_special_char_value(char c) const;
};
-} // namespace serialization
+} // namespace meta
} // namespace fory
diff --git a/cpp/fory/serialization/meta_string_test.cc
b/cpp/fory/meta/meta_string_test.cc
similarity index 99%
rename from cpp/fory/serialization/meta_string_test.cc
rename to cpp/fory/meta/meta_string_test.cc
index f41a7c1b7..7f50f5d0f 100644
--- a/cpp/fory/serialization/meta_string_test.cc
+++ b/cpp/fory/meta/meta_string_test.cc
@@ -17,12 +17,12 @@
* under the License.
*/
-#include "fory/serialization/meta_string.h"
+#include "fory/meta/meta_string.h"
#include <gtest/gtest.h>
namespace fory {
-namespace serialization {
+namespace meta {
namespace {
class MetaStringTest : public ::testing::Test {
@@ -519,5 +519,5 @@ TEST_F(MetaStringTest, MixedAlphaDigit) {
}
} // namespace
-} // namespace serialization
+} // namespace meta
} // namespace fory
diff --git a/cpp/fory/row/schema.cc b/cpp/fory/row/schema.cc
index 5d3ef9341..03cca3c1e 100644
--- a/cpp/fory/row/schema.cc
+++ b/cpp/fory/row/schema.cc
@@ -18,7 +18,7 @@
*/
#include "fory/row/schema.h"
-#include "fory/serialization/meta_string.h"
+#include "fory/meta/meta_string.h"
#include "fory/type/type.h"
#include <algorithm>
#include <stdexcept>
@@ -26,7 +26,7 @@
namespace fory {
namespace row {
-using namespace serialization;
+using namespace meta;
namespace {
diff --git a/cpp/fory/serialization/BUILD b/cpp/fory/serialization/BUILD
index a19d872e5..2c8f8dfd7 100644
--- a/cpp/fory/serialization/BUILD
+++ b/cpp/fory/serialization/BUILD
@@ -4,7 +4,6 @@ cc_library(
name = "fory_serialization",
srcs = [
"context.cc",
- "meta_string.cc",
"type_resolver.cc",
"skip.cc",
],
@@ -16,7 +15,6 @@ cc_library(
"context.h",
"enum_serializer.h",
"fory.h",
- "meta_string.h",
"map_serializer.h",
"ref_resolver.h",
"serializer.h",
@@ -88,15 +86,6 @@ cc_test(
],
)
-cc_test(
- name = "meta_string_test",
- srcs = ["meta_string_test.cc"],
- deps = [
- ":fory_serialization",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
-)
cc_binary(
name = "xlang_test_main",
diff --git a/cpp/fory/serialization/context.cc
b/cpp/fory/serialization/context.cc
index b814aa52a..a29609697 100644
--- a/cpp/fory/serialization/context.cc
+++ b/cpp/fory/serialization/context.cc
@@ -18,7 +18,7 @@
*/
#include "fory/serialization/context.h"
-#include "fory/serialization/meta_string.h"
+#include "fory/meta/meta_string.h"
#include "fory/serialization/type_resolver.h"
#include "fory/thirdparty/MurmurHash3.h"
#include "fory/type/type.h"
@@ -26,6 +26,8 @@
namespace fory {
namespace serialization {
+using namespace meta;
+
// ============================================================================
// Meta String Encoding Constants (shared between encoder and writer)
// ============================================================================
diff --git a/cpp/fory/serialization/context.h b/cpp/fory/serialization/context.h
index 856a2df15..77ca3afde 100644
--- a/cpp/fory/serialization/context.h
+++ b/cpp/fory/serialization/context.h
@@ -19,8 +19,8 @@
#pragma once
+#include "fory/meta/meta_string.h"
#include "fory/serialization/config.h"
-#include "fory/serialization/meta_string.h"
#include "fory/serialization/ref_resolver.h"
#include "fory/serialization/type_info.h"
#include "fory/util/buffer.h"
@@ -387,7 +387,7 @@ private:
std::unordered_map<int64_t, std::shared_ptr<TypeInfo>> parsed_type_infos_;
// Dynamic meta strings used for named type/class info.
- MetaStringTable meta_string_table_;
+ meta::MetaStringTable meta_string_table_;
};
/// Implementation of DepthGuard destructor
diff --git a/cpp/fory/serialization/type_resolver.cc
b/cpp/fory/serialization/type_resolver.cc
index f18410755..a699d4fef 100644
--- a/cpp/fory/serialization/type_resolver.cc
+++ b/cpp/fory/serialization/type_resolver.cc
@@ -18,8 +18,8 @@
*/
#include "fory/serialization/type_resolver.h"
+#include "fory/meta/meta_string.h"
#include "fory/serialization/context.h"
-#include "fory/serialization/meta_string.h"
#include "fory/thirdparty/MurmurHash3.h"
#include "fory/type/type.h"
#include <algorithm>
@@ -30,6 +30,8 @@
namespace fory {
namespace serialization {
+using namespace meta;
+
// Constants from xlang spec
constexpr size_t SMALL_NUM_FIELDS_THRESHOLD = 0b11111;
constexpr uint8_t REGISTER_BY_NAME_FLAG = 0b100000;
diff --git a/cpp/fory/util/BUILD b/cpp/fory/util/BUILD
index 6e90873e9..7cb528607 100644
--- a/cpp/fory/util/BUILD
+++ b/cpp/fory/util/BUILD
@@ -8,7 +8,6 @@ cc_library(
alwayslink=True,
linkstatic=True,
deps = [
- "//cpp/fory/meta:fory_meta",
"@abseil-cpp//absl/debugging:failure_signal_handler",
"@abseil-cpp//absl/debugging:stacktrace",
"@abseil-cpp//absl/debugging:symbolize",
diff --git a/cpp/fory/util/bit_util.h b/cpp/fory/util/bit_util.h
index 2d87f81de..53fe4f789 100644
--- a/cpp/fory/util/bit_util.h
+++ b/cpp/fory/util/bit_util.h
@@ -27,8 +27,6 @@
#include <string>
#include <type_traits>
-#include "fory/meta/type_traits.h"
-
#ifdef _WIN32
#define ROW_LITTLE_ENDIAN 1
#else
@@ -144,8 +142,10 @@ static inline void ByteSwap(void *dst, const void *src,
int len) {
// Convert to little/big endian format from the machine's native endian format.
template <typename T>
using IsEndianConvertibleType =
- meta::IsOneOf<T, int64_t, uint64_t, int32_t, uint32_t, int16_t, uint16_t,
- float, double>;
+ std::disjunction<std::is_same<T, int64_t>, std::is_same<T, uint64_t>,
+ std::is_same<T, int32_t>, std::is_same<T, uint32_t>,
+ std::is_same<T, int16_t>, std::is_same<T, uint16_t>,
+ std::is_same<T, float>, std::is_same<T, double>>;
template <typename T>
using EnableIfIsEndianConvertibleType =
diff --git a/cpp/fory/util/buffer.h b/cpp/fory/util/buffer.h
index 62dda9b74..142c9b042 100644
--- a/cpp/fory/util/buffer.h
+++ b/cpp/fory/util/buffer.h
@@ -95,8 +95,9 @@ public:
reinterpret_cast<T *>(data_ + offset)[0] = value;
}
- template <typename T,
- typename = meta::EnableIfIsOneOf<T, int8_t, uint8_t, bool>>
+ template <typename T, typename = std::enable_if_t<std::disjunction_v<
+ std::is_same<T, int8_t>, std::is_same<T, uint8_t>,
+ std::is_same<T, bool>>>>
inline void UnsafePutByte(uint32_t offset, T value) {
data_[offset] = value;
}
@@ -113,8 +114,9 @@ public:
return value;
}
- template <typename T,
- typename = meta::EnableIfIsOneOf<T, int8_t, uint8_t, bool>>
+ template <typename T, typename = std::enable_if_t<std::disjunction_v<
+ std::is_same<T, int8_t>, std::is_same<T, uint8_t>,
+ std::is_same<T, bool>>>>
inline T GetByteAs(uint32_t relative_offset) {
FORY_CHECK(relative_offset < size_) << "Out of range " << relative_offset
<< " should be less than " << size_;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]