lib-ruby-parser-bindings 0.13.0

Tools to generate bindings for lib-ruby-parser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::options;
use lib_ruby_parser_nodes::{MessageField, MessageFieldType};

/// Returns name of the message field that is compatible with C
pub fn field_name(field: &MessageField) -> &str {
    match &field.snakecase_name[..] {
        "operator" => "operator_",
        other => other,
    }
}

/// Returns type of the message field according to `options` configured by you
pub fn field_type(field: &MessageField) -> &'static str {
    match field.field_type {
        MessageFieldType::Str => options().string_ptr_blob_name,
        MessageFieldType::Byte => options().byte_blob_name,
    }
}