All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	qemu-devel@nongnu.org, "Victor Toso" <victortoso@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>,
	"John Snow" <jsnow@redhat.com>
Subject: Re: [PATCH v2] qapi: pluggable backend code generators
Date: Tue, 04 Mar 2025 08:18:16 +0100	[thread overview]
Message-ID: <874j09z2kn.fsf@pond.sub.org> (raw)
In-Reply-To: <87msea9pdv.fsf@pond.sub.org> (Markus Armbruster's message of "Tue, 25 Feb 2025 13:31:56 +0100")

Markus Armbruster <armbru@redhat.com> writes:

> Daniel P. Berrangé <berrange@redhat.com> writes:
>
>> The 'qapi.backend.QAPIBackend' class defines an API contract for code
>> generators. The current generator is put into a new class
>> 'qapi.backend.QAPICBackend' and made to be the default impl.
>>
>> A custom generator can be requested using the '-k' arg which takes a
>
> Missed an instance of -k.  Can fix this myself.
>
>> fully qualified python class name
>>
>>    qapi-gen.py -B the.python.module.QAPIMyBackend
>>
>> This allows out of tree code to use the QAPI generator infrastructure
>> to create new language bindings for QAPI schemas. This has the caveat
>> that the QAPI generator APIs are not guaranteed stable, so consumers
>> of this feature may have to update their code to be compatible with
>> future QEMU releases.
>>
>> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

[...]

>> diff --git a/scripts/qapi/main.py b/scripts/qapi/main.py
>> index 324081b9fc..8a8b1e0121 100644
>> --- a/scripts/qapi/main.py
>> +++ b/scripts/qapi/main.py

[...]

>> @@ -29,32 +25,37 @@ def invalid_prefix_char(prefix: str) -> Optional[str]:
>>      return None
>>  
>>  
>> -def generate(schema_file: str,
>> -             output_dir: str,
>> -             prefix: str,
>> -             unmask: bool = False,
>> -             builtins: bool = False,
>> -             gen_tracing: bool = False) -> None:
>> -    """
>> -    Generate C code for the given schema into the target directory.
>> +def create_backend(path: str) -> QAPIBackend:
>> +    if path is None:
>> +        return QAPICBackend()
>>  
>> -    :param schema_file: The primary QAPI schema file.
>> -    :param output_dir: The output directory to store generated code.
>> -    :param prefix: Optional C-code prefix for symbol names.
>> -    :param unmask: Expose non-ABI names through introspection?
>> -    :param builtins: Generate code for built-in types?
>> +    if "." not in path:
>> +        print(f"Missing qualified module path in '{path}'", file=sys.stderr)
>> +        sys.exit(1)
>>  
>> -    :raise QAPIError: On failures.
>> -    """
>> -    assert invalid_prefix_char(prefix) is None
>> +    module_path, _, class_name = path.rpartition('.')
>
> I'd like to tweak this to
>
>        module_path, dot, class_name = path.rpartition('.')
>        if not dot:
>            print(f"argument of -B must be of the form MODULE.CLASS",
>                  file=sys.stderr)

This bothers flake8:

    scripts/qapi/main.py:34:15: F541 f-string is missing placeholders

I'll make it a plain string instead.

>            sys.exit(1)
>

[...]



      parent reply	other threads:[~2025-03-04  7:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-24 18:20 [PATCH v2] qapi: pluggable backend code generators Daniel P. Berrangé
2025-02-25 12:31 ` Markus Armbruster
2025-02-25 12:39   ` Daniel P. Berrangé
2025-02-26  7:46     ` Markus Armbruster
2025-03-04  7:18   ` Markus Armbruster [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874j09z2kn.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=qemu-devel@nongnu.org \
    --cc=victortoso@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.