wvxvw / protopy

Protobuf parser for Python
GNU Lesser General Public License v3.0
8 stars 3 forks source link

Be proactive in parser #3

Open wvxvw opened 6 years ago

wvxvw commented 6 years ago

Right now, the parse generated while reading the Proto file needs a lot of manipulations before it is possible to generate descriptors from it. A lot of that work can actually happen in the parser, potentially speeding up the process. In particular:

  1. Normalize names of inner messages.
  2. Extract oneof fields into parent message.
  3. Extract inner messages into a flat list.
  4. Define proto_file_t struct which provides easy access to the entities in the Proto file, something along the lines of:
    typedef struct proto_file_t {
    char* package;
    list_t* imports;
    list_t* enums;
    list_t* messages;
    } proto_file_t;
wvxvw commented 6 years ago

Most of this is done, but now it seems like there's a lot of duplication between types defined in helpers.h and in descriptors.h, in particular factory_t and field_info_t. Need to revisit this.