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