def _test_py2cpp(func, expected_string): result = cppunparse.py2cpp(func) if result != expected_string: print("ERROR in py2cpp, expected:\n%s\n\ngot:\n%s\n" % (expected_string, result)) return False return True
def codeblock_to_cpp(cb: CodeBlock): """ Converts a CodeBlock object to a C++ string. """ if cb.language == dtypes.Language.CPP: return cb.as_string elif cb.language == dtypes.Language.Python: return cppunparse.py2cpp(cb.code) else: warnings.warn('Unrecognized language %s in codeblock' % cb.language) return cb.as_string