objectbox-generator icon indicating copy to clipboard operation
objectbox-generator copied to clipboard

Flex property type

Open greenrobot-team opened this issue 3 years ago • 2 comments
trafficstars

Using flex annotation (or another name?) on a byte array property (only this FlatBuffers type?) in the FlatBuffers schema:

// objectbox:flex
flexProperty:[byte];

Should generate a model file where the property type is 13 (which is Flex):

        {
          "id": "32:4612611183471672203",
          "name": "flexProperty",
          "type": 13
        }

Notes

  • ~FlexBuffers docs indicate std::vector<uint8_t> is returned for C++; there does not appear to be an official Go implementation.~ Not relevant, do not add flex properties to generated binding code, only to model JSON.

Tasks

  • [x] Generated C, C++ and Go code not correct.
  • [x] Figure out why property UIDs after newly added one are re-set (or is this just happening for tests?).

@greenrobot

greenrobot-team avatar Jan 17 '22 11:01 greenrobot-team

Figure out why property UIDs after newly added one are re-set (or is this just happening for tests?).

This (vs. all UIDs or none changing) is caused by

  • the random seed for generating UIDs being fixed for tests (see generator.Options in test-all.go) and
  • this test not using an initial model file.

Changes are expected then.

Edit: also tested generator manually with initial model file and everything works as expected.

greenrobot-team avatar Jan 24 '22 10:01 greenrobot-team

Edit: Never mind, it's building now.

@greenrobot On macOS the Cmake build fails with

        Undefined symbols for architecture x86_64:
          "NewEntityName::_OBX_MetaInfo::fromFlatBuffer(void const*, unsigned long, NewEntityName&)", referenced from:
              obx::Box<NewEntityName>::get(unsigned long long, NewEntityName&) in step-2.cpp.o
        ld: symbol(s) not found for architecture x86_64
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
        make[4]: *** [TestCpp] Error 1
        make[3]: *** [CMakeFiles/TestCpp.dir/all] Error 2
        make[2]: *** [CMakeFiles/TestCpp.dir/rule] Error 2
        make[1]: *** [TestCpp] Error 2

Does that ring a bell? The signature of the generated code (fromFlatBuffer) and the call from the C library (in ::get) do not appear to have changed between C lib version 14 and 15. There also doesn't appear to be a differentiation for macOS that I can see.

Edit: the generated method has this signature:

void NewEntityName::_OBX_MetaInfo::fromFlatBuffer(const void* data, size_t, NewEntityName& outObject) {

greenrobot-team avatar Jan 24 '22 14:01 greenrobot-team