2
0

backend.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. from abc import ABC, abstractmethod
  4. from .commands import gen_commands
  5. from .events import gen_events
  6. from .features import gen_features
  7. from .introspect import gen_introspect
  8. from .schema import QAPISchema
  9. from .types import gen_types
  10. from .visit import gen_visit
  11. class QAPIBackend(ABC):
  12. @abstractmethod
  13. def generate(self,
  14. schema: QAPISchema,
  15. output_dir: str,
  16. prefix: str,
  17. unmask: bool,
  18. builtins: bool,
  19. gen_tracing: bool) -> None:
  20. """
  21. Generate code for the given schema into the target directory.
  22. :param schema: The primary QAPI schema object.
  23. :param output_dir: The output directory to store generated code.
  24. :param prefix: Optional C-code prefix for symbol names.
  25. :param unmask: Expose non-ABI names through introspection?
  26. :param builtins: Generate code for built-in types?
  27. :raise QAPIError: On failures.
  28. """
  29. class QAPICBackend(QAPIBackend):
  30. def generate(self,
  31. schema: QAPISchema,
  32. output_dir: str,
  33. prefix: str,
  34. unmask: bool,
  35. builtins: bool,
  36. gen_tracing: bool) -> None:
  37. """
  38. Generate C code for the given schema into the target directory.
  39. :param schema_file: The primary QAPI schema file.
  40. :param output_dir: The output directory to store generated code.
  41. :param prefix: Optional C-code prefix for symbol names.
  42. :param unmask: Expose non-ABI names through introspection?
  43. :param builtins: Generate code for built-in types?
  44. :raise QAPIError: On failures.
  45. """
  46. gen_types(schema, output_dir, prefix, builtins)
  47. gen_features(schema, output_dir, prefix)
  48. gen_visit(schema, output_dir, prefix, builtins)
  49. gen_commands(schema, output_dir, prefix, gen_tracing)
  50. gen_events(schema, output_dir, prefix)
  51. gen_introspect(schema, output_dir, prefix, unmask)