1# This work is licensed under the terms of the GNU GPL, version 2 or later. 2# See the COPYING file in the top-level directory. 3 4from abc import ABC, abstractmethod 5 6from .commands import gen_commands 7from .events import gen_events 8from .features import gen_features 9from .introspect import gen_introspect 10from .schema import QAPISchema 11from .types import gen_types 12from .visit import gen_visit 13 14 15class QAPIBackend(ABC): 16 17 @abstractmethod 18 def generate(self, 19 schema: QAPISchema, 20 output_dir: str, 21 prefix: str, 22 unmask: bool, 23 builtins: bool, 24 gen_tracing: bool) -> None: 25 """ 26 Generate code for the given schema into the target directory. 27 28 :param schema: The primary QAPI schema object. 29 :param output_dir: The output directory to store generated code. 30 :param prefix: Optional C-code prefix for symbol names. 31 :param unmask: Expose non-ABI names through introspection? 32 :param builtins: Generate code for built-in types? 33 34 :raise QAPIError: On failures. 35 """ 36 37 38class QAPICBackend(QAPIBackend): 39 40 def generate(self, 41 schema: QAPISchema, 42 output_dir: str, 43 prefix: str, 44 unmask: bool, 45 builtins: bool, 46 gen_tracing: bool) -> None: 47 """ 48 Generate C code for the given schema into the target directory. 49 50 :param schema_file: The primary QAPI schema file. 51 :param output_dir: The output directory to store generated code. 52 :param prefix: Optional C-code prefix for symbol names. 53 :param unmask: Expose non-ABI names through introspection? 54 :param builtins: Generate code for built-in types? 55 56 :raise QAPIError: On failures. 57 """ 58 gen_types(schema, output_dir, prefix, builtins) 59 gen_features(schema, output_dir, prefix) 60 gen_visit(schema, output_dir, prefix, builtins) 61 gen_commands(schema, output_dir, prefix, gen_tracing) 62 gen_events(schema, output_dir, prefix) 63 gen_introspect(schema, output_dir, prefix, unmask) 64