Skip to content

Commit d3cb8fc

Browse files
committed
Renamed wxMemoryBuffer.Byte method to GetByte for consistency (#49).
1 parent 9e5cd5d commit d3cb8fc

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

wxLua/bindings/wxwidgets/wxbase_data.i

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ public:
534534

535535
// wxLua specific
536536
// Get the data at the given index. If length > 1, then multiple values are returned.
537-
unsigned char Byte(int index, size_t length = 1);
537+
unsigned char GetByte(int index, size_t length = 1);
538538
// Set the data at the given index. If multiple data are given, the following values are
539539
// set at the subsequent positions. Data length and buffer size are updated if necessary.
540540
void SetByte(int index, unsigned char data);

wxLua/bindings/wxwidgets/wxbase_override.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -711,9 +711,9 @@ static int LUACALL wxLua_wxArrayString_ToLuaTable(lua_State *L)
711711
}
712712
%end
713713

714-
%override wxLua_wxMemoryBuffer_Byte
715-
// unsigned char Byte(int index, size_t length = 1);
716-
static int LUACALL wxLua_wxMemoryBuffer_Byte(lua_State *L)
714+
%override wxLua_wxMemoryBuffer_GetByte
715+
// unsigned char GetByte(int index, size_t length = 1);
716+
static int LUACALL wxLua_wxMemoryBuffer_GetByte(lua_State *L)
717717
{
718718
// int index
719719
int index = (int)wxlua_getnumbertype(L, 2);

wxLua/modules/wxbind/src/wxbase_data.cpp

+30-30
Original file line numberDiff line numberDiff line change
@@ -3642,35 +3642,6 @@ static int LUACALL wxLua_wxMemoryBuffer_AppendData(lua_State *L)
36423642
return 0;
36433643
}
36443644

3645-
static wxLuaArgType s_wxluatypeArray_wxLua_wxMemoryBuffer_Byte[] = { &wxluatype_wxMemoryBuffer, &wxluatype_TNUMBER, &wxluatype_TINTEGER, NULL };
3646-
static int LUACALL wxLua_wxMemoryBuffer_Byte(lua_State *L);
3647-
static wxLuaBindCFunc s_wxluafunc_wxLua_wxMemoryBuffer_Byte[1] = {{ wxLua_wxMemoryBuffer_Byte, WXLUAMETHOD_METHOD, 2, 3, s_wxluatypeArray_wxLua_wxMemoryBuffer_Byte }};
3648-
// %override wxLua_wxMemoryBuffer_Byte
3649-
// unsigned char Byte(int index, size_t length = 1);
3650-
static int LUACALL wxLua_wxMemoryBuffer_Byte(lua_State *L)
3651-
{
3652-
// int index
3653-
int index = (int)wxlua_getnumbertype(L, 2);
3654-
// get this
3655-
wxMemoryBuffer * self = (wxMemoryBuffer *)wxluaT_getuserdatatype(L, 1, wxluatype_wxMemoryBuffer);
3656-
// int length (optional)
3657-
int length = 1;
3658-
if (lua_gettop(L) >= 3)
3659-
length = (size_t)wxlua_getnumbertype(L, 3);
3660-
if (index + length > self->GetDataLen())
3661-
length = self->GetDataLen() - index;
3662-
if (index < 0 || length <= 0)
3663-
return 0;
3664-
int count = 0;
3665-
while (count < length) {
3666-
unsigned char returns = ((unsigned char *)(self->GetData()))[index + count];
3667-
lua_pushnumber(L, returns);
3668-
count++;
3669-
}
3670-
return length;
3671-
}
3672-
3673-
36743645

36753646
#if (wxCHECK_VERSION(2,9,4)) && (wxLUA_USE_wxMemoryBuffer)
36763647
static wxLuaArgType s_wxluatypeArray_wxLua_wxMemoryBuffer_Clear[] = { &wxluatype_wxMemoryBuffer, NULL };
@@ -3757,6 +3728,35 @@ if ((double)(lua_Integer)returns == (double)returns) {
37573728
return 1;
37583729
}
37593730

3731+
static wxLuaArgType s_wxluatypeArray_wxLua_wxMemoryBuffer_GetByte[] = { &wxluatype_wxMemoryBuffer, &wxluatype_TNUMBER, &wxluatype_TINTEGER, NULL };
3732+
static int LUACALL wxLua_wxMemoryBuffer_GetByte(lua_State *L);
3733+
static wxLuaBindCFunc s_wxluafunc_wxLua_wxMemoryBuffer_GetByte[1] = {{ wxLua_wxMemoryBuffer_GetByte, WXLUAMETHOD_METHOD, 2, 3, s_wxluatypeArray_wxLua_wxMemoryBuffer_GetByte }};
3734+
// %override wxLua_wxMemoryBuffer_GetByte
3735+
// unsigned char GetByte(int index, size_t length = 1);
3736+
static int LUACALL wxLua_wxMemoryBuffer_GetByte(lua_State *L)
3737+
{
3738+
// int index
3739+
int index = (int)wxlua_getnumbertype(L, 2);
3740+
// get this
3741+
wxMemoryBuffer * self = (wxMemoryBuffer *)wxluaT_getuserdatatype(L, 1, wxluatype_wxMemoryBuffer);
3742+
// int length (optional)
3743+
int length = 1;
3744+
if (lua_gettop(L) >= 3)
3745+
length = (size_t)wxlua_getnumbertype(L, 3);
3746+
if (index + length > self->GetDataLen())
3747+
length = self->GetDataLen() - index;
3748+
if (index < 0 || length <= 0)
3749+
return 0;
3750+
int count = 0;
3751+
while (count < length) {
3752+
unsigned char returns = ((unsigned char *)(self->GetData()))[index + count];
3753+
lua_pushnumber(L, returns);
3754+
count++;
3755+
}
3756+
return length;
3757+
}
3758+
3759+
37603760
static wxLuaArgType s_wxluatypeArray_wxLua_wxMemoryBuffer_GetData[] = { &wxluatype_wxMemoryBuffer, NULL };
37613761
static int LUACALL wxLua_wxMemoryBuffer_GetData(lua_State *L);
37623762
static wxLuaBindCFunc s_wxluafunc_wxLua_wxMemoryBuffer_GetData[1] = {{ wxLua_wxMemoryBuffer_GetData, WXLUAMETHOD_METHOD, 1, 1, s_wxluatypeArray_wxLua_wxMemoryBuffer_GetData }};
@@ -4008,7 +4008,6 @@ void wxLua_wxMemoryBuffer_delete_function(void** p)
40084008
wxLuaBindMethod wxMemoryBuffer_methods[] = {
40094009
{ "AppendByte", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxMemoryBuffer_AppendByte, 1, NULL },
40104010
{ "AppendData", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxMemoryBuffer_AppendData, 1, NULL },
4011-
{ "Byte", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxMemoryBuffer_Byte, 1, NULL },
40124011

40134012
#if (wxCHECK_VERSION(2,9,4)) && (wxLUA_USE_wxMemoryBuffer)
40144013
{ "Clear", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxMemoryBuffer_Clear, 1, NULL },
@@ -4017,6 +4016,7 @@ wxLuaBindMethod wxMemoryBuffer_methods[] = {
40174016
{ "Fill", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxMemoryBuffer_Fill, 1, NULL },
40184017
{ "GetAppendBuf", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxMemoryBuffer_GetAppendBuf, 1, NULL },
40194018
{ "GetBufSize", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxMemoryBuffer_GetBufSize, 1, NULL },
4019+
{ "GetByte", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxMemoryBuffer_GetByte, 1, NULL },
40204020
{ "GetData", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxMemoryBuffer_GetData, 1, NULL },
40214021
{ "GetDataLen", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxMemoryBuffer_GetDataLen, 1, NULL },
40224022
{ "GetWriteBuf", WXLUAMETHOD_METHOD, s_wxluafunc_wxLua_wxMemoryBuffer_GetWriteBuf, 1, NULL },

0 commit comments

Comments
 (0)