qbolt/qbolt/interop.cpp

43 lines
836 B
C++
Raw Normal View History

#include "interop.h"
2017-05-21 00:39:55 +00:00
#include <QStringList>
Interop::Interop()
{
}
GoString Interop::toGoString_WeakRef(QByteArray *qba) {
return GoString{qba->data(), qba->length()};
}
int64_t Interop::GetMagic() {
return ::GetMagic();
}
2017-05-21 00:39:55 +00:00
//
2017-06-19 08:53:50 +00:00
GoSliceManagedWrapper::GoSliceManagedWrapper(const QList<QByteArray>& qsl) :
2017-05-21 00:39:55 +00:00
rawStrings(),
slice(),
strings(nullptr)
2017-05-21 00:39:55 +00:00
{
2017-06-19 08:53:50 +00:00
rawStrings.reserve(qsl.size());
strings = new GoString[qsl.size()];
2017-06-19 08:53:50 +00:00
for (int i = 0; i < qsl.size(); ++i) {
rawStrings.push_back( qsl.at(i) );
strings[i].p = rawStrings[i].data();
strings[i].n = rawStrings[i].size();
2017-05-21 00:39:55 +00:00
}
slice.data = static_cast<void*>(strings);
2017-06-19 08:53:50 +00:00
slice.len = qsl.size(); // * sizeof(GoString);
2017-05-21 00:39:55 +00:00
slice.cap = slice.len;
}
GoSliceManagedWrapper::~GoSliceManagedWrapper()
{
delete[] strings;
}