All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: bitbake-devel <bitbake-devel@lists.openembedded.org>
Cc: Holger Freyther <holger@freyther.de>
Subject: [PATCH] BBHandler: Improve IN_PYTHON_EOF handling
Date: Sun, 20 Dec 2015 13:21:14 +0000	[thread overview]
Message-ID: <1450617674.8461.91.camel@linuxfoundation.org> (raw)

Now we're actively using the line numbers for other thins, having
magic values like IN_PYTHON_EOF causes problems, in particular, 32
bit overflow on 32 bit machines.

There is a neater way to signal eof to feeder(), just using an extra
parameter so use this instead and drop the IN_PYTHON_EOF magic values.

This has the added bonus that line numbers are then correct for
python functions at the end of files.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py
index ec097ba..97a9ee8 100644
--- a/bitbake/lib/bb/parse/parse_py/BBHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py
@@ -47,7 +47,6 @@ __addhandler_regexp__    = re.compile( r"addhandler\s+(.+)" )
 __def_regexp__           = re.compile( r"def\s+(\w+).*:" )
 __python_func_regexp__   = re.compile( r"(\s+.*)|(^$)" )
 
-
 __infunc__ = []
 __inpython__ = False
 __body__   = []
@@ -55,15 +54,6 @@ __classname__ = ""
 
 cached_statements = {}
 
-# We need to indicate EOF to the feeder. This code is so messy that
-# factoring it out to a close_parse_file method is out of question.
-# We will use the IN_PYTHON_EOF as an indicator to just close the method
-#
-# The two parts using it are tightly integrated anyway
-IN_PYTHON_EOF = -9999999999999
-
-
-
 def supports(fn, d):
     """Return True if fn has a supported extension"""
     return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"]
@@ -110,7 +100,7 @@ def get_statements(filename, absolute_filename, base_name):
         file.close()
         if __inpython__:
             # add a blank line to close out any python definition
-            feeder(IN_PYTHON_EOF, "", filename, base_name, statements)
+            feeder(lineno, "", filename, base_name, statements, eof=True)
 
         if filename.endswith(".bbclass") or filename.endswith(".inc"):
             cached_statements[absolute_filename] = statements
@@ -171,7 +161,7 @@ def handle(fn, d, include):
 
     return d
 
-def feeder(lineno, s, fn, root, statements):
+def feeder(lineno, s, fn, root, statements, eof=False):
     global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__, __infunc__, __body__, bb, __residue__, __classname__
     if __infunc__:
         if s == '}':
@@ -185,7 +175,7 @@ def feeder(lineno, s, fn, root, statements):
 
     if __inpython__:
         m = __python_func_regexp__.match(s)
-        if m and lineno != IN_PYTHON_EOF:
+        if m and not eof:
             __body__.append(s)
             return
         else:
@@ -194,7 +184,7 @@ def feeder(lineno, s, fn, root, statements):
             __body__ = []
             __inpython__ = False
 
-            if lineno == IN_PYTHON_EOF:
+            if eof:
                 return
 
     if s and s[0] == '#':




             reply	other threads:[~2015-12-20 13:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-20 13:21 Richard Purdie [this message]
2015-12-20 17:13 ` [PATCH] BBHandler: Improve IN_PYTHON_EOF handling Holger Freyther

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=1450617674.8461.91.camel@linuxfoundation.org \
    --to=richard.purdie@linuxfoundation.org \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=holger@freyther.de \
    /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.