MCPcopy Create free account
hub / github.com/argotorg/solidity / wrapReadCallback

Function wrapReadCallback

libsolc/libsolc.cpp:74–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74ReadCallback::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
108std::string compile(std::string _input, CStyleReadFileCallback _readCallback, void* _readContext)
109{

Callers 1

compileFunction · 0.85

Calls 3

takeOverAllocationFunction · 0.85
truncateCStringFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected