Blender V5.3
dna_parse.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 * SPDX-FileCopyrightText: 2002-2026 Blender Authors
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later */
5
15
16#include "dna_parse.h"
17
18#include <cctype>
19#include <cstdio>
20#include <cstring>
21#include <fstream>
22
23#include "BLI_map.hh"
26#include "BLI_string_ref.hh"
27#include "BLI_utildefines.hh"
28
29#include "dna_utils.h"
30
31namespace blender {
32
33int debugSDNA = 0;
34
35namespace dna {
36
37#define DEBUG_PRINTF(debug_level, ...) \
38 { \
39 if (debugSDNA > debug_level) { \
40 printf(__VA_ARGS__); \
41 } \
42 } \
43 ((void)0)
44
45/* -------------------------------------------------------------------- */
48
50{
51 static const char *files[] = {
52#include "dna_includes_as_strings.h"
53 };
54 return Span<const char *>(files, ARRAY_SIZE(files));
55}
56
57[[nodiscard]] static bool read_file_data(const StringRefNull filepath, Vector<char> &data)
58{
59 std::ifstream file(filepath, std::ios::binary | std::ios::ate);
60 if (!file) {
61 return false;
62 }
63 const std::streamsize size = file.tellg();
64 if (size < 0) {
65 return false;
66 }
67 file.seekg(0, std::ios::beg);
68 data.resize(size);
69 return file.read(data.data(), size) ? true : false;
70}
71
73
74/* -------------------------------------------------------------------- */
77
78/* Token kind is either an identifier or number, or an ascii character. */
79using TokenKind = int;
81constexpr TokenKind TOKEN_NUMBER = 257;
82constexpr TokenKind TOKEN_END = 258;
83
88
90 Vector<Token> tokens_;
91 int64_t pos_ = 0;
92
93 public:
94 void append(Token &&token)
95 {
96 tokens_.append(std::move(token));
97 }
98
99 bool at_end() const
100 {
101 return pos_ >= tokens_.size();
102 }
103
104 TokenKind kind(int64_t offset = 0) const
105 {
106 return (pos_ + offset < tokens_.size()) ? tokens_[pos_ + offset].kind : TOKEN_END;
107 }
108
109 const Token &peek(int64_t offset = 0) const
110 {
111 return tokens_[pos_ + offset];
112 }
113
114 const Token &consume()
115 {
116 return tokens_[pos_++];
117 }
118
119 void advance()
120 {
121 pos_++;
122 }
123
125 {
126 if (this->kind() == k) {
127 pos_++;
128 return true;
129 }
130 return false;
131 }
132
134 {
135 if (this->kind() == TOKEN_IDENTIFIER && this->peek().text == kw) {
136 pos_++;
137 return true;
138 }
139 return false;
140 }
141
143 {
144 int64_t n = 0;
145
146 while (!expr.is_empty()) {
147 if (this->kind(n) == TOKEN_END) {
148 return false;
149 }
150
151 if (expr[0] == ' ') {
152 expr = expr.drop_prefix(1);
153 continue;
154 }
155
156 const StringRef text = this->peek(n).text;
157 if (!expr.startswith(text)) {
158 return false;
159 }
160 expr = expr.drop_prefix(text.size());
161 n++;
162 }
163
164 pos_ += n;
165 return true;
166 }
167};
168
170
171/* -------------------------------------------------------------------- */
174
175static bool is_identifier_start(char c)
176{
177 return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
178}
179
180static bool is_identifier_continuation(char c)
181{
182 return is_identifier_start(c) || (c >= '0' && c <= '9');
183}
184
190{
191 TokenStream stream;
192 const char *cur = source.begin();
193 const char *end = source.end();
194
195 while (cur < end) {
196 const char c = *cur;
197
198 /* White-space. */
199 if (ELEM(c, ' ', '\t', '\n', '\r')) {
200 cur++;
201 continue;
202 }
203
204 /* Discard C++ style comment. */
205 if (c == '/' && cur + 1 < end && cur[1] == '/') {
206 cur += 2;
207 while (cur < end && *cur != '\n') {
208 cur++;
209 }
210 continue;
211 }
212
213 /* Discard C style comment. */
214 if (c == '/' && cur + 1 < end && cur[1] == '*') {
215 cur += 2;
216 while (cur + 1 < end && !(cur[0] == '*' && cur[1] == '/')) {
217 cur++;
218 }
219 if (cur + 1 < end) {
220 cur += 2;
221 }
222 continue;
223 }
224
225 /* Discard string literal. */
226 if (c == '"') {
227 cur++;
228 while (cur < end && *cur != '"') {
229 if (*cur == '\\' && cur + 1 < end) {
230 cur++;
231 }
232 cur++;
233 }
234 if (cur < end) {
235 cur++;
236 }
237 continue;
238 }
239
240 /* Add identifier, :: scope separators are considered part of it. */
241 if (is_identifier_start(c)) {
242 const char *begin = cur;
243 while (cur < end && is_identifier_continuation(*cur)) {
244 cur++;
245 }
246 while (cur + 1 < end && cur[0] == ':' && cur[1] == ':') {
247 cur += 2;
248 while (cur < end && is_identifier_continuation(*cur)) {
249 cur++;
250 }
251 }
252 StringRef text(begin, cur - begin);
253 stream.append({TOKEN_IDENTIFIER, text});
254 continue;
255 }
256
257 /* Number. */
258 if (c >= '0' && c <= '9') {
259 const char *begin = cur;
260 while (cur < end && *cur >= '0' && *cur <= '9') {
261 cur++;
262 }
263 stream.append({TOKEN_NUMBER, StringRef(begin, cur - begin)});
264 continue;
265 }
266
267 /* Add anything else as a single character token. */
268 stream.append({c, StringRef(cur, 1)});
269 cur++;
270 }
271
272 return stream;
273}
274
277{
278 TokenStream stripped_stream;
279 while (!stream.at_end()) {
280 /* Skip blocks with C++ code that we can't parse. */
281 if (stream.consume_expression("#ifdef __cplusplus") ||
282 stream.consume_expression("#if defined(__cplusplus)"))
283 {
284 while (!stream.at_end() && !stream.consume_expression("#endif")) {
285 stream.advance();
286 }
287 continue;
288 }
289 /* Skip DNA macros that we don't need to parse. */
290 if (stream.consume_keyword("DNA_DEPRECATED")) {
291 continue;
292 }
293 if (stream.consume_keyword("DNA_DEFINE_CXX_METHODS")) {
294 while (!stream.at_end() && stream.kind() != ')') {
295 stream.advance();
296 }
297 if (!stream.at_end()) {
298 stream.advance();
299 }
300 continue;
301 }
302 stripped_stream.append(Token{stream.consume()});
303 }
304 return stripped_stream;
305}
306
308
309/* -------------------------------------------------------------------- */
312
314static bool is_valid_type_name(const StringRefNull type_name, const StringRefNull filepath)
315{
316 if (type_name.is_empty()) {
317 fprintf(stderr,
318 "File '%s' contains struct we can't parse \"%s\"\n",
319 filepath.c_str(),
320 type_name.c_str());
321 return false;
322 }
323 if (ELEM(type_name, "long", "ulong")) {
324 fprintf(stderr,
325 "File '%s' contains use of \"%s\" in DNA struct which is not allowed\n",
326 filepath.c_str(),
327 type_name.c_str());
328 return false;
329 }
330 return true;
331}
332
334static bool is_valid_member_name(const StringRefNull name, const StringRefNull filepath)
335{
336 /* Strip pointer/array decorators: e.g. `*var[3]` -> `var`. */
337 const StringRef name_strip = DNA_member_id_string_ref(name);
338
339 /* Enforce '_pad123' naming convention, disallow 'pad123' or 'pad_123',
340 * special exception for [a-z] after since there is a 'pad_rot_angle' preference. */
341 if (!name_strip.is_empty() && name_strip[0] == '_' && !name_strip.startswith("_pad")) {
342 fprintf(stderr,
343 "File '%s': only '_pad' variables can start with an underscore, found '%s'\n",
344 filepath.c_str(),
345 name.c_str());
346 return false;
347 }
348
349 if (name_strip.startswith("pad")) {
350 const StringRef rest = name_strip.drop_prefix(3);
351 if (!rest.is_empty() && rest[0] >= 'a' && rest[0] <= 'z') {
352 /* May be part of a word, allow that. */
353 return true;
354 }
355 bool has_only_digit_or_none = true;
356 for (char c : rest) {
357 if (!((c >= '0' && c <= '9') || c == '_')) {
358 has_only_digit_or_none = false;
359 break;
360 }
361 }
362 if (has_only_digit_or_none) {
363 fprintf(stderr,
364 "File '%s': padding variables must be formatted '_pad[number]', found '%s'\n",
365 filepath.c_str(),
366 name.c_str());
367 return false;
368 }
369 }
370
371 return true;
372}
373
375
376/* -------------------------------------------------------------------- */
379
381static void skip_balanced(TokenStream &stream, TokenKind open, TokenKind close)
382{
383 stream.advance();
384 int depth = 1;
385 while (!stream.at_end() && depth > 0) {
386 const TokenKind k = stream.consume().kind;
387 if (k == open) {
388 depth++;
389 }
390 else if (k == close) {
391 depth--;
392 }
393 }
394}
395
397static void skip_initializer(TokenStream &stream)
398{
399 int depth = 0;
400 while (!stream.at_end()) {
401 const TokenKind k = stream.kind();
402 if (depth == 0 && ELEM(k, ',', ';')) {
403 return;
404 }
405 if (k == '{' || k == '(') {
406 depth++;
407 }
408 else if (k == '}' || k == ')') {
409 depth--;
410 }
411 stream.advance();
412 }
413}
414
416static void append_array_suffix(TokenStream &stream, std::string &out)
417{
418 while (!stream.at_end() && stream.kind() == '[') {
419 out += '[';
420 stream.advance();
421 int depth = 1;
422 while (!stream.at_end() && depth > 0) {
423 const Token &t = stream.consume();
424 out += t.text;
425 if (t.kind == '[') {
426 depth++;
427 }
428 else if (t.kind == ']') {
429 depth--;
430 }
431 }
432 }
433}
434
436static void append_template_suffix(TokenStream &stream, std::string &out)
437{
438 if (!stream.consume('<')) {
439 return;
440 }
441 out += '<';
442 int depth = 1;
443 while (!stream.at_end() && depth > 0) {
444 const Token &t = stream.consume();
445 out += t.text;
446 if (t.kind == '<') {
447 depth++;
448 }
449 else if (t.kind == '>') {
450 depth--;
451 }
452 }
453}
454
460[[nodiscard]] static bool parse_paren_declaration(TokenStream &stream, std::string &out)
461{
462 stream.advance();
463 out += '(';
464 while (stream.consume('*')) {
465 out += '*';
466 }
467 if (stream.at_end() || stream.kind() != TOKEN_IDENTIFIER) {
468 return false;
469 }
470 out += stream.consume().text;
471 if (!stream.consume(')')) {
472 return false;
473 }
474 out += ')';
475
476 if (!stream.at_end() && stream.kind() == '(') {
477 skip_balanced(stream, '(', ')');
478 }
479 else {
480 while (!stream.at_end() && stream.kind() == '[') {
481 skip_balanced(stream, '[', ']');
482 }
483 }
484 out += "()";
485 return true;
486}
487
489[[nodiscard]] static bool parse_member_declaration(TokenStream &stream, std::string &out)
490{
491 out.clear();
492
493 /* Pointer prefixes. */
494 while (stream.consume('*')) {
495 out += '*';
496 }
497
498 /* Function pointer or multi-dimensional array pointer: `(*name)...` */
499 if (!stream.at_end() && stream.kind() == '(') {
500 return parse_paren_declaration(stream, out);
501 }
502
503 /* Plain identifier with potential array suffixes. */
504 if (stream.at_end() || stream.kind() != TOKEN_IDENTIFIER) {
505 return false;
506 }
507 out += stream.consume().text;
508 append_array_suffix(stream, out);
509 return true;
510}
511
513[[nodiscard]] static bool parse_struct_body(TokenStream &stream,
514 const StringRefNull filepath,
515 ParsedStruct &r_struct)
516{
517 while (!stream.at_end() && stream.kind() != '}') {
518 /* Skip qualifiers. */
519 while (stream.consume_keyword("struct") || stream.consume_keyword("unsigned") ||
520 stream.consume_keyword("const"))
521 {
522 }
523
524 if (stream.at_end() || stream.kind() != TOKEN_IDENTIFIER) {
525 fprintf(stderr,
526 "File '%s' contains a member declaration that can't be parsed\n",
527 filepath.c_str());
528 return false;
529 }
530
531 /* Consume the identifier and any template arguments (e.g. `ListBaseT<Foo>`)
532 * into the type name. `substitute_cpp_types` later rewrites templated type
533 * names into their canonical SDNA form. */
534 std::string type_name(stream.consume().text);
535 append_template_suffix(stream, type_name);
536 if (!is_valid_type_name(type_name, filepath)) {
537 return false;
538 }
539
540 DEBUG_PRINTF(1, "\t|\t|\tfound type %s (", type_name.c_str());
541
542 /* Comma-separated declarations terminated by `;`. */
543 while (true) {
544 std::string member_name;
545 if (!parse_member_declaration(stream, member_name)) {
546 fprintf(stderr,
547 "File '%s' contains a member declaration that can't be parsed\n",
548 filepath.c_str());
549 return false;
550 }
551 if (!is_valid_member_name(member_name, filepath)) {
552 return false;
553 }
554
555 DEBUG_PRINTF(1, "%s ||", member_name.c_str());
556
557 r_struct.members.append({.type_name = type_name, .member_name = member_name});
558
559 if (stream.consume('=')) {
560 skip_initializer(stream);
561 }
562 if (stream.consume(';')) {
563 break;
564 }
565 if (!stream.consume(',')) {
566 fprintf(stderr,
567 "File '%s' contains a member declaration that can't be parsed\n",
568 filepath.c_str());
569 return false;
570 }
571 }
572
573 DEBUG_PRINTF(1, ")\n");
574 }
575 if (!stream.consume('}')) {
576 fprintf(stderr, "File '%s' contains a struct without a closing brace\n", filepath.c_str());
577 return false;
578 }
579 return true;
580}
581
583static void skip_struct_body(TokenStream &stream)
584{
585 int depth = 1;
586 while (!stream.at_end() && depth > 0) {
587 const TokenKind k = stream.consume().kind;
588 if (k == '{') {
589 depth++;
590 }
591 else if (k == '}') {
592 depth--;
593 }
594 }
595}
596
598[[nodiscard]] static bool parse_enum_declaration(TokenStream &stream,
599 const StringRefNull filepath,
600 Vector<ParsedEnum> &r_enums)
601{
602 stream.consume_keyword("class");
603 stream.consume_keyword("struct");
604
605 std::string name;
606 if (!stream.at_end() && stream.kind() == TOKEN_IDENTIFIER) {
607 name = stream.consume().text;
608 }
609
610 std::string underlying_type;
611 if (stream.consume(':')) {
612 if (stream.at_end() || stream.kind() != TOKEN_IDENTIFIER) {
613 fprintf(stderr,
614 "File '%s' contains enum '%s' with unparseable underlying type\n",
615 filepath.c_str(),
616 name.c_str());
617 return false;
618 }
619 underlying_type = stream.consume().text;
620 }
621
622 if (!stream.consume(';')) {
623 if (stream.at_end() || stream.kind() != '{') {
624 return true;
625 }
626 skip_balanced(stream, '{', '}');
627 }
628
629 if (!name.empty()) {
630 r_enums.append({.type_name = std::move(name), .underlying_type = std::move(underlying_type)});
631 }
632
633 return true;
634}
635
636static bool parse_dna_header(const StringRefNull filepath,
637 Vector<ParsedStruct> &r_structs,
638 Vector<ParsedEnum> &r_enums)
639{
640 Vector<char> buffer;
641 if (!read_file_data(filepath, buffer)) {
642 fprintf(stderr, "Can't read file %s\n", filepath.c_str());
643 return false;
644 }
645
646 TokenStream stream = tokenize_dna_header(StringRef(buffer.data(), buffer.size()));
647 stream = strip_ignored_tokens(stream);
648
649 bool skip_next_struct = false;
650
651 while (!stream.at_end()) {
652 /* `# #` markers in the source flag the next struct definition to be skipped. */
653 if (stream.kind() == '#' && stream.kind(1) == '#') {
654 stream.advance();
655 stream.advance();
656 skip_next_struct = true;
657 continue;
658 }
659
660 if (stream.consume_keyword("enum")) {
661 if (!parse_enum_declaration(stream, filepath, r_enums)) {
662 return false;
663 }
664 continue;
665 }
666
667 if (!stream.consume_keyword("struct")) {
668 stream.advance();
669 continue;
670 }
671 if (stream.kind() != TOKEN_IDENTIFIER) {
672 continue;
673 }
674 const StringRef name = stream.consume().text;
675 if (!stream.consume('{')) {
676 continue;
677 }
678
679 if (skip_next_struct) {
680 skip_next_struct = false;
681 skip_struct_body(stream);
682 continue;
683 }
684
685 const std::string struct_name(name);
686 if (!is_valid_type_name(struct_name, filepath)) {
687 return false;
688 }
689
690 ParsedStruct parsed_struct;
691 parsed_struct.type_name = struct_name;
692 DEBUG_PRINTF(1, "\t|\t|-- detected struct %s\n", parsed_struct.type_name.c_str());
693
694 if (!parse_struct_body(stream, filepath, parsed_struct)) {
695 return false;
696 }
697
698 r_structs.append(std::move(parsed_struct));
699 }
700
701 return true;
702}
703
704bool parse_dna_headers(const StringRefNull base_directory,
705 Vector<ParsedStruct> &r_structs,
706 Vector<ParsedEnum> &r_enums,
707 Span<const char *> include_files)
708{
709 for (const char *filename : include_files) {
710 const std::string path = std::string(base_directory) + filename;
711 if (!parse_dna_header(path, r_structs, r_enums)) {
712 return false;
713 }
714 }
715 return true;
716}
717
719
720/* -------------------------------------------------------------------- */
723
726{
727 if (member.type_name.starts_with("ListBaseT<") && member.type_name.ends_with(">")) {
728 member.type_name = "ListBase";
729 }
730}
731
739
741 {"int2", "int", {2, 0}, alignof(blender::int2)},
742 {"int3", "int", {3, 0}, alignof(blender::int3)},
743 {"int4", "int", {4, 0}, alignof(blender::int4)},
744 {"float2", "float", {2, 0}, alignof(blender::float2)},
745 {"float3", "float", {3, 0}, alignof(blender::float3)},
746 {"float4", "float", {4, 0}, alignof(blender::float4)},
747 {"float2x2", "float", {2, 2}, alignof(blender::float2x2)},
748 {"float3x3", "float", {3, 3}, alignof(blender::float3x3)},
749 {"float4x4", "float", {4, 4}, alignof(blender::float4x4)},
750};
751
752static_assert(sizeof(blender::int2) == sizeof(int[2]));
753static_assert(sizeof(blender::int3) == sizeof(int[3]));
754static_assert(sizeof(blender::int4) == sizeof(int[4]));
755static_assert(sizeof(blender::float2) == sizeof(float[2]));
756static_assert(sizeof(blender::float3) == sizeof(float[3]));
757static_assert(sizeof(blender::float4) == sizeof(float[4]));
758static_assert(sizeof(blender::float2x2) == sizeof(float[2][2]));
759static_assert(sizeof(blender::float3x3) == sizeof(float[3][3]));
760static_assert(sizeof(blender::float4x4) == sizeof(float[4][4]));
761
763{
764 const CppVectorMatrixTypeMap *mapping = nullptr;
766 if (member.type_name == m.cpp_type) {
767 mapping = &m;
768 break;
769 }
770 }
771 if (mapping == nullptr || member.member_name.empty()) {
772 return;
773 }
774 member.type_name = mapping->scalar;
775 member.alignment = mapping->alignment;
776
777 /* Members like `float (*var)[3][3]` have the `[3][3]` stripped in
778 * #parse_paren_declaration. So also don't add it for `float3x3 *var` either,
779 * rather keep it as `float` `*var`. */
780 if (member.member_name[0] != '*' && member.member_name[0] != '(') {
781 member.member_name += '[';
782 member.member_name += char('0' + mapping->dimensions[0]);
783 member.member_name += ']';
784 if (mapping->dimensions[1] != 0) {
785 member.member_name += '[';
786 member.member_name += char('0' + mapping->dimensions[1]);
787 member.member_name += ']';
788 }
789 }
790}
791
793[[nodiscard]] static bool substitute_enum(const ParsedStruct &parsed_struct,
794 ParsedMember &member,
796{
797 const ParsedEnum *const *found = enum_map.lookup_ptr(member.type_name);
798 if (found == nullptr) {
799 return true;
800 }
801 const ParsedEnum &parsed_enum = **found;
802 if (parsed_enum.underlying_type.empty()) {
803 fprintf(stderr,
804 "Struct '%s' member '%s' uses enum '%s' without an explicit underlying type\n",
805 parsed_struct.type_name.c_str(),
806 member.member_name.c_str(),
807 parsed_enum.type_name.c_str());
808 return false;
809 }
810 member.type_name = parsed_enum.underlying_type;
811 return true;
812}
813
816{
817 static const std::pair<const char *, const char *> integer_type_aliases[] = {
818 {"uint8_t", "uchar"},
819 {"int16_t", "short"},
820 {"uint16_t", "ushort"},
821 {"int32_t", "int"},
822 {"uint32_t", "int"},
823 };
824
825 for (const auto &[alias, sdna_name] : integer_type_aliases) {
826 if (member.type_name == alias) {
827 member.type_name = sdna_name;
828 break;
829 }
830 }
831}
832
835 bool /*for_rna*/)
836{
838 enum_map.reserve(enums.size());
839 for (const ParsedEnum &parsed_enum : enums) {
840 enum_map.add(parsed_enum.type_name, &parsed_enum);
841 }
842
843 for (ParsedStruct &parsed_struct : structs) {
844 for (ParsedMember &member : parsed_struct.members) {
845 substitute_listbase_t(member);
847 if (!substitute_enum(parsed_struct, member, enum_map)) {
848 return false;
849 }
851 }
852 }
853 return true;
854}
855
857
858} // namespace dna
859} // namespace blender
#define ELEM(...)
const Value * lookup_ptr(const Key &key) const
Definition BLI_map.hh:508
bool add(const Key &key, const Value &value)
Definition BLI_map.hh:295
void reserve(int64_t n)
Definition BLI_map.hh:1028
constexpr Span()=default
constexpr const char * c_str() const
constexpr StringRef drop_prefix(int64_t n) const
constexpr StringRef()
int64_t size() const
void append(const T &value)
constexpr const char * end() const
constexpr bool startswith(StringRef prefix) const
constexpr const char * begin() const
constexpr bool is_empty() const
constexpr int64_t size() const
const Token & peek(int64_t offset=0) const
Definition dna_parse.cc:109
void append(Token &&token)
Definition dna_parse.cc:94
bool consume_expression(StringRef expr)
Definition dna_parse.cc:142
TokenKind kind(int64_t offset=0) const
Definition dna_parse.cc:104
bool consume(TokenKind k)
Definition dna_parse.cc:124
const Token & consume()
Definition dna_parse.cc:114
bool consume_keyword(StringRef kw)
Definition dna_parse.cc:133
#define DEBUG_PRINTF(debug_level,...)
Definition dna_parse.cc:37
VecBase< int32_t, 3 > int3
VecBase< float, 2 > float2
VecBase< int32_t, 2 > int2
VecBase< float, 3 > float3
VecBase< int32_t, 4 > int4
VecBase< float, 4 > float4
bool substitute_cpp_types(Vector< ParsedStruct > &structs, const Span< ParsedEnum > enums, bool)
Definition dna_parse.cc:833
static bool parse_struct_body(TokenStream &stream, const StringRefNull filepath, ParsedStruct &r_struct)
Definition dna_parse.cc:513
constexpr TokenKind TOKEN_NUMBER
Definition dna_parse.cc:81
static bool parse_member_declaration(TokenStream &stream, std::string &out)
Definition dna_parse.cc:489
static void substitute_vector_or_matrix(ParsedMember &member)
Definition dna_parse.cc:762
static void skip_initializer(TokenStream &stream)
Definition dna_parse.cc:397
static bool parse_paren_declaration(TokenStream &stream, std::string &out)
Definition dna_parse.cc:460
static TokenStream strip_ignored_tokens(TokenStream stream)
Definition dna_parse.cc:276
static bool substitute_enum(const ParsedStruct &parsed_struct, ParsedMember &member, const Map< StringRef, const ParsedEnum * > &enum_map)
Definition dna_parse.cc:793
static TokenStream tokenize_dna_header(StringRef source)
Definition dna_parse.cc:189
static void append_template_suffix(TokenStream &stream, std::string &out)
Definition dna_parse.cc:436
static void substitute_sdna_integer_type(ParsedMember &member)
Definition dna_parse.cc:815
static bool is_valid_type_name(const StringRefNull type_name, const StringRefNull filepath)
Definition dna_parse.cc:314
static bool read_file_data(const StringRefNull filepath, Vector< char > &data)
Definition dna_parse.cc:57
static void skip_struct_body(TokenStream &stream)
Definition dna_parse.cc:583
static bool is_identifier_continuation(char c)
Definition dna_parse.cc:180
constexpr TokenKind TOKEN_END
Definition dna_parse.cc:82
static bool parse_enum_declaration(TokenStream &stream, const StringRefNull filepath, Vector< ParsedEnum > &r_enums)
Definition dna_parse.cc:598
static bool is_identifier_start(char c)
Definition dna_parse.cc:175
bool parse_dna_headers(const StringRefNull base_directory, Vector< ParsedStruct > &r_structs, Vector< ParsedEnum > &r_enums, Span< const char * > include_files)
Definition dna_parse.cc:704
static bool is_valid_member_name(const StringRefNull name, const StringRefNull filepath)
Definition dna_parse.cc:334
static void substitute_listbase_t(ParsedMember &member)
Definition dna_parse.cc:725
static void skip_balanced(TokenStream &stream, TokenKind open, TokenKind close)
Definition dna_parse.cc:381
static void append_array_suffix(TokenStream &stream, std::string &out)
Definition dna_parse.cc:416
Span< const char * > default_dna_header_filenames()
Definition dna_parse.cc:49
constexpr TokenKind TOKEN_IDENTIFIER
Definition dna_parse.cc:80
static const CppVectorMatrixTypeMap cpp_array_type_mappings[]
Definition dna_parse.cc:740
static bool parse_dna_header(const StringRefNull filepath, Vector< ParsedStruct > &r_structs, Vector< ParsedEnum > &r_enums)
Definition dna_parse.cc:636
std::string filename(const std::string_view &str, size_t pos)
BMesh Iterators.
int debugSDNA
Definition dna_parse.cc:33
__int64 int64_t
Definition BKE_text.h:90
MatBase< float, 2, 2 > float2x2
MatBase< float, 4, 4 > float4x4
BMesh const char void * data
StringRef DNA_member_id_string_ref(const StringRef member_full)
Definition dna_utils.cc:95
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
MatBase< float, 3, 3 > float3x3
iter begin(iter)
std::string underlying_type
Definition dna_parse.h:40
Vector< ParsedMember > members
Definition dna_parse.h:34