|
|
@@ -1,5 +1,11 @@ |
|
|
|
from Function import * |
|
|
|
|
|
|
|
def includes(): |
|
|
|
return """#include <map> |
|
|
|
#include <string> |
|
|
|
#include "entities.h" |
|
|
|
""" |
|
|
|
|
|
|
|
def replaceAnd(s): |
|
|
|
return s.replace("and", "&&") |
|
|
|
|
|
|
@@ -34,6 +40,7 @@ def translateStatement(s, state): |
|
|
|
ss = s.lstrip() |
|
|
|
posColon = ss.find(": ") |
|
|
|
posComma = ss.find(", ") |
|
|
|
posCtx = ss.find("c.") |
|
|
|
posEqual = ss.find(" = ") |
|
|
|
posFor = ss.find("for ") |
|
|
|
posIn = ss.find(" in ") |
|
|
@@ -70,6 +77,7 @@ def translateStatement(s, state): |
|
|
|
|
|
|
|
# name = value -> auto name = value |
|
|
|
if ( |
|
|
|
posCtx == -1 and |
|
|
|
posColon == -1 and |
|
|
|
posOpenSquareBracket == -1 and |
|
|
|
posEqual >= 0 |
|
|
@@ -120,6 +128,9 @@ class CPP: |
|
|
|
params = [] |
|
|
|
for i in range(0, len(self.fn.parameters)): |
|
|
|
p = translateParameter(self.fn.parameters[i]) |
|
|
|
# Make Context passed by reference. |
|
|
|
if "Context" in p: |
|
|
|
p = p.replace("Context", "Context&") |
|
|
|
params.append(p) |
|
|
|
strparams = "\n".join(params) |
|
|
|
if (len(strparams) > 0): |
|
|
|