-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Group optional encoder_v2 #144
Merged
huangminghuang
merged 4 commits into
objectcomputing:master
from
martinfantini:group_encoder_error_v2
Mar 6, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
507f3fa
Add reusable the encoder and decoder test class
martinfantini 5dc3762
Revert the change which control the pointer
martinfantini 673fa54
More tests in the group encoder
martinfantini 3809d54
Add code changes to support the optional group for the encoder V2
martinfantini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,11 +25,13 @@ std::string get_properties_type(const Instruction *inst) { | |
using namespace mfast; | ||
struct ext_cref_type_getter : mfast::field_instruction_visitor { | ||
std::stringstream out_; | ||
bool is_group_type_ = false; | ||
|
||
public: | ||
ext_cref_type_getter() {} | ||
|
||
std::string get() { return out_.str(); } | ||
bool group_type() { return is_group_type_; } | ||
|
||
virtual void visit(const int32_field_instruction *inst, void *) override { | ||
out_ << "ext_cref<int32_cref, " << get_operator_tag(inst) << ", " | ||
|
@@ -83,6 +85,7 @@ struct ext_cref_type_getter : mfast::field_instruction_visitor { | |
virtual void visit(const group_field_instruction *inst, void *) override { | ||
out_ << "ext_cref< " << codegen_base::cpp_name(inst) | ||
<< "_cref, group_type_tag, " << get_properties_type(inst) << ">"; | ||
is_group_type_ = true; | ||
} | ||
|
||
virtual void visit(const sequence_field_instruction *inst, void *) override; | ||
|
@@ -132,6 +135,12 @@ std::string get_ext_cref_type(const field_instruction *inst) { | |
return getter.get(); | ||
} | ||
|
||
bool is_group_type(const field_instruction *inst) { | ||
ext_cref_type_getter getter; | ||
inst->accept(getter, nullptr); | ||
return getter.group_type(); | ||
} | ||
|
||
void ext_cref_type_getter::visit(const sequence_field_instruction *inst, | ||
void *) { | ||
const uint32_field_instruction *length_inst = inst->length_instruction(); | ||
|
@@ -473,9 +482,17 @@ void inl_gen::visit(const mfast::group_field_instruction *inst, void *pIndex) { | |
|
||
for (std::size_t i = 0; i < inst->subinstructions().size(); ++i) { | ||
const field_instruction *subinst = inst->subinstructions()[i]; | ||
; | ||
out_ << " visitor.visit(" << get_ext_cref_type(subinst) << " ((*this)[" | ||
<< i << "]) );\n"; | ||
|
||
if (is_group_type(subinst) && subinst->optional()) | ||
{ | ||
out_ << " {\n" | ||
<< " " << get_ext_cref_type(subinst) << " ext_cref_group((*this)[" << i << "]);\n" | ||
<< " ext_cref_group.set_group_present(this->field_storage(" << i << ")->is_present());\n" | ||
<< " visitor.visit(ext_cref_group);\n" | ||
<< " }\n"; | ||
} | ||
else | ||
out_ << " visitor.visit(" << get_ext_cref_type(subinst) << " ((*this)[" << i << "]) );\n"; | ||
} | ||
|
||
out_ << "}\n\n"; | ||
|
@@ -508,6 +525,7 @@ void inl_gen::visit(const mfast::group_field_instruction *inst, void *pIndex) { | |
|
||
for (std::size_t i = 0; i < inst->subinstructions().size(); ++i) { | ||
const field_instruction *subinst = inst->subinstructions()[i]; | ||
|
||
out_ << " visitor.visit(" << get_ext_mref_type(subinst) << " ((*this)[" | ||
<< i << "]) );\n"; | ||
} | ||
|
@@ -662,7 +680,7 @@ void inl_gen::visit(const mfast::sequence_field_instruction *inst, | |
|
||
for (std::size_t i = 0; i < inst->subinstructions().size(); ++i) { | ||
const field_instruction *subinst = inst->subinstructions()[i]; | ||
; | ||
|
||
out_ << " visitor.visit(" << get_ext_cref_type(subinst) << " ((*this)[" | ||
<< i << "]) );\n"; | ||
} | ||
|
@@ -677,7 +695,7 @@ void inl_gen::visit(const mfast::sequence_field_instruction *inst, | |
|
||
for (std::size_t i = 0; i < inst->subinstructions().size(); ++i) { | ||
const field_instruction *subinst = inst->subinstructions()[i]; | ||
; | ||
|
||
out_ << " visitor.visit(" << get_ext_mref_type(subinst) << " ((*this)[" | ||
<< i << "]) );\n"; | ||
} | ||
|
@@ -791,9 +809,17 @@ void inl_gen::visit(const mfast::template_instruction *inst, void *) { | |
|
||
for (std::size_t i = 0; i < inst->subinstructions().size(); ++i) { | ||
const field_instruction *subinst = inst->subinstructions()[i]; | ||
; | ||
out_ << " visitor.visit(" << get_ext_cref_type(subinst) << " ((*this)[" | ||
<< i << "]) );\n"; | ||
|
||
if (is_group_type(subinst) && subinst->optional()) | ||
{ | ||
out_ << " {\n" | ||
<< " " << get_ext_cref_type(subinst) << " ext_cref_group((*this)[" << i << "]);\n" | ||
<< " ext_cref_group.set_group_present(this->field_storage(" << i << ")->is_present());\n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the set of the group presence, at the encode time. |
||
<< " visitor.visit(ext_cref_group);\n" | ||
<< " }\n"; | ||
} | ||
else | ||
out_ << " visitor.visit(" << get_ext_cref_type(subinst) << " ((*this)[" << i << "]) );\n"; | ||
} | ||
|
||
out_ << "}\n\n"; | ||
|
@@ -842,7 +868,7 @@ void inl_gen::visit(const mfast::template_instruction *inst, void *) { | |
|
||
for (std::size_t i = 0; i < inst->subinstructions().size(); ++i) { | ||
const field_instruction *subinst = inst->subinstructions()[i]; | ||
; | ||
|
||
out_ << " visitor.visit(" << get_ext_mref_type(subinst) << " ((*this)[" | ||
<< i << "]) );\n"; | ||
} | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the set of the group presence, at the encode time.