| 72 | } |
| 73 | |
| 74 | ReadCallback::Callback wrapReadCallback(CStyleReadFileCallback _readCallback, void* _readContext) |
| 75 | { |
| 76 | ReadCallback::Callback readCallback; |
| 77 | if (_readCallback) |
| 78 | { |
| 79 | readCallback = [=](std::string const& _kind, std::string const& _data) |
| 80 | { |
| 81 | char* contents_c = nullptr; |
| 82 | char* error_c = nullptr; |
| 83 | _readCallback(_readContext, _kind.data(), _data.data(), &contents_c, &error_c); |
| 84 | ReadCallback::Result result; |
| 85 | result.success = true; |
| 86 | if (!contents_c && !error_c) |
| 87 | { |
| 88 | result.success = false; |
| 89 | result.responseOrErrorMessage = "Callback not supported."; |
| 90 | } |
| 91 | if (contents_c) |
| 92 | { |
| 93 | result.success = true; |
| 94 | result.responseOrErrorMessage = takeOverAllocation(contents_c); |
| 95 | } |
| 96 | if (error_c) |
| 97 | { |
| 98 | result.success = false; |
| 99 | result.responseOrErrorMessage = takeOverAllocation(error_c); |
| 100 | } |
| 101 | truncateCString(result.responseOrErrorMessage); |
| 102 | return result; |
| 103 | }; |
| 104 | } |
| 105 | return readCallback; |
| 106 | } |
| 107 | |
| 108 | std::string compile(std::string _input, CStyleReadFileCallback _readCallback, void* _readContext) |
| 109 | { |
no test coverage detected