mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Fix bug with converting "*.ino" to "*.cpp"
This commit is contained in:
@ -1,6 +1,11 @@
|
||||
Release History
|
||||
===============
|
||||
|
||||
2.0.1 (2015-??-??)
|
||||
------------------
|
||||
|
||||
* Fixed bug with converting ``*.ino`` to ``*.cpp``
|
||||
|
||||
2.0.0 (2015-05-22)
|
||||
------------------
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
VERSION = (2, 0, 0)
|
||||
VERSION = (2, 0, "1.dev0")
|
||||
__version__ = ".".join([str(s) for s in VERSION])
|
||||
|
||||
__title__ = "platformio"
|
||||
|
@ -309,8 +309,8 @@ class InoToCPPConverter(object):
|
||||
|
||||
PROTOTYPE_RE = re.compile(
|
||||
r"""^(
|
||||
(?:\s*[a-z_\d]+){1,2} # return type
|
||||
\s+[a-z_\d]+\s* # name of prototype
|
||||
(\s*[a-z_\d]+){1,2} # return type
|
||||
(\s+[a-z_\d]+\s*) # name of prototype
|
||||
\([a-z_,\.\*\&\[\]\s\d]*\) # arguments
|
||||
)\s*\{ # must end with {
|
||||
""",
|
||||
@ -334,6 +334,15 @@ class InoToCPPConverter(object):
|
||||
else:
|
||||
return " "
|
||||
|
||||
def _parse_prototypes(self, contents):
|
||||
prototypes = []
|
||||
reserved_keywords = set(["if", "else", "while"])
|
||||
for item in self.PROTOTYPE_RE.findall(contents):
|
||||
if set([item[1].strip(), item[2].strip()]) & reserved_keywords:
|
||||
continue
|
||||
prototypes.append(item[0])
|
||||
return prototypes
|
||||
|
||||
def append_prototypes(self, fname, contents, prototypes):
|
||||
contents = self.STRIPCOMMENTS_RE.sub(self._replace_comments_callback,
|
||||
contents)
|
||||
@ -358,7 +367,7 @@ class InoToCPPConverter(object):
|
||||
data = []
|
||||
for node in self.nodes:
|
||||
ino_contents = node.get_text_contents()
|
||||
prototypes += self.PROTOTYPE_RE.findall(ino_contents)
|
||||
prototypes += self._parse_prototypes(ino_contents)
|
||||
|
||||
item = (basename(node.get_path()), ino_contents)
|
||||
if self.is_main_node(ino_contents):
|
||||
|
Reference in New Issue
Block a user