22#define PBL_DEFAULT_PACKAGE_NAME ""
24typedef void(*pbl_report_error_cb_t)(
const char *msg_format, ...);
240pbl_printf(
const char* fmt, ...)
753static inline const char*
const pbl_field_descriptor_t * pbl_message_descriptor_FindFieldByNumber(const pbl_message_descriptor_t *message, int number)
Finds a field descriptor by its number in a message descriptor.
Definition protobuf_lang_tree.c:465
int pbl_field_descriptor_type(const pbl_field_descriptor_t *field)
Get the type of a field descriptor.
Definition protobuf_lang_tree.c:508
uint64_t pbl_field_descriptor_default_value_uint64(const pbl_field_descriptor_t *field)
Retrieves the default value of a field descriptor as a 64-bit unsigned integer.
Definition protobuf_lang_tree.c:640
int pbl_field_descriptor_is_repeated(const pbl_field_descriptor_t *field)
Checks if a field descriptor is repeated.
Definition protobuf_lang_tree.c:529
bool pbl_field_descriptor_default_value_bool(const pbl_field_descriptor_t *field)
Retrieves the default value of a boolean field descriptor.
Definition protobuf_lang_tree.c:661
pbl_node_t * pbl_create_field_node(pbl_file_descriptor_t *file, int lineno, const char *label, const char *type_name, const char *name, int number, pbl_node_t *options)
Create a field node for a Protocol Buffers message.
Definition protobuf_lang_tree.c:892
pbl_node_t * pbl_create_option_node(pbl_file_descriptor_t *file, int lineno, const char *name, const char *value)
Creates a new option node for Protocol Buffers Language Tree.
Definition protobuf_lang_tree.c:998
int run_pbl_parser(pbl_descriptor_pool_t *pool)
Runs the Protocol Buffers Language parser.
pbl_node_t * pbl_create_enum_value_node(pbl_file_descriptor_t *file, int lineno, const char *name, int number)
Create a new enum value node.
Definition protobuf_lang_tree.c:988
const pbl_enum_descriptor_t * pbl_field_descriptor_enum_type(const pbl_field_descriptor_t *field)
Get the enum descriptor for a field.
Definition protobuf_lang_tree.c:593
void pbl_foreach_message(const pbl_descriptor_pool_t *pool, void(*cb)(const pbl_message_descriptor_t *, void *), void *userdata)
Iterates over all message descriptors in a descriptor pool.
Definition protobuf_lang_tree.c:791
bool pbl_field_descriptor_is_required(const pbl_field_descriptor_t *field)
Checks if a field descriptor is required.
Definition protobuf_lang_tree.c:605
const pbl_enum_value_descriptor_t * pbl_enum_descriptor_FindValueByNumber(const pbl_enum_descriptor_t *anEnum, int number)
Finds an enumeration value descriptor by its number.
Definition protobuf_lang_tree.c:725
const char * pbl_message_descriptor_name(const pbl_message_descriptor_t *message)
Retrieves the name of a message descriptor.
Definition protobuf_lang_tree.c:437
const pbl_method_descriptor_t * pbl_message_descriptor_pool_FindMethodByName(const pbl_descriptor_pool_t *pool, const char *name)
Finds a method descriptor by its name in a message descriptor pool.
Definition protobuf_lang_tree.c:391
struct _protobuf_lang_token_t protobuf_lang_token_t
Represents a single lexer token produced while parsing a .proto file.
const char * pbl_field_descriptor_default_value_string(const pbl_field_descriptor_t *field, int *size)
Get the default value string of a Protocol Buffers field descriptor.
Definition protobuf_lang_tree.c:668
const char * pbl_method_descriptor_full_name(const pbl_method_descriptor_t *method)
Retrieves the full name of a method descriptor.
Definition protobuf_lang_tree.c:406
const char * pbl_field_descriptor_name(const pbl_field_descriptor_t *field)
Retrieves the name of a field descriptor.
Definition protobuf_lang_tree.c:494
void pbl_free_pool(pbl_descriptor_pool_t *pool)
Free a descriptor pool and its associated resources.
Definition protobuf_lang_tree.c:129
const pbl_field_descriptor_t * pbl_message_descriptor_FindFieldByName(const pbl_message_descriptor_t *message, const char *name)
Finds a field descriptor by name in a message descriptor.
Definition protobuf_lang_tree.c:476
void pbl_free_node(void *anode)
Frees a protocol buffer language tree node and its children.
Definition protobuf_lang_tree.c:1155
double pbl_field_descriptor_default_value_double(const pbl_field_descriptor_t *field)
Retrieves the default value of a double field descriptor.
Definition protobuf_lang_tree.c:654
const char * pbl_get_node_full_name(pbl_node_t *node)
Get the full name of a node.
Definition protobuf_lang_tree.c:296
const pbl_enum_value_descriptor_t * pbl_enum_descriptor_FindValueByName(const pbl_enum_descriptor_t *anEnum, const char *name)
Finds an enumeration value descriptor by name within a given enumeration descriptor.
Definition protobuf_lang_tree.c:736
const char * pbl_field_descriptor_full_name(const pbl_field_descriptor_t *field)
Retrieves the full name of a field descriptor.
Definition protobuf_lang_tree.c:487
pbl_node_t * pbl_create_node(pbl_file_descriptor_t *file, int lineno, pbl_node_type_t nodetype, const char *name)
Creates a new node in the Protocol Buffers language tree.
Definition protobuf_lang_tree.c:817
pbl_node_t * pbl_create_method_node(pbl_file_descriptor_t *file, int lineno, const char *name, const char *in_msg_type, bool in_is_stream, const char *out_msg_type, bool out_is_stream)
Create a method node for Protocol Buffers.
Definition protobuf_lang_tree.c:863
int pbl_message_descriptor_field_count(const pbl_message_descriptor_t *message)
Get the count of fields in a message descriptor.
Definition protobuf_lang_tree.c:451
uint32_t pbl_field_descriptor_default_value_uint32(const pbl_field_descriptor_t *field)
Retrieves the default value of a field descriptor as a uint32.
Definition protobuf_lang_tree.c:633
int pbl_enum_value_descriptor_number(const pbl_enum_value_descriptor_t *enumValue)
Retrieves the number associated with an enum value descriptor.
Definition protobuf_lang_tree.c:761
const char * pbl_enum_value_descriptor_full_name(const pbl_enum_value_descriptor_t *enumValue)
Get the full name of an enum value descriptor.
Definition protobuf_lang_tree.c:754
void pbl_reinit_descriptor_pool(pbl_descriptor_pool_t **ppool, const char **directories, pbl_report_error_cb_t error_cb)
Reinitialize the protocol buffers pool according to proto files directories.
Definition protobuf_lang_tree.c:107
const char * pbl_method_descriptor_name(const pbl_method_descriptor_t *method)
Retrieves the name of a method descriptor.
Definition protobuf_lang_tree.c:399
int64_t pbl_field_descriptor_default_value_int64(const pbl_field_descriptor_t *field)
Retrieves the default value of a field descriptor as an int64.
Definition protobuf_lang_tree.c:626
const pbl_enum_value_descriptor_t * pbl_enum_descriptor_value(const pbl_enum_descriptor_t *anEnum, int value_index)
Retrieves an enum value descriptor by its index.
Definition protobuf_lang_tree.c:718
pbl_node_t * pbl_merge_children(pbl_node_t *to, pbl_node_t *from)
Merges children from one node to another.
Definition protobuf_lang_tree.c:1104
bool pbl_field_descriptor_has_default_value(const pbl_field_descriptor_t *field)
Checks if a field descriptor has a default value.
Definition protobuf_lang_tree.c:612
const pbl_field_descriptor_t * pbl_message_descriptor_field(const pbl_message_descriptor_t *message, int field_index)
Retrieves a field descriptor from a message descriptor by index.
Definition protobuf_lang_tree.c:458
const char * pbl_field_descriptor_TypeName(wmem_allocator_t *scope, int field_type)
Retrieves the type name for a given field type.
Definition protobuf_lang_tree.c:574
pbl_node_t * pbl_set_node_name(pbl_node_t *node, int lineno, const char *newname)
Set the name of a node.
Definition protobuf_lang_tree.c:842
const char * pbl_message_descriptor_full_name(const pbl_message_descriptor_t *message)
Retrieves the full name of a message descriptor.
Definition protobuf_lang_tree.c:444
struct _protobuf_lang_state_t protobuf_lang_state_t
Holds the full mutable state of the protobuf language parser across a single parse run.
const pbl_message_descriptor_t * pbl_message_descriptor_pool_FindMessageTypeByName(const pbl_descriptor_pool_t *pool, const char *name)
Finds a message descriptor by its name in a descriptor pool.
Definition protobuf_lang_tree.c:429
const char * pbl_enum_descriptor_name(const pbl_enum_descriptor_t *anEnum)
Get the name of an enum descriptor.
Definition protobuf_lang_tree.c:697
const char * pbl_enum_value_descriptor_name(const pbl_enum_value_descriptor_t *enumValue)
Retrieves the name of an enum value descriptor.
Definition protobuf_lang_tree.c:747
int pbl_enum_descriptor_value_count(const pbl_enum_descriptor_t *anEnum)
Get the count of values in an enum descriptor.
Definition protobuf_lang_tree.c:711
const pbl_enum_value_descriptor_t * pbl_field_descriptor_default_value_enum(const pbl_field_descriptor_t *field)
Retrieves the default value enum for a field descriptor.
Definition protobuf_lang_tree.c:676
pbl_node_t * pbl_add_child(pbl_node_t *parent, pbl_node_t *child)
Adds a child node to a parent node.
Definition protobuf_lang_tree.c:1012
int pbl_field_descriptor_number(const pbl_field_descriptor_t *field)
Retrieves the number associated with a field descriptor.
Definition protobuf_lang_tree.c:501
const pbl_message_descriptor_t * pbl_method_descriptor_output_type(const pbl_method_descriptor_t *method)
Retrieves the output type of a method descriptor.
Definition protobuf_lang_tree.c:421
const pbl_message_descriptor_t * pbl_method_descriptor_input_type(const pbl_method_descriptor_t *method)
Retrieves the input message descriptor type for a method.
Definition protobuf_lang_tree.c:413
const char * pbl_enum_descriptor_full_name(const pbl_enum_descriptor_t *anEnum)
Get the full name of an enum descriptor.
Definition protobuf_lang_tree.c:704
bool pbl_add_proto_file_to_be_parsed(pbl_descriptor_pool_t *pool, const char *filepath)
Adds a Protocol Buffers file to be parsed.
Definition protobuf_lang_tree.c:185
pbl_node_t * pbl_create_map_field_node(pbl_file_descriptor_t *file, int lineno, const char *name, int number, pbl_node_t *options)
Create a map field node in the Protocol Buffers language tree.
Definition protobuf_lang_tree.c:971
pbl_node_type_t
Node types in the Protocol Buffers language (proto2/proto3) parse tree.
Definition protobuf_lang_tree.h:29
@ PBL_SERVICE
Definition protobuf_lang_tree.h:38
@ PBL_MAP_FIELD
Definition protobuf_lang_tree.h:35
@ PBL_UNKNOWN
Definition protobuf_lang_tree.h:30
@ PBL_MESSAGE
Definition protobuf_lang_tree.h:32
@ PBL_PACKAGE
Definition protobuf_lang_tree.h:31
@ PBL_OPTIONS
Definition protobuf_lang_tree.h:40
@ PBL_METHOD
Definition protobuf_lang_tree.h:39
@ PBL_FIELD
Definition protobuf_lang_tree.h:33
@ PBL_OPTION
Definition protobuf_lang_tree.h:41
@ PBL_ENUM
Definition protobuf_lang_tree.h:36
@ PBL_ONEOF
Definition protobuf_lang_tree.h:34
@ PBL_ENUM_VALUE
Definition protobuf_lang_tree.h:37
const pbl_message_descriptor_t * pbl_field_descriptor_message_type(const pbl_field_descriptor_t *field)
Retrieves the message type descriptor for a field.
Definition protobuf_lang_tree.c:581
float pbl_field_descriptor_default_value_float(const pbl_field_descriptor_t *field)
Retrieves the default value of a float field descriptor.
Definition protobuf_lang_tree.c:647
int32_t pbl_field_descriptor_default_value_int32(const pbl_field_descriptor_t *field)
Retrieves the default value for an int32 field descriptor.
Definition protobuf_lang_tree.c:619
int pbl_field_descriptor_is_packed(const pbl_field_descriptor_t *field)
Checks if a field descriptor is packed.
Definition protobuf_lang_tree.c:536
Holds the full mutable state of the protobuf language parser across a single parse run.
Definition protobuf_lang_tree.h:186
pbl_file_descriptor_t * file
Definition protobuf_lang_tree.h:188
void * pParser
Definition protobuf_lang_tree.h:192
void * scanner
Definition protobuf_lang_tree.h:191
GSList * lex_string_tokens
Definition protobuf_lang_tree.h:189
bool grammar_error
Definition protobuf_lang_tree.h:193
pbl_descriptor_pool_t * pool
Definition protobuf_lang_tree.h:187
GSList * lex_struct_tokens
Definition protobuf_lang_tree.h:190
protobuf_lang_token_t * tmp_token
Definition protobuf_lang_tree.h:194
Represents a single lexer token produced while parsing a .proto file.
Definition protobuf_lang_tree.h:178
int ln
Definition protobuf_lang_tree.h:180
char * v
Definition protobuf_lang_tree.h:179
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
Central descriptor pool for all parsed .proto files; analogous to google::protobuf::DescriptorPool in...
Definition protobuf_lang_tree.h:49
GQueue * source_paths
Definition protobuf_lang_tree.h:50
struct _protobuf_lang_state_t * parser_state
Definition protobuf_lang_tree.h:55
GHashTable * proto_files
Definition protobuf_lang_tree.h:53
GQueue * proto_files_to_be_parsed
Definition protobuf_lang_tree.h:54
GHashTable * packages
Definition protobuf_lang_tree.h:52
pbl_report_error_cb_t error_cb
Definition protobuf_lang_tree.h:51
Describes a protobuf enum type, analogous to google::protobuf::EnumDescriptor in the C++ protobuf lib...
Definition protobuf_lang_tree.h:159
pbl_node_t basic_info
Definition protobuf_lang_tree.h:160
GQueue * values
Definition protobuf_lang_tree.h:161
GHashTable * values_by_number
Definition protobuf_lang_tree.h:162
Descriptor for a single enum value; analogous to google::protobuf::EnumValueDescriptor in the protobu...
Definition protobuf_lang_tree.h:114
int number
Definition protobuf_lang_tree.h:116
pbl_node_t basic_info
Definition protobuf_lang_tree.h:115
Describes a field in a Protocol Buffer message, similar to google::protobuf::FieldDescriptor.
Definition protobuf_lang_tree.h:125
bool has_default_value
Definition protobuf_lang_tree.h:134
pbl_node_t * options_node
Definition protobuf_lang_tree.h:130
pbl_node_t basic_info
Definition protobuf_lang_tree.h:126
double d
Definition protobuf_lang_tree.h:149
int64_t i64
Definition protobuf_lang_tree.h:145
bool b
Definition protobuf_lang_tree.h:150
char * type_name
Definition protobuf_lang_tree.h:129
uint64_t u64
Definition protobuf_lang_tree.h:147
int type
Definition protobuf_lang_tree.h:128
float f
Definition protobuf_lang_tree.h:148
char * s
Definition protobuf_lang_tree.h:151
char * orig_default_value
Definition protobuf_lang_tree.h:135
int32_t i32
Definition protobuf_lang_tree.h:144
bool is_required
Definition protobuf_lang_tree.h:133
const pbl_enum_value_descriptor_t * e
Definition protobuf_lang_tree.h:152
int string_or_bytes_default_value_length
Definition protobuf_lang_tree.h:136
bool is_repeated
Definition protobuf_lang_tree.h:132
int number
Definition protobuf_lang_tree.h:127
uint32_t u32
Definition protobuf_lang_tree.h:146
Descriptor for a single parsed .proto source file.
Definition protobuf_lang_tree.h:62
int syntax_version
Definition protobuf_lang_tree.h:64
int package_name_lineno
Definition protobuf_lang_tree.h:66
const char * package_name
Definition protobuf_lang_tree.h:65
pbl_descriptor_pool_t * pool
Definition protobuf_lang_tree.h:67
const char * filename
Definition protobuf_lang_tree.h:63
Descriptor for a message type definition; analogous to google::protobuf::Descriptor in the protobuf C...
Definition protobuf_lang_tree.h:103
GQueue * fields
Definition protobuf_lang_tree.h:105
pbl_node_t basic_info
Definition protobuf_lang_tree.h:104
GHashTable * fields_by_number
Definition protobuf_lang_tree.h:106
Descriptor for a single RPC or stream method within a service definition; analogous to google::protob...
Definition protobuf_lang_tree.h:90
bool in_is_stream
Definition protobuf_lang_tree.h:93
pbl_node_t basic_info
Definition protobuf_lang_tree.h:91
char * in_msg_type
Definition protobuf_lang_tree.h:92
char * out_msg_type
Definition protobuf_lang_tree.h:94
bool out_is_stream
Definition protobuf_lang_tree.h:95
Base node carrying identity and tree linkage for every parse tree element.
Definition protobuf_lang_tree.h:74
pbl_node_type_t nodetype
Definition protobuf_lang_tree.h:75
GHashTable * children_by_name
Definition protobuf_lang_tree.h:80
struct pbl_node_t * parent
Definition protobuf_lang_tree.h:78
int lineno
Definition protobuf_lang_tree.h:82
char * full_name
Definition protobuf_lang_tree.h:77
pbl_file_descriptor_t * file
Definition protobuf_lang_tree.h:81
char * name
Definition protobuf_lang_tree.h:76
GQueue * children
Definition protobuf_lang_tree.h:79
Describes a single protobuf option; the name of the option is stored in basic_info.
Definition protobuf_lang_tree.h:170
pbl_node_t basic_info
Definition protobuf_lang_tree.h:171
char * value
Definition protobuf_lang_tree.h:172