qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, John Snow <jsnow@redhat.com>
Subject: [PULL 03/15] qapi/source: Remove line number from QAPISourceInfo initializer
Date: Thu, 20 May 2021 19:52:44 +0200	[thread overview]
Message-ID: <20210520175256.1119684-4-armbru@redhat.com> (raw)
In-Reply-To: <20210520175256.1119684-1-armbru@redhat.com>

From: John Snow <jsnow@redhat.com>

With the QAPISourceInfo(None, None, None) construct gone, there's no
longer any reason to have to specify that a file starts on the first
line. Remove it from the initializer and default it to 1.

Remove the last vestiges where we check for 'line' being unset, that
can't happen, now.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20210519183951.3946870-4-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi/parser.py |  2 +-
 scripts/qapi/source.py | 10 +++-------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index a53b735e7d..39dbcc4eac 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -47,7 +47,7 @@ def __init__(self, fname, previously_included=None, incl_info=None):
         if self.src == '' or self.src[-1] != '\n':
             self.src += '\n'
         self.cursor = 0
-        self.info = QAPISourceInfo(fname, 1, incl_info)
+        self.info = QAPISourceInfo(fname, incl_info)
         self.line_pos = 0
         self.exprs = []
         self.docs = []
diff --git a/scripts/qapi/source.py b/scripts/qapi/source.py
index 1ade864d7b..04193cc964 100644
--- a/scripts/qapi/source.py
+++ b/scripts/qapi/source.py
@@ -31,10 +31,9 @@ def __init__(self) -> None:
 class QAPISourceInfo:
     T = TypeVar('T', bound='QAPISourceInfo')
 
-    def __init__(self, fname: str, line: int,
-                 parent: Optional['QAPISourceInfo']):
+    def __init__(self, fname: str, parent: Optional['QAPISourceInfo']):
         self.fname = fname
-        self.line = line
+        self.line = 1
         self.parent = parent
         self.pragma: QAPISchemaPragma = (
             parent.pragma if parent else QAPISchemaPragma()
@@ -52,10 +51,7 @@ def next_line(self: T) -> T:
         return info
 
     def loc(self) -> str:
-        ret = self.fname
-        if self.line is not None:
-            ret += ':%d' % self.line
-        return ret
+        return f"{self.fname}:{self.line}"
 
     def in_defn(self) -> str:
         if self.defn_name:
-- 
2.26.3



  parent reply	other threads:[~2021-05-20 17:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 17:52 [PULL 00/15] QAPI patches patches for 2021-05-20 Markus Armbruster
2021-05-20 17:52 ` [PULL 01/15] qapi/parser: Don't try to handle file errors Markus Armbruster
2021-05-20 17:52 ` [PULL 02/15] qapi: Add test for nonexistent schema file Markus Armbruster
2021-05-20 17:52 ` Markus Armbruster [this message]
2021-05-20 17:52 ` [PULL 04/15] qapi/parser: factor parsing routine into method Markus Armbruster
2021-05-20 17:52 ` [PULL 05/15] qapi/parser: Assert lexer value is a string Markus Armbruster
2021-05-20 17:52 ` [PULL 06/15] qapi/parser: enforce all top-level expressions must be dict in _parse() Markus Armbruster
2021-05-20 17:52 ` [PULL 07/15] qapi/parser: assert object keys are strings Markus Armbruster
2021-05-20 17:52 ` [PULL 08/15] qapi/parser: Use @staticmethod where appropriate Markus Armbruster
2021-05-20 17:52 ` [PULL 09/15] qapi: add must_match helper Markus Armbruster
2021-05-20 17:52 ` [PULL 10/15] qapi/parser: Fix token membership tests when token can be None Markus Armbruster
2021-05-20 17:52 ` [PULL 11/15] qapi/parser: Rework _check_pragma_list_of_str as a TypeGuard Markus Armbruster
2021-05-20 17:52 ` [PULL 12/15] qapi/parser: add type hint annotations Markus Armbruster
2021-05-20 17:52 ` [PULL 13/15] qapi/parser: Remove superfluous list comprehension Markus Armbruster
2021-05-20 17:52 ` [PULL 14/15] qapi/parser: allow 'ch' variable name Markus Armbruster
2021-05-20 17:52 ` [PULL 15/15] qapi/parser: add docstrings Markus Armbruster
2021-05-21  8:54 ` [PULL 00/15] QAPI patches patches for 2021-05-20 Peter Maydell

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=20210520175256.1119684-4-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).