Bug 1553482 - Generating BINAST_TOTAL_NUMBER_OF_FIELDS, BINAST_NUMBER_OF_LIST_TYPES;r=arai

Differential Revision: https://phabricator.services.mozilla.com/D32289

--HG--
extra : moz-landing-system : lando
This commit is contained in:
David Teller 2019-05-24 09:08:54 +00:00
Родитель 0b6cbb257b
Коммит 14632329cc
2 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -289,6 +289,10 @@ enum class BinASTField : uint16_t {
// The number of distinct values of BinASTField.
const size_t BINASTFIELD_LIMIT = 69;
// The total number of fields across all interfaces. Used typically to maintain
// a probability table per field.
const size_t BINAST_TOTAL_NUMBER_OF_FIELDS = 275;
/**
* The different variants of Binary AST string enums, as per
* the specifications of Binary AST, as a single macro and
@ -365,6 +369,10 @@ enum class BinASTVariant : uint16_t {
// The number of distinct values of BinASTVariant.
const size_t BINASTVARIANT_LIMIT = 49;
// The total number of lists across all interfaces. Used typically to maintain a
// probability table per field.
const size_t BINAST_TOTAL_NUMBER_OF_LISTS = 22;
/**
* Return a string describing a `BinASTKind`.
*/

Просмотреть файл

@ -994,7 +994,13 @@ enum class BinASTField: uint16_t {
#undef EMIT_ENUM
};
");
buffer.push_str(&format!("\n// The number of distinct values of BinASTField.\nconst size_t BINASTFIELD_LIMIT = {};\n\n\n", field_limit));
buffer.push_str(&format!("\n// The number of distinct values of BinASTField.\nconst size_t BINASTFIELD_LIMIT = {};\n", field_limit));
let total_number_of_fields: usize = self.syntax.interfaces_by_name()
.values()
.map(|interface| interface.contents().fields().len())
.sum();
buffer.push_str(&format!("\n// The total number of fields across all interfaces. Used typically to maintain a probability table per field.\nconst size_t BINAST_TOTAL_NUMBER_OF_FIELDS = {};\n\n\n", total_number_of_fields));
if self.rules.hpp_tokens_variants_doc.is_some() {
buffer.push_str(&self.rules.hpp_tokens_variants_doc.reindent(""));
@ -1024,6 +1030,8 @@ enum class BinASTVariant: uint16_t {
buffer.push_str(&format!("\n// The number of distinct values of BinASTVariant.\nconst size_t BINASTVARIANT_LIMIT = {};\n\n\n",
variants_limit));
buffer.push_str(&format!("\n// The total number of lists across all interfaces. Used typically to maintain a probability table per field.\nconst size_t BINAST_TOTAL_NUMBER_OF_LISTS = {};\n\n\n", self.list_parsers_to_generate.len()));
buffer.push_str(&self.rules.hpp_tokens_footer.reindent(""));
buffer.push_str("\n");
}