From a3b23cfe81cd437a2b118dd10006fd2cd3b7728c Mon Sep 17 00:00:00 2001 From: Jamieson Pryor Date: Sun, 12 Nov 2023 15:53:50 -0800 Subject: [PATCH] Rev JNI Bind release header to v 0.9.8. PiperOrigin-RevId: 581793760 --- jni_bind_release.h | 1783 +++++++++++++++++++---------------- jni_bind_release_leader.inc | 2 +- 2 files changed, 956 insertions(+), 829 deletions(-) diff --git a/jni_bind_release.h b/jni_bind_release.h index eb425a6e..71e24ea0 100644 --- a/jni_bind_release.h +++ b/jni_bind_release.h @@ -15,7 +15,7 @@ */ /******************************************************************************* - * JNI Bind Version 0.9.7. + * JNI Bind Version 0.9.8. * Alpha Public Release. ******************************************************************************** * This header is the single header version which you can use to quickly test or @@ -847,8 +847,8 @@ namespace jni { class JniHelper { public: // Finds a class with "name". Note, the classloader used is whatever is - // present on the statck when this is caled. No caching is performed, - // returned jclass is a local. + // present on the stack when this is called. No caching is performed, + // returned `jclass` is a local. static jclass FindClass(const char* name); // Returns a local ref jclass for the given jobject. @@ -1121,7 +1121,7 @@ Constructor(ParamsRaw...) -> Constructor; template constexpr bool operator==(const Constructor& lhs, - const Constructor& rhs) { + const Constructor& rhs) { return lhs.params_ == rhs.params_; } @@ -1803,27 +1803,10 @@ class ClassLoader : public Object { explicit constexpr ClassLoader(const char* class_loader_name) : Object(class_loader_name) {} - // Default classloader (no name needed). explicit constexpr ClassLoader( ParentLoader_ parent_loader, SupportedClassSet supported_class_set) - __attribute__(( - enable_if(parent_loader == kDefaultClassLoader, - "You must provide a name for classloaders (except " - "kNullClassLoader and kDefaultClassLoader)"))) - : Object("__JNI_BIND_DEFAULT_CLASS_LOADER__"), - parent_loader_(parent_loader), - supported_classes_(supported_class_set.supported_classes_) {} - - // Null classloader (no name needed). - explicit constexpr ClassLoader( - ParentLoader_ parent_loader, - SupportedClassSet supported_class_set) - __attribute__(( - enable_if(parent_loader == kNullClassLoader, - "You must provide a name for classloaders (except " - "kNullClassLoader and kDefaultClassLoader)"))) - : Object("__JNI_BIND_NULL_CLASS_LOADER__"), + : Object("__JNI_NO_NAME_GIVEN__"), parent_loader_(parent_loader), supported_classes_(supported_class_set.supported_classes_) {} @@ -1943,43 +1926,6 @@ constexpr const auto& ParentLoaderForClass() { } // namespace jni -#include -#include - -namespace jni::metaprogramming { - -// Metafunction to take a sequence of indices, and produce the corresponding -// elements in sequences of tuples. -template -struct TypeIndexMask { - template - struct GetHelper {}; - - template - struct GetHelper, Ts...> { - using type = std::tuple...>; - }; - - template - using Get = typename GetHelper, Ts...>::type; - - template - struct SequenceGenerator {}; - - template - struct SequenceGenerator> { - using type = Get; - }; - - template - using type = typename SequenceGenerator::type; -}; - -template -using TypeTupFromIndexMask_t = - typename TypeIndexMask::template type; - -} // namespace jni::metaprogramming namespace jni::metaprogramming { @@ -2076,55 +2022,6 @@ struct Constants { } // namespace jni::metaprogramming -#include -#include - -namespace jni::metaprogramming { - -// Represents a value that can be [0, max], and an overflow bit. -// When incremented, the type will rollover, and set its overflow bit. -template -struct NBit { - static constexpr size_t value_ = cur_value; - static constexpr size_t overflow_bit_ = overflow_bit; - - // Only unary values will ever need the clamp. - using Increment = - NBit<(value_ == max ? 0 : std::clamp(value_ + 1, size_t{0}, max)), max, - value_ == max>; - - using ResetOverflow = NBit; -}; - -} // namespace jni::metaprogramming - -#include -#include - -namespace jni::metaprogramming { - -// Metafunction to increment types a certain number of times. -// Types must export a type alias "Increment" which increments the type once. -template -struct Increment { - template - struct IncrementCountHelper { - using type = typename Increment::template type::Increment; - }; - - template - struct IncrementCountHelper { - using type = T; - }; - - template - using type = typename IncrementCountHelper::type; -}; - -template -using Increment_t = typename Increment::template type; - -} // namespace jni::metaprogramming namespace jni { @@ -2398,106 +2295,61 @@ struct ValsConstRef { } // namespace jni::metaprogramming #include +#include namespace jni::metaprogramming { -struct Reverse { - template - struct Helper { - using type = std::tuple<>; +// Metafunction to take a sequence of indices, and produce the corresponding +// elements in sequences of tuples. +template +struct TypeIndexMask { + template + struct GetHelper {}; + + template + struct GetHelper, Ts...> { + using type = std::tuple...>; }; template - using Helper_t = typename Helper>::type; + using Get = typename GetHelper, Ts...>::type; - template - struct Helper> { - using type = ConcatenateTup_t, std::tuple>; - }; + template + struct SequenceGenerator {}; template - using type = Helper_t; -}; + struct SequenceGenerator> { + using type = Get; + }; -template -using Reverse_t = typename Reverse::template type; + template + using type = typename SequenceGenerator::type; +}; -template -using Reverse_Tup = TupleUnroller_t; +template +using TypeTupFromIndexMask_t = + typename TypeIndexMask::template type; } // namespace jni::metaprogramming #include -#include #include namespace jni::metaprogramming { -template -struct NBitSequence {}; - -template <> -struct NBitSequence<> { - using Increment = NBitSequence<>; -}; - -// Represents a sequence of "NBits". This can be useful for generating -// selections of pools of objects of various sizes. -// -// For a sequence with N values, a tuple of size N that contains tuples whose -// sizes match those of max_values can be selected from using TypeMask. -// -// In other words, a sequence of N sets of sizes K0, K1, K2...KN can represent a -// single selection with an NBitSequence where sizeof...(values) == N and -// sizeof...(max_values) == N where Ki == max_values[i]. -template -struct NBitSequence...> { - static constexpr size_t sequence_size_ = sizeof...(values); - - using Sequence = std::tuple...>; - using TypeMask = TypeIndexMask; - - template - using GetBit = TypeOfNthTupleElement_t; - - // Helper method to compare values of all NBits. - template - static constexpr bool Same(std::index_sequence = {}) { - static_assert(sizeof...(Bits) == sizeof...(values)); - return std::is_same_v, - std::index_sequence>; - } - - static constexpr size_t max_representable_size_ = ((max_values + 1) * ...); - - template - static constexpr bool same_ = Same(std::index_sequence{}); - - // If the next bit is overflowing (i.e. it just rolled over), this current - // value increments. Bits only overflow for a single cycle, otherwise higher - // order bits flip when no rollover is happening. - template - struct IncrementedBit { - using type = std::conditional_t::type::overflow_bit_, - typename GetBit::Increment, - typename GetBit::ResetOverflow>; - }; - - template <> - struct IncrementedBit { - using type = typename GetBit::Increment; - }; - - template - struct IncrementSequenceHelper {}; +// Represents a value that can be [0, max], and an overflow bit. +// When incremented, the type will rollover, and set its overflow bit. +template +struct NBit { + static constexpr size_t value_ = cur_value; + static constexpr size_t overflow_bit_ = overflow_bit; - template - struct IncrementSequenceHelper> { - using type = NBitSequence::type...>; - }; + // Only unary values will ever need the clamp. + using Increment = + NBit<(value_ == max ? 0 : std::clamp(value_ + 1, size_t{0}, max)), max, + value_ == max>; - using Increment = typename IncrementSequenceHelper< - std::make_index_sequence>::type; + using ResetOverflow = NBit; }; } // namespace jni::metaprogramming @@ -2545,38 +2397,31 @@ using LambdaStringToType = decltype(LambdaToStr(std::declval())); } // namespace jni::metaprogramming -#include #include +#include namespace jni::metaprogramming { -// Metafunction that detects a partial specialisation for a Container. -template