mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-04 04:33:23 +00:00
Swap the dependency of CreateX and X::Pack object API functions. (#8754)
Previously: X::Pack forwarded to CreateX. Now: CreateX will forward to X::Pack. This is a step toward enabling using native types for tables when using the object API. When defining a native table, the user will be able to define a custom X::Pack method (which is more consistent with the existing native_type functionality for structs). By reversing the order of the dependencies, CreateX can continue to be auto-generated and will use the custom X::Pack method when overriden for native_type tables.
This commit is contained in:
@@ -3820,16 +3820,16 @@ class CppGenerator : public BaseGenerator {
|
||||
code_ += "}";
|
||||
code_ += "";
|
||||
|
||||
// Generate the X::Pack member function that simply calls the global
|
||||
// CreateX function.
|
||||
code_ += "inline " + TablePackSignature(struct_def, false, opts_) + " {";
|
||||
code_ += " return Create{{STRUCT_NAME}}(_fbb, _o, _rehasher);";
|
||||
// Generate the global CreateX function that simply calls the
|
||||
// X::Pack member function.
|
||||
code_ +=
|
||||
"inline " + TableCreateSignature(struct_def, false, opts_) + " {";
|
||||
code_ += " return {{STRUCT_NAME}}::Pack(_fbb, _o, _rehasher);";
|
||||
code_ += "}";
|
||||
code_ += "";
|
||||
|
||||
// Generate a CreateX method that works with an unpacked C++ object.
|
||||
code_ +=
|
||||
"inline " + TableCreateSignature(struct_def, false, opts_) + " {";
|
||||
code_ += "inline " + TablePackSignature(struct_def, false, opts_) + " {";
|
||||
code_ += " (void)_rehasher;";
|
||||
code_ += " (void)_o;";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user