From 6a70b62bafe50bc8caca43453ea854e65d13ce4d Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 16 Nov 2024 18:09:43 +0000 Subject: [PATCH] library: redo buffer APIs Completely changed the way Buffer objects are exposed in the API to make them more in line with JavaScript's DataView. There are a few advantages to this: 1. Much easier to understand how to send binary data from Lua<->Browser. Basically only need to understand one API instead of two. 2. More depth than before with less complexity. 3. Buffer read functions can now also be used on strings. --- src/library/doc.texi | 459 +++++++++++++++++++++++++++++--- src/library/plugin/plugin_api.c | 169 +++++++++--- src/library/plugin/plugin_api.h | 5 - 3 files changed, 561 insertions(+), 72 deletions(-) diff --git a/src/library/doc.texi b/src/library/doc.texi index 7feb7ac..4cf4d7c 100644 --- a/src/library/doc.texi +++ b/src/library/doc.texi @@ -491,7 +491,8 @@ local mypoint = bolt.point(0, 0, 0) Creates and returns a new @ref{objects-buffer,,Buffer Object} with the given size. Buffer objects are fixed-size and useful for passing large -amounts of binary data to functions. +amounts of binary data to functions. They're mostly analogous to +JavaScript's @code{DataView}. The initial contents will be 0. @example lua @verbatim @@ -682,6 +683,136 @@ end) It's @strong{not safe} to use an event object after the event handler has returned. +@node functions-buffergetint8 +@section buffergetint8 + +Reads a single byte from a buffer object or string, at the given offset, +and returns it as a signed integer. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +local num = bolt.buffergetint8(mybuffer, myoffset) +@end verbatim +@end example + +@node functions-buffergetint16 +@section buffergetint16 + +Reads a two-byte value from the buffer object or string, at the given +offset, and returns it as a signed integer. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +local num = bolt.buffergetint16(mybuffer, myoffset) +@end verbatim +@end example + +@node functions-buffergetint32 +@section buffergetint32 + +Reads a four-byte value from the buffer object or string, at the given +offset, and returns it as a signed integer. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +local num = bolt.buffergetint32(mybuffer, myoffset) +@end verbatim +@end example + +@node functions-buffergetint64 +@section buffergetint64 + +Reads an eight-byte value from the buffer object or string, at the given +offset, and returns it as a signed integer. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +local num = bolt.buffergetint64(mybuffer, myoffset) +@end verbatim +@end example + +@node functions-buffergetuint8 +@section buffergetuint8 + +Reads a single byte from the buffer object or string, at the given +offset and returns it, as an unsigned integer. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +local num = bolt.buffergetuint8(mybuffer, myoffset) +@end verbatim +@end example + +@node functions-buffergetuint16 +@section buffergetuint16 + +Reads a two-byte value from the buffer object or string, at the given +offset, and returns it as an unsigned integer. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +local num = bolt.buffergetuint16(mybuffer, myoffset) +@end verbatim +@end example + +@node functions-buffergetuint32 +@section buffergetuint32 + +Reads a four-byte value from the buffer object or string, at the given +offset, and returns it as an unsigned integer. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +local num = bolt.buffergetuint32(mybuffer, myoffset) +@end verbatim +@end example + +@node functions-buffergetuint64 +@section buffergetuint64 + +Reads an eight-byte value from the buffer object or string, at the given +offset, and returns it as an unsigned integer. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +local num = bolt.buffergetuint64(mybuffer, myoffset) +@end verbatim +@end example + +@node functions-buffergetfloat32 +@section buffergetfloat32 + +Reads a four-byte IEEE floating point value from the buffer object or +string, at the given offset, and returns it as a number. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +local num = bolt.buffergetfloat32(mybuffer, myoffset) +@end verbatim +@end example + +@node functions-buffergetfloat64 +@section buffergetfloat64 + +Reads an eight-byte IEEE floating point value from the buffer object or +string, at the given offset, and returns it as a number. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +local num = bolt.buffergetfloat64(mybuffer, myoffset) +@end verbatim +@end example + @node Objects @chapter List of Objects @@ -805,64 +936,328 @@ mysurface:drawtowindow(mywindow, 0, 0, 100, 100, 0, 0, 1920, 1080) A buffer is a fixed-size, pre-allocated block of memory containing binary data. Functions in Bolt which need binary data as an input can take either a Lua string or a Buffer object. Functions that return -binary data return strings, because it's more performant and sometimes -more useful. +binary data return strings. The buffer API is designed to be mostly the +same as the @code{DataView} API in JavaScript, and exists to make it +easier to read and receive large amounts of raw binary data, such as +file contents, RGBA pixel data, or messages to and from browsers. + +@example lua +@verbatim +local mybuffer = bolt.createbuffer(12) +mybuffer:setuint32(0, 12345) +mybuffer:setfloat64(4, -3.14159) +local num1 = mybuffer:getuint32(0) --returns 12345 +local num2 = mybuffer:getfloat64(4) --returns -3.14159 +@end verbatim +@end example + +The "get" functions of buffers can be found on the base object returned +from @code{require("bolt")} and can be used on either strings or +buffers. For example, @ref{buffer-getuint32,,buffer:getuint32} is the +same as @ref{functions-buffergetuint32,,bolt.buffergetuint32}, except +that in the latter case, the buffer or string needs to be passed +explicitly as the first param. The buffer's "set" functions aren't +available by that method because strings are considered read-only. + +@example lua +@verbatim +local mybuffer = bolt.createbuffer(4) +mybuffer:setuint32(0, 123) +local num1 = mybuffer:getuint32(0) --returns 123 +local num2 = bolt.buffergetfloat64(mybuffer, 0) --same function as above +@end verbatim +@end example -@node buffer-writeinteger -@subsection writeinteger +All functions in the buffer API are bounds-checked and will call +@code{error()} if the buffer size is exceeded, or if the given offset is +negative. However there are no limitations on memory alignment. + +@example lua +@verbatim +local mybuffer = bolt.createbuffer(16) +mybuffer:setuin64(3, 123) --fine +mybuffer:setuin64(17, 0) --error (writing out of bounds) +@end verbatim +@end example + +Endianness is always native. Values will be truncated as necessary using +C's type casts. + +@node buffer-getint8 +@subsection getint8 + +Reads a single byte from the buffer at the given offset and returns it +as a signed integer. @xref{objects-buffer,,Buffer objects} for more on +the buffer API. + +@example lua +@verbatim +local num = mybuffer:getint8(myoffset) +@end verbatim +@end example + +@node buffer-getint16 +@subsection getint16 + +Reads a two-byte value from the buffer at the given offset and returns +it as a signed integer. @xref{objects-buffer,,Buffer objects} for more +on the buffer API. + +@example lua +@verbatim +local num = mybuffer:getint16(myoffset) +@end verbatim +@end example + +@node buffer-getint32 +@subsection getint32 + +Reads a four-byte value from the buffer at the given offset and returns +it as a signed integer. @xref{objects-buffer,,Buffer objects} for more +on the buffer API. + +@example lua +@verbatim +local num = mybuffer:getint32(myoffset) +@end verbatim +@end example + +@node buffer-getint64 +@subsection getint64 + +Reads an eight-byte value from the buffer at the given offset and +returns it as a signed integer. @xref{objects-buffer,,Buffer objects} +for more on the buffer API. + +@example lua +@verbatim +local num = mybuffer:getint64(myoffset) +@end verbatim +@end example + +@node buffer-getuint8 +@subsection getuint8 + +Reads a single byte from the buffer at the given offset and returns it +as an unsigned integer. @xref{objects-buffer,,Buffer objects} for more +on the buffer API. + +@example lua +@verbatim +local num = mybuffer:getuint8(myoffset) +@end verbatim +@end example + +@node buffer-getuint16 +@subsection getuint16 + +Reads a two-byte value from the buffer at the given offset and returns +it as an unsigned integer. @xref{objects-buffer,,Buffer objects} for +more on the buffer API. + +@example lua +@verbatim +local num = mybuffer:getuint16(myoffset) +@end verbatim +@end example + +@node buffer-getuint32 +@subsection getuint32 + +Reads a four-byte value from the buffer at the given offset and returns +it as an unsigned integer. @xref{objects-buffer,,Buffer objects} for +more on the buffer API. + +@example lua +@verbatim +local num = mybuffer:getuint32(myoffset) +@end verbatim +@end example + +@node buffer-getuint64 +@subsection getuint64 + +Reads an eight-byte value from the buffer at the given offset and +returns it as an unsigned integer. @xref{objects-buffer,,Buffer objects} +for more on the buffer API. + +@example lua +@verbatim +local num = mybuffer:getuint64(myoffset) +@end verbatim +@end example + +@node buffer-getfloat32 +@subsection getfloat32 + +Reads a four-byte IEEE floating point value from the given offset and +returns it as a number. @xref{objects-buffer,,Buffer objects} for more +on the buffer API. + +@example lua +@verbatim +local num = mybuffer:getfloat32(myoffset) +@end verbatim +@end example + +@node buffer-getfloat64 +@subsection getfloat64 + +Reads an eight-byte IEEE floating point value from the given offset and +returns it as a number. @xref{objects-buffer,,Buffer objects} for more +on the buffer API. + +@example lua +@verbatim +local num = mybuffer:getfloat64(myoffset) +@end verbatim +@end example + +@node buffer-setint8 +@subsection setint8 + +Writes a single byte into the buffer at the given offset. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +mybuffer:setint8(myoffset, myvalue) +@end verbatim +@end example + +@node buffer-setint16 +@subsection setint16 + +Writes a two-byte value into the buffer at the given offset. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +mybuffer:setint16(myoffset, myvalue) +@end verbatim +@end example + +@node buffer-setint32 +@subsection setint32 + +Writes a four-byte value into the buffer at the given offset. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +mybuffer:setint32(myoffset, myvalue) +@end verbatim +@end example + +@node buffer-setint64 +@subsection setint64 + +Writes an eight-byte value into the buffer at the given offset. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +mybuffer:setint64(myoffset, myvalue) +@end verbatim +@end example + +@node buffer-setuint8 +@subsection setuint8 + +Writes a single unsigned byte into the buffer at the given offset. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +mybuffer:setuint8(myoffset, myvalue) +@end verbatim +@end example + +@node buffer-setuint16 +@subsection setuint16 + +Writes a two-byte unsigned value into the buffer at the given offset. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +mybuffer:setuint16(myoffset, myvalue) +@end verbatim +@end example + +@node buffer-setuint32 +@subsection setuint32 + +Writes a four-byte unsigned value into the buffer at the given offset. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +mybuffer:setuint32(myoffset, myvalue) +@end verbatim +@end example + +@node buffer-setuint64 +@subsection setuint64 + +Writes an eight-byte unsigned value into the buffer at the given offset. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. + +@example lua +@verbatim +mybuffer:setuint64(myoffset, myvalue) +@end verbatim +@end example -Writes an integer into the buffer. The first parameter is the integer to -write, the second is the offset into the buffer where the first byte -should be written, and the third is the number of bytes the integer will -be truncated to. The integer will be written in little-endian. +@node buffer-setfloat32 +@subsection setfloat32 -The following example would result in the first byte of the buffer being -0x39 and the second byte being 0x5. +Writes a number into the buffer at the given offset, as a four-byte IEEE +floatint point value. @xref{objects-buffer,,Buffer objects} for more on +the buffer API. @example lua @verbatim -mybuffer:writeinteger(1337, 0, 2) +mybuffer:setfloat32(myoffset, myvalue) @end verbatim @end example -@node buffer-writenumber -@subsection writenumber +@node buffer-setfloat64 +@subsection setfloat64 -Writes a number into the buffer. The first parameter is the number to -write, and the second is the offset into the buffer where the first byte -should be written. The number will be written as a native-endian, -8-byte, double-precision floating point value. +Writes a number into the buffer at the given offset, as an eight-byte +IEEE floatint point value. @xref{objects-buffer,,Buffer objects} for +more on the buffer API. @example lua @verbatim -mybuffer:writeinteger(1.5, 0) +mybuffer:setfloat64(myoffset, myvalue) @end verbatim @end example -@node buffer-writestring -@subsection writestring +@node buffer-setstring +@subsection setstring -Writes a string into the buffer. The first parameter is the string and -the second is the offset into the buffer where the first byte should be -written. The full length of the string will be copied. +Writes a string into the buffer at the given offset. The entire string +will be copied. @xref{objects-buffer,,Buffer objects} for more on the +buffer API. @example lua @verbatim -mybuffer:writestring("my new buffer contents", 0) +mybuffer:setstring(myoffset, mystring) @end verbatim @end example -@node buffer-writebuffer -@subsection writebuffer +@node buffer-setbuffer +@subsection setbuffer -Writes the contents of another buffer into this buffer. The first -parameter is the buffer to be copied from, and the second is the offset -into this buffer where the first byte should be written. The full length -of the source buffer will be copied. +Writes the contents of another buffer into this buffer at the given +offset. The entire contents of the source buffer will be copied. +@xref{objects-buffer,,Buffer objects} for more on the buffer API. @example lua @verbatim -mybuffer:writebuffer(myotherbuffer, 0) +mybuffer:setstring(myoffset, mystring) @end verbatim @end example diff --git a/src/library/plugin/plugin_api.c b/src/library/plugin/plugin_api.c index 37bbbf2..502d46d 100644 --- a/src/library/plugin/plugin_api.c +++ b/src/library/plugin/plugin_api.c @@ -19,6 +19,11 @@ #define API_VERSION_MAJOR 1 #define API_VERSION_MINOR 0 +struct FixedBuffer { + void* data; + size_t size; +}; + static void set_handler(lua_State* state, const char* regname, uint64_t window_id, int ev) { lua_getfield(state, LUA_REGISTRYINDEX, regname); /*stack: window table*/ \ lua_pushinteger(state, window_id); /*stack: window table, window id*/ \ @@ -100,6 +105,70 @@ static int buffer_gc(lua_State* state) { return 0; } +/* macros that generate handlers for Buffer objects */ + +#define DEFBUFFERINTERNAL(TYPE, FNAME, LUATYPE) \ +static TYPE internal_buffer_get##FNAME(lua_State* state, const void* data, size_t data_size, long offset) { \ + TYPE ret; \ + if (offset < 0 || (offset + sizeof(TYPE)) > data_size) { \ + lua_pushfstring(state, "buffer get" #FNAME ": out-of-bounds read (buffer length %lu, reading at %li)", data_size, offset); \ + lua_error(state); \ + } \ + memcpy(&ret, (uint8_t*)data + offset, sizeof ret); \ + return ret; \ +} \ +static void internal_buffer_set##FNAME(lua_State* state, void* data, size_t data_size, long offset, TYPE value) { \ + if (offset < 0 || (offset + sizeof(TYPE)) > data_size) { \ + lua_pushfstring(state, "buffer set" #FNAME ": out-of-bounds write (buffer length %lu, writing at %li)", data_size, offset); \ + lua_error(state); \ + } \ + memcpy((uint8_t*)data + offset, &value, sizeof value); \ +} \ + +#define DEFBUFFERINTERNAL_1BYTE(TYPE, FNAME, LUATYPE) \ +static TYPE internal_buffer_get##FNAME(lua_State* state, const void* data, size_t data_size, long offset) { \ + if (offset < 0 || offset >= data_size) { \ + lua_pushfstring(state, "buffer get" #FNAME ": out-of-bounds read (buffer length %lu, reading at %li)", data_size, offset); \ + lua_error(state); \ + } \ + return ((TYPE*)data)[offset]; \ +} \ +static void internal_buffer_set##FNAME(lua_State* state, void* data, size_t data_size, long offset, TYPE value) { \ + if (offset < 0 || offset >= data_size) { \ + lua_pushfstring(state, "buffer set" #FNAME ": out-of-bounds write (buffer length %lu, writing at %li)", data_size, offset); \ + lua_error(state); \ + } \ + ((TYPE*)data)[offset] = value; \ +} + +#define DEFBUFFERAPI(TYPE, FNAME, LUATYPE) \ +static int api_bufferget##FNAME(lua_State* state) { \ + size_t data_length; \ + const void* data; \ + get_binary_data(state, 1, &data, &data_length); \ + const long offset = luaL_checklong(state, 2); \ + const TYPE ret = internal_buffer_get##FNAME(state, data, data_length, offset); \ + lua_push##LUATYPE(state, ret); \ + return 1; \ +} \ +static int api_buffer_get##FNAME(lua_State* state) { \ + const struct FixedBuffer* buffer = require_self_userdata(state, "get" #FNAME); \ + const long offset = luaL_checklong(state, 2); \ + const TYPE ret = internal_buffer_get##FNAME(state, buffer->data, buffer->size, offset); \ + lua_push##LUATYPE(state, ret); \ + return 1; \ +} \ +static int api_buffer_set##FNAME(lua_State* state) { \ + const struct FixedBuffer* buffer = require_self_userdata(state, "set" #FNAME); \ + const long offset = luaL_checklong(state, 2); \ + const TYPE value = (TYPE)luaL_check##LUATYPE(state, 3); \ + internal_buffer_set##FNAME(state, buffer->data, buffer->size, offset, value); \ + return 0; \ +} + +#define DEFBUFFER(TYPE, FNAME, LUATYPE) DEFBUFFERINTERNAL(TYPE, FNAME, LUATYPE) DEFBUFFERAPI(TYPE, FNAME, LUATYPE) +#define DEFBUFFER_1BYTE(TYPE, FNAME, LUATYPE) DEFBUFFERINTERNAL_1BYTE(TYPE, FNAME, LUATYPE) DEFBUFFERAPI(TYPE, FNAME, LUATYPE) + /* API definitions start here */ DEFINE_CALLBACK(swapbuffers) @@ -554,7 +623,7 @@ static int api_point(lua_State* state) { static int api_createbuffer(lua_State* state) { const long size = luaL_checklong(state, 1); struct FixedBuffer* buffer = lua_newuserdata(state, sizeof(struct FixedBuffer)); - buffer->data = malloc(size); + buffer->data = calloc(size, 1); if (!buffer->data) { lua_pushfstring(state, "createbuffer: heap error, failed to allocate %i bytes", size); lua_error(state); @@ -1303,40 +1372,39 @@ static int api_embeddedbrowser_showdevtools(lua_State* state) { return 0; } -static int api_buffer_writeinteger(lua_State* state) { - const struct FixedBuffer* buffer = require_self_userdata(state, "writeinteger"); - const uint64_t value = (uint64_t)luaL_checklong(state, 2); - const long offset = luaL_checklong(state, 3); - const int width = luaL_checkint(state, 4); - for (size_t i = 0; i < width; i += 1) { - const uint8_t b = (uint8_t)((value >> (8 * i)) & 0xFF); - *((uint8_t*)buffer->data + offset + i) = b; - } - return 0; -} - -static int api_buffer_writenumber(lua_State* state) { - const struct FixedBuffer* buffer = require_self_userdata(state, "writenumber"); - const double value = (double)luaL_checknumber(state, 2); - const long offset = luaL_checklong(state, 3); - memcpy((uint8_t*)buffer->data + offset, &value, sizeof(value)); - return 0; -} - -static int api_buffer_writestring(lua_State* state) { - const struct FixedBuffer* buffer = require_self_userdata(state, "writestring"); +DEFBUFFER(float, float32, number) +DEFBUFFER(double, float64, number) +DEFBUFFER_1BYTE(int8_t, int8, integer) +DEFBUFFER(int16_t, int16, integer) +DEFBUFFER(int32_t, int32, integer) +DEFBUFFER(int64_t, int64, integer) +DEFBUFFER_1BYTE(uint8_t, uint8, integer) +DEFBUFFER(uint16_t, uint16, integer) +DEFBUFFER(uint32_t, uint32, integer) +DEFBUFFER(uint64_t, uint64, integer) + +static int api_buffer_setstring(lua_State* state) { + struct FixedBuffer* buffer = require_self_userdata(state, "setstring"); + const long offset = luaL_checklong(state, 2); size_t size; - const void* data = luaL_checklstring(state, 2, &size); - const long offset = luaL_checklong(state, 3); - memcpy((uint8_t*)buffer->data + offset, data, size); + const void* data = luaL_checklstring(state, 3, &size); + if (offset < 0 || (offset + size) > buffer->size) { + lua_pushfstring(state, "buffer setstring: out-of-bounds write (buffer length %lu, writing %lu bytes at %li)", buffer->size, size, offset); + lua_error(state); + } + memcpy(buffer->data + offset, data, size); return 0; } -static int api_buffer_writebuffer(lua_State* state) { - const struct FixedBuffer* buffer = require_self_userdata(state, "writebuffer"); - const struct FixedBuffer* source = require_userdata(state, 2, "writebuffer"); - const long offset = luaL_checklong(state, 3); - memcpy((uint8_t*)buffer->data + offset, source->data, source->size); +static int api_buffer_setbuffer(lua_State* state) { + struct FixedBuffer* buffer = require_self_userdata(state, "setbuffer"); + const long offset = luaL_checklong(state, 2); + const struct FixedBuffer* srcbuffer = require_userdata(state, 3, "setbuffer"); + if (offset < 0 || (offset + srcbuffer->size) > buffer->size) { + lua_pushfstring(state, "buffer setbuffer: out-of-bounds write (buffer length %lu, writing %lu bytes at %li)", buffer->size, srcbuffer->size, offset); + lua_error(state); + } + memcpy(buffer->data + offset, srcbuffer->data, srcbuffer->size); return 0; } @@ -1383,6 +1451,7 @@ static struct ApiFuncTemplate bolt_functions[] = { BOLTFUNC(loadfile), BOLTFUNC(loadconfig), BOLTFUNC(saveconfig), + BOLTFUNC(onrender2d), BOLTFUNC(onrender3d), BOLTFUNC(onminimap), @@ -1391,6 +1460,7 @@ static struct ApiFuncTemplate bolt_functions[] = { BOLTFUNC(onmousebutton), BOLTFUNC(onmousebuttonup), BOLTFUNC(onscroll), + BOLTFUNC(createsurface), BOLTFUNC(createsurfacefromrgba), BOLTFUNC(createsurfacefrompng), @@ -1399,6 +1469,17 @@ static struct ApiFuncTemplate bolt_functions[] = { BOLTFUNC(createembeddedbrowser), BOLTFUNC(point), BOLTFUNC(createbuffer), + + BOLTFUNC(buffergetint8), + BOLTFUNC(buffergetint16), + BOLTFUNC(buffergetint32), + BOLTFUNC(buffergetint64), + BOLTFUNC(buffergetuint8), + BOLTFUNC(buffergetuint16), + BOLTFUNC(buffergetuint32), + BOLTFUNC(buffergetuint64), + BOLTFUNC(buffergetfloat32), + BOLTFUNC(buffergetfloat64), }; #undef BOLTFUNC @@ -1459,10 +1540,28 @@ static struct ApiFuncTemplate transform_functions[] = { }; static struct ApiFuncTemplate buffer_functions[] = { - BOLTFUNC(writeinteger, buffer), - BOLTFUNC(writenumber, buffer), - BOLTFUNC(writestring, buffer), - BOLTFUNC(writebuffer, buffer), + BOLTFUNC(getint8, buffer), + BOLTFUNC(getint16, buffer), + BOLTFUNC(getint32, buffer), + BOLTFUNC(getint64, buffer), + BOLTFUNC(getuint8, buffer), + BOLTFUNC(getuint16, buffer), + BOLTFUNC(getuint32, buffer), + BOLTFUNC(getuint64, buffer), + BOLTFUNC(getfloat32, buffer), + BOLTFUNC(getfloat64, buffer), + BOLTFUNC(setint8, buffer), + BOLTFUNC(setint16, buffer), + BOLTFUNC(setint32, buffer), + BOLTFUNC(setint64, buffer), + BOLTFUNC(setuint8, buffer), + BOLTFUNC(setuint16, buffer), + BOLTFUNC(setuint32, buffer), + BOLTFUNC(setuint64, buffer), + BOLTFUNC(setfloat32, buffer), + BOLTFUNC(setfloat64, buffer), + BOLTFUNC(setstring, buffer), + BOLTFUNC(setbuffer, buffer), }; // zero-size type causes ICE in MSVC diff --git a/src/library/plugin/plugin_api.h b/src/library/plugin/plugin_api.h index 5267891..bed49e3 100644 --- a/src/library/plugin/plugin_api.h +++ b/src/library/plugin/plugin_api.h @@ -25,11 +25,6 @@ enum { BROWSER_EVENT_ENUM_SIZE, // last member of enum }; -struct FixedBuffer { - void* data; - size_t size; -}; - struct ExternalBrowser { uint64_t id; uint64_t plugin_id;