ffi: Add Value class to represent all supported primitive values for the key-value pair IR format.#502
Merged
Merged
Conversation
gibber9809
previously approved these changes
Jul 31, 2024
gibber9809
left a comment
Contributor
There was a problem hiding this comment.
LGTM. PR title is also fine by me.
kirkrodrigues
requested changes
Aug 7, 2024
kirkrodrigues
requested changes
Aug 7, 2024
Comment on lines
+78
to
+85
| REQUIRE(int_value.is<value_int_t>()); | ||
| REQUIRE((int_value.get_immutable_view<value_int_t>() == cIntVal)); | ||
| REQUIRE_FALSE(int_value.is_null()); | ||
| REQUIRE_FALSE(int_value.is<value_float_t>()); | ||
| REQUIRE_FALSE(int_value.is<value_bool_t>()); | ||
| REQUIRE_FALSE(int_value.is<string>()); | ||
| REQUIRE_FALSE(int_value.is<EightByteEncodedTextAst>()); | ||
| REQUIRE_FALSE(int_value.is<FourByteEncodedTextAst>()); |
Member
There was a problem hiding this comment.
We can extract this into a method that basically tests
REQUIRE((std::is_same_v<value_int_t, Type> == value.is<value_int_t>()));
for each type, and then just passes in the values defined here, right?
Comment on lines
+86
to
+90
| REQUIRE_THROWS(int_value.get_immutable_view<value_float_t>()); | ||
| REQUIRE_THROWS(int_value.get_immutable_view<value_bool_t>()); | ||
| REQUIRE_THROWS(int_value.get_immutable_view<string>()); | ||
| REQUIRE_THROWS(int_value.get_immutable_view<EightByteEncodedTextAst>()); | ||
| REQUIRE_THROWS(int_value.get_immutable_view<FourByteEncodedTextAst>()); |
Member
There was a problem hiding this comment.
We can extract this into a method that does something like:
if constexpr (std::is_same_v<value_int_t, Type>) {
REQUIRE(value.get_immutable_view<Type>() == typed_value);
} else {
REQUIRE_THROWS(value.get_immutable_view<value_int_t>());
}for each type, right?
Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Member
Author
|
To be consistent within the same file, and also not be confusing with |
kirkrodrigues
requested changes
Aug 8, 2024
kirkrodrigues
approved these changes
Aug 8, 2024
Value class to represent all supported primitive values in the key-value pair IR format.Value class to represent all supported primitive values for the key-value pair IR format.
jackluo923
pushed a commit
to jackluo923/clp
that referenced
this pull request
Dec 4, 2024
…r the key-value pair IR format. (y-scope#502) Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com>
junhaoliao
pushed a commit
to junhaoliao/clp
that referenced
this pull request
May 17, 2026
…r the key-value pair IR format. (y-scope#502) Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a class named
Value, which wrapsstd::variantto implement a supertype for all the supported value types in the key-value pair IR format. The core idea of theValueclass is to provide type safety, using templates to guard the supported types, as well as the methods to:The current implementation's support types include
int64_t,double,bool,std::string, andEncodedTextAst(both four-byte encoding and eight-byte encoding). The value can also benullif it is constructed without any input (implemented usingstd::monostate).With the current design, it should be easy to extend the supported types in future development.
Validation performed