mzaks / FlatBuffersSwift

This project brings FlatBuffers (an efficient cross platform serialization library) to Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can i resolve reference to Definition??

TonyStark106 opened this issue · comments

ERROR (org.eclipse.xtext.diagnostics.Diagnostic.Linking) 'Couldn't resolve reference to Definition 'Result'.' on Type maxim.zaks.flatBuffers.impl.TypeImpl@6a1ebcff (primType: null, qualifiedType: null), lineNumber 13, length 6

could you please paste your schema, Seems like Result is not defined or is of an unexpected type

I have two fbs files in the same directory.It work by offical flatbuffers flatc -c command.Please forgive my terrible english.thank!

// commData.fbs
include "result.fbs";
namespace com.hyt258.hyt.protocol;
attribute "priority";
table FBData {
dataId: uint;
dataName: string;
}
table FBDataList {
res: Result (required);
DataList: [FBData];
}
root_type FBDataList;

// result.fbs
namespace com.hyt258.hyt.protocol;
attribute "priority";
table Result {
errCode: uint (id:0);
errMsg: string (id:1);
}
root_type Result;

I see couple of things in your fbs files which is not supported yet by this code generator.

  1. include this is why you get the error, currently the code generator analyses only one file. I just added an issue, however I am not sure when I will implement it. #48
  2. namespace there is an issue for that #15 but to be honest I am very close to put it to won't fix, because as we can see it in your example you use nested namespace as it is common in languages like Java, C# and maybe C++, languages which have a namespace/packe feature build in. In Swift there are only modules which can not be nested. I thought about nesting the classes inside of empty enum to emulate a namespace, but it feels ridicules to me. This is why I am close to set this feature to won't implement.
  3. required #10 I want to implement it soon.
  4. id attribute also on my list #9

So if you want to give it FlatBuffersSwift a spin now you would have to merge this two files. As I can see you are not referencing the types by fully qualified name so the namespace is not an issue.

On the side note. This statement:
attribute "priority";
Defines custom attributes which makes sense only if you have a custom code generator as far as I know.

Thank you for your precise answer.