Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of wxMemoryBuffer is improved to avoid unnecessary dependence #64

Merged
merged 1 commit into from
Apr 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions wxLua/bindings/wxwidgets/wxbase_rules.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ wxLuaBinding_class_implementation =
p_wxluatype_wxSortedArrayString = &wxluatype_wxSortedArrayString;
p_wxluatype_wxArrayInt = &wxluatype_wxArrayInt;
p_wxluatype_wxArrayDouble = &wxluatype_wxArrayDouble;
p_wxluatype_wxMemoryBuffer = &wxluatype_wxMemoryBuffer;

return ret;
}
Expand Down
1 change: 1 addition & 0 deletions wxLua/modules/wxbind/src/wxbase_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3138,6 +3138,7 @@ bool wxLuaBinding_wxbase::RegisterBinding(const wxLuaState& wxlState)
p_wxluatype_wxSortedArrayString = &wxluatype_wxSortedArrayString;
p_wxluatype_wxArrayInt = &wxluatype_wxArrayInt;
p_wxluatype_wxArrayDouble = &wxluatype_wxArrayDouble;
p_wxluatype_wxMemoryBuffer = &wxluatype_wxMemoryBuffer;

return ret;
}
Expand Down
1 change: 1 addition & 0 deletions wxLua/modules/wxlua/wxlbind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ int* p_wxluatype_wxArrayString = &wxluatype_TUNKNOWN;
int* p_wxluatype_wxSortedArrayString = &wxluatype_TUNKNOWN;
int* p_wxluatype_wxArrayInt = &wxluatype_TUNKNOWN;
int* p_wxluatype_wxArrayDouble = &wxluatype_TUNKNOWN;
int* p_wxluatype_wxMemoryBuffer = &wxluatype_TUNKNOWN;
int* p_wxluatype_wxPoint = &wxluatype_TUNKNOWN;
int* p_wxluatype_wxPoint2DDouble = &wxluatype_TUNKNOWN;

Expand Down
1 change: 1 addition & 0 deletions wxLua/modules/wxlua/wxlbind.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ extern WXDLLIMPEXP_DATA_WXLUA(int*) p_wxluatype_wxArrayString; // wxLua type for
extern WXDLLIMPEXP_DATA_WXLUA(int*) p_wxluatype_wxSortedArrayString; // wxLua type for wxSortedArrayString
extern WXDLLIMPEXP_DATA_WXLUA(int*) p_wxluatype_wxArrayInt; // wxLua type for wxArrayInt
extern WXDLLIMPEXP_DATA_WXLUA(int*) p_wxluatype_wxArrayDouble; // wxLua type for wxArrayDouble
extern WXDLLIMPEXP_DATA_WXLUA(int*) p_wxluatype_wxMemoryBuffer; // wxLua type for wxMemoryBuffer
extern WXDLLIMPEXP_DATA_WXLUA(int*) p_wxluatype_wxPoint; // wxLua type for wxPoint
extern WXDLLIMPEXP_DATA_WXLUA(int*) p_wxluatype_wxPoint2DDouble; // wxLua type for wxPoint2DDouble

Expand Down
9 changes: 3 additions & 6 deletions wxLua/modules/wxlua/wxllua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,15 +982,13 @@ const wxLuaBindClass* LUACALL wxluaT_getclass(lua_State* L, const char* class_na

bool wxluaT_isuserdatatype(lua_State* L, int stack_idx, int wxl_type)
{
extern int wxluatype_wxMemoryBuffer;

int stack_type = wxluaT_type(L, stack_idx);

if (wxlua_iswxuserdatatype(stack_type) &&
((wxluatype_NULL == stack_type) || // FIXME, how to check when NULL is valid or not?
((wxl_type == WXLUA_TSTRING) &&
((wxluaT_isderivedtype(L, stack_type, *p_wxluatype_wxString) >= 0) ||
(wxluaT_isderivedtype(L, stack_type, wxluatype_wxMemoryBuffer) >= 0))) ||
(wxluaT_isderivedtype(L, stack_type, *p_wxluatype_wxMemoryBuffer) >= 0))) ||
(wxluaT_isderivedtype(L, stack_type, wxl_type) >= 0)))
return true;

Expand Down Expand Up @@ -1407,7 +1405,6 @@ const char* LUACALL wxlua_getstringtypelen(lua_State *L, int stack_idx, size_t *
return lua_tolstring(L, stack_idx, len);
else if (wxlua_iswxuserdata(L, stack_idx))
{
extern int wxluatype_wxMemoryBuffer;
int stack_type = wxluaT_type(L, stack_idx);

if (wxluaT_isderivedtype(L, stack_type, *p_wxluatype_wxString) >= 0)
Expand All @@ -1419,9 +1416,9 @@ const char* LUACALL wxlua_getstringtypelen(lua_State *L, int stack_idx, size_t *
*len = strlen(retp);
return retp;
}
else if (wxluaT_isderivedtype(L, stack_type, wxluatype_wxMemoryBuffer) >= 0)
else if (wxluaT_isderivedtype(L, stack_type, *p_wxluatype_wxMemoryBuffer) >= 0)
{
wxMemoryBuffer * wxmem = (wxMemoryBuffer *)wxluaT_getuserdatatype(L, stack_idx, wxluatype_wxMemoryBuffer);
wxMemoryBuffer * wxmem = (wxMemoryBuffer *)wxluaT_getuserdatatype(L, stack_idx, *p_wxluatype_wxMemoryBuffer);
const char *datap = (const char *)wxmem->GetData();
if (len != NULL)
*len = wxmem->GetDataLen();
Expand Down