flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

The converted structure is lost with python.

Open kuozhijishou opened this issue 2 years ago • 4 comments

version:

windows release flatc version 2.0.0

for Common.Tile.ids:

in the fbs's definition, "Common.Tile.ids" == "Common.Slice". All other programming languages can be found in "Common.Tile.ids" "Common.Slice". but Python can not, I just found out that “obj”, what it brings is a mistake. Only Python faced this mistake, and I have no way to use it with python now .

fbs:
namespace Common;

struct Slice {
    index:uint32;
    size:uint32;
}

struct Tile {
    x:int32;
    y:int32;
    ids:Slice;
}
python: (flatc.exe -p **.fbs)
def Ids(self, obj):
    obj.Init(self._tab.Bytes, self._tab.Pos + 8)
    return obj
cpp
const Common::Slice &ids() const {
    return ids_;
}
java
public Common.Slice ids() { return ids(new Common.Slice()); }
public Common.Slice ids(Common.Slice obj) { return obj.__assign(bb_pos + 8, bb); }
go
func (rcv *Tile) Ids(obj *Slice) *Slice {
    if obj == nil {
        obj = new(Slice)
    }
    obj.Init(rcv._tab.Bytes, rcv._tab.Pos+8)
    return obj
}

kuozhijishou avatar May 26 '22 09:05 kuozhijishou

What do you mean by "the converted structure is lost"?

CasperN avatar May 26 '22 16:05 CasperN

Sorry, I may have a grammar problem using Google Translate.

in the fbs's definition, "Common.Tile.ids" == "Common.Slice". All other programming languages can be found in "Common.Tile.ids" "Common.Slice". but Python can not, I just found out that “obj”, what it brings is a mistake.

What do you mean by "the converted structure is lost"?

kuozhijishou avatar May 27 '22 01:05 kuozhijishou

Are you trying to say that the obj name in the following generated code should be named slice?

def Ids(self, obj):
    obj.Init(self._tab.Bytes, self._tab.Pos + 8)
    return obj

dbaileychess avatar Jun 15 '22 04:06 dbaileychess

Are you trying to say that the obj name in the following generated code should be named slice?

def Ids(self, obj):
    obj.Init(self._tab.Bytes, self._tab.Pos + 8)
    return obj

Yes, this should be Slice, theoretically.

kuozhijishou avatar Jun 15 '22 06:06 kuozhijishou

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

github-actions[bot] avatar Mar 04 '23 01:03 github-actions[bot]

This issue was automatically closed due to no activity for 6 months plus the 14 day notice period.

github-actions[bot] avatar Mar 18 '23 20:03 github-actions[bot]