Hi there,
I would like to share the proto compiler I developed and get some feedback on it as well.
The compiler's code is located https://github.com/AmirAavani/PB2PAS. The generated code(units) uses the units in
https://github.com/AmirAavani/my-units/tree/master/PB2PAS. I attached two proto files and the generated unit files as well (Please see the ReadME file in the repo for more information).
The proto compiler works with proto3
syntax(https://developers.google.com/protocol-buffers/docs/proto3). Right now, it does not support "bytes" (one could use string instead). Also, it does not support "service" as well (WIP).
It would be great if you could go through the output/code and let me know what you think (or if you have any comments). I have some specific questions:
1) For Repeated Fields, the message class will have the following three properties:
constFieldName, MutableFeildName, and FieldName[Index: Integer].
Their definition looks like this:
property ConstFieldName: TFieldName read FFieldName;
property MutableFieldName: TFieldName read GetOrCreate write FFiledName;
property FieldName[Index: Integer]: TFieldName read GetFiledName;Is there a better way to handle this. Specifically is there anyway to disable MsgObj.ConstFieldName.Add(...)?
2) A similar question about Getters for Non-simple fields (Fields that are messages, OneOf, etc). The code generates the following properties, per this kind of fields:
property FieldName: TFieldName read FFieldName write FFieldName; property MutableFieldName: TFieldName read GetOrCreateFieldName;
Should I drop "write FFieldName" from the property FieldName?
3) I do not have a good answer for this one: Should the the items in a Map/List be freed in the class destructor?
In the current implementation, the destructor frees the Maps/Lists and all their members. The issue is uncommenting line 178 of Main.pp (attached) would cause a segfault. I had a couple of ideas about how to handle this, but none of them is perfect. Wondering what you think?
Regards,
Amir
