mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
test direct non-copying reading FFIBytearray in C++ context
This commit is contained in:
parent
d3760d5b7c
commit
dc9ae6e99e
4 changed files with 22 additions and 0 deletions
|
|
@ -5,6 +5,8 @@
|
|||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
#define VC_LUA_DIRECT_BYTEARRAY_ACCESS
|
||||
|
||||
inline constexpr int ENGINE_VERSION_MAJOR = 0;
|
||||
inline constexpr int ENGINE_VERSION_MINOR = 32;
|
||||
|
||||
|
|
|
|||
|
|
@ -833,11 +833,22 @@ namespace lua {
|
|||
return tolstring(L, idx);
|
||||
}
|
||||
pushvalue(L, idx);
|
||||
#ifdef VC_LUA_DIRECT_BYTEARRAY_ACCESS
|
||||
requireglobal(L, "Bytearray_as_ptr");
|
||||
pushvalue(L, -2);
|
||||
call(L, 1, 2);
|
||||
auto view = tolstring(L, -2);
|
||||
uint64_t size = touinteger(L, -1);
|
||||
auto ptr = (const char*)std::stoull(std::string(view), nullptr, 16);
|
||||
pop(L, 3);
|
||||
return std::string_view(ptr, size);
|
||||
#else
|
||||
requireglobal(L, "Bytearray_as_string");
|
||||
pushvalue(L, -2);
|
||||
call(L, 1, 1);
|
||||
auto view = tolstring(L, -1);
|
||||
pop(L, 2);
|
||||
return view;
|
||||
#endif // VC_LUA_DIRECT_BYTEARRAY_ACCESS
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue