-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Open
Labels
c++pr-requestedA Pull Request is requested to move the issue forward.A Pull Request is requested to move the issue forward.
Description
As the title mentions, when using a native table from another namespace inside another table, the generated code is missing the namespace in the Pack() function. See the below reproduction scenario.
Minimal example
// native.hpp
#include <vector>
struct MyNativeInterface {
std::vector<int> data;
};// native.fbs
// flatc --cpp --gen-object-api native.fbs
native_include "native.hpp";
namespace native;
table TableWithNative (native_type: "native::MyNativeInterface") {
data: [int];
}// consumer.fbs
// flatc --cpp --gen-object-api consumer.fbs
include "native.fbs";
namespace foo;
table Consumer {
c1: native.TableWithNative;
c2: [native.TableWithNative] (native_inline);
}The generated header for the consumer.fbs is as below:
// consumer_generated.h
//...
#include "native_generated.h"
namespace foo {
// ...
inline ::flatbuffers::Offset<Consumer> Consumer::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const ConsumerT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
(void)_rehasher;
(void)_o;
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const ConsumerT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
auto _c1 = _o->c1 ? CreateTableWithNative(_fbb, _o->c1.get(), _rehasher) : 0; // <-- no good! should be native::CreateTableWithNative
auto _c2 = _o->c2.size() ? _fbb.CreateVector<::flatbuffers::Offset<native::TableWithNative>> (_o->c2.size(), [](size_t i, _VectorArgs *__va) { return CreateTableWithNative(*__va->__fbb, &(__va->__o->c2[i]), __va->__rehasher); }, &_va ) : 0;
return foo::CreateConsumer(
_fbb,
_c1,
_c2);
}
// NOTE: It should be 'native::CreateTableWithNative', and not just 'CreateTableWithNative' in both 'c1' and 'c2' above.
// ...
}It should be native::CreateTableWithNative, and not just CreateTableWithNative in both c1 and c2 above.
Tagging @cosmith-nvidia due to relevance to this implementation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
c++pr-requestedA Pull Request is requested to move the issue forward.A Pull Request is requested to move the issue forward.