| 58 | |
| 59 | |
| 60 | void PushLine(const AString & a_Line) |
| 61 | { |
| 62 | if (m_IsInToLua) |
| 63 | { |
| 64 | // Inside a tolua block |
| 65 | if (TrimString(a_Line) == "// tolua_end") |
| 66 | { |
| 67 | // End of a tolua block |
| 68 | m_IsInToLua = false; |
| 69 | return; |
| 70 | } |
| 71 | m_Out << a_Line << std::endl; |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | if (m_IsInComment) |
| 76 | { |
| 77 | // Inside a multiline comment block, outside of a tolua block; accumulate m_LastComment |
| 78 | m_LastComment += a_Line + "\n"; |
| 79 | m_IsInComment = (a_Line.find("*/") == AString::npos); |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | AString Trimmed(TrimString(a_Line)); |
| 84 | |
| 85 | if (Trimmed == "// tolua_begin") |
| 86 | { |
| 87 | // Beginning of a tolua block |
| 88 | m_IsInToLua = true; |
| 89 | if (!m_LastComment.empty()) |
| 90 | { |
| 91 | m_Out << m_LastComment << std::endl; |
| 92 | m_LastComment.clear(); |
| 93 | } |
| 94 | return; |
| 95 | } |
| 96 | |
| 97 | size_t CommentBegin = a_Line.find("/*"); |
| 98 | if (CommentBegin != AString::npos) |
| 99 | { |
| 100 | m_IsInComment = (a_Line.find("*/", CommentBegin) == AString::npos); |
| 101 | m_LastComment = a_Line; |
| 102 | } |
| 103 | |
| 104 | size_t ExportIdx = a_Line.find("// tolua_export"); |
| 105 | if (ExportIdx != AString::npos) |
| 106 | { |
| 107 | // Single-line tolua block |
| 108 | |
| 109 | // Strip the export comment and right-trim the line: |
| 110 | AString Stripped(a_Line.substr(0, ExportIdx)); |
| 111 | int End = Stripped.length() - 1; |
| 112 | while ((End > 0) && (Stripped[End] <= 32)) |
| 113 | { |
| 114 | End--; |
| 115 | } |
| 116 | Stripped.erase(End + 1); |
| 117 |
nothing calls this directly
no test coverage detected