diff --git a/HISTORY.rst b/HISTORY.rst index f22ac94c..5d03f055 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,11 @@ Release History =============== +2.0.1 (2015-??-??) +------------------ + +* Fixed bug with converting ``*.ino`` to ``*.cpp`` + 2.0.0 (2015-05-22) ------------------ diff --git a/platformio/__init__.py b/platformio/__init__.py index 0864a676..a701575c 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,7 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (2, 0, 0) +VERSION = (2, 0, "1.dev0") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 656473b7..3c07e786 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -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):