mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
d404fee38f
Merge all the command-line scripts for generating tuple-tree implementations into a single `tuple-tree-generate.py` script. Move all the other files a directory down.
28 lines
700 B
Python
28 lines
700 B
Python
#
|
|
# This file is distributed under the MIT License. See LICENSE.md for details.
|
|
#
|
|
import re
|
|
from pathlib import Path
|
|
|
|
import jinja2
|
|
|
|
from tuple_tree_generator.schema.struct import ReferenceStructField, SequenceStructField
|
|
from tuple_tree_generator.schema.struct import SimpleStructField
|
|
|
|
TEMPLATES_DIR = Path(__file__).parent.parent / "templates"
|
|
|
|
loader = jinja2.FileSystemLoader(str(TEMPLATES_DIR))
|
|
int_re = re.compile(r"(u)?int(8|16|32|64)_t")
|
|
|
|
|
|
def is_simple_struct_field(obj):
|
|
return isinstance(obj, SimpleStructField)
|
|
|
|
|
|
def is_sequence_struct_field(obj):
|
|
return isinstance(obj, SequenceStructField)
|
|
|
|
|
|
def is_reference_struct_field(obj):
|
|
return isinstance(obj, ReferenceStructField)
|