|
From: Steve K. <ha...@ya...> - 2006-07-15 23:08:56
|
Hi,
I found a bug in method GetAllFiles(). The overwrite function pass the wrong parameters positions.
static int LUACALL wxLua_wxDir_GetAllFiles(lua_State *L)
{
wxLuaState wxlState(L);
unsigned int returns;
// get number of arguments
int argCount = lua_gettop(L);
// int flags = wxDIR_DEFAULT
// Wrong code follow. SHould be 5 not 4 as the first param is luastate
// int flags = (argCount >= 4 ? (int)wxlState.GetNumberType(4) : wxDIR_DEFAULT);
int flags = (argCount >= 5 ? (int)wxlState.GetNumberType(5) : wxDIR_DEFAULT);
// const wxString& filespec = ""
// 3 is wrong, should be 4
wxString filespec = (argCount >= 4 ? lua2wx(wxlState.GetStringType(4)) : wxString(wxT("")));
// wxArrayString *files
wxArrayString files;
// const wxString& dirname
wxString dirname = lua2wx(wxlState.GetStringType(2));
// call GetAllFiles
returns = wxDir::GetAllFiles(dirname, &files, filespec, flags);
// push the result number
lua_pushnumber(L, returns);
wxlState.PushwxArrayStringTable(files);
// return the number of parameters
return 2;
}
Cheers,
S.KIEU
---------------------------------
Do you Yahoo!?
Yahoo! Personals: It's free to check out our great singles! |
|
From: John L. <jla...@gm...> - 2006-07-18 22:30:47
|
On 7/15/06, Steve Kieu <ha...@ya...> wrote:
>
> I found a bug in method GetAllFiles(). The overwrite function pass the wrong
> parameters positions.
I think it's ok. This is one of the overridden functions where the
function call doesn't take the input wxArrayString, but rather returns
the array as a lua table.
// %override [unsigned int, lua string table] wxDir::GetAllFiles(const
wxString& dirname, const wxString& filespec = "", int flags =
wxDIR_DEFAULT)
I have been wondering if it might be simpler to use wxArrayString for
these cases rather than returning a lua table of strings. You can
always use the added function wxArrayString:ToLuaTable() to get it as
a table if you like.
What do you think? On one hand it's nice to use the native lua table
for arrays like this, but on the other hand the bindings are easier
with fewer overrides and confusion with the wxWidgets docs if we keep
it as a wxArrayString.
Regards,
John Labenski
> static int LUACALL wxLua_wxDir_GetAllFiles(lua_State *L)
> {
> wxLuaState wxlState(L);
> unsigned int returns;
> // get number of arguments
> int argCount = lua_gettop(L);
> // int flags = wxDIR_DEFAULT
>
> // Wrong code follow. SHould be 5 not 4 as the first param is luastate
>
> // int flags = (argCount >= 4 ? (int)wxlState.GetNumberType(4) :
> wxDIR_DEFAULT);
>
> int flags = (argCount >= 5 ? (int)wxlState.GetNumberType(5) :
> wxDIR_DEFAULT);
>
> // const wxString& filespec = ""
>
> // 3 is wrong, should be 4
>
> wxString filespec = (argCount >= 4 ? lua2wx(wxlState.GetStringType(4)) :
> wxString(wxT("")));
> // wxArrayString *files
> wxArrayString files;
> // const wxString& dirname
> wxString dirname = lua2wx(wxlState.GetStringType(2));
> // call GetAllFiles
> returns = wxDir::GetAllFiles(dirname, &files, filespec, flags);
> // push the result number
> lua_pushnumber(L, returns);
> wxlState.PushwxArrayStringTable(files);
> // return the number of parameters
> return 2;
> }
>
>
> Cheers,
>
>
>
>
> S.KIEU
>
> ________________________________
> Do you Yahoo!?
> Yahoo! Personals: It's free to check out our great singles!
>
>
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>
>
> _______________________________________________
> Wxlua-users mailing list
> Wxl...@li...
> https://lists.sourceforge.net/lists/listinfo/wxlua-users
>
>
>
|
|
From: Steve K. <ha...@ya...> - 2006-07-19 22:31:14
|
I think it's ok. This is one of the overridden functions where the function call doesn't take the input wxArrayString, but rather returns the array as a lua table. // %override [unsigned int, lua string table] wxDir::GetAllFiles(const wxString& dirname, const wxString& filespec = "", int flags = wxDIR_DEFAULT) My apology, it is just that I read the un commented line %wxchkver23 static unsigned int GetAllFiles(const wxString& dirname, wxArrayString *files, const wxString& filespec = "", int flags = wxDIR_DEFAULT) and still think that the method is still using *files its argument so I still pass dummy args into it and it failled, then whining about it :-). I should look at the override line . I have been wondering if it might be simpler to use wxArrayString for these cases rather than returning a lua table of strings. You can always use the added function wxArrayString:ToLuaTable() to get it as a table if you like. What do you think? On one hand it's nice to use the native lua table for arrays like this, but on the other hand the bindings are easier with fewer overrides and confusion with the wxWidgets docs if we keep it as a wxArrayString. I personally prefer lua table; as I can get it out, process it using lua code etc. It is just much easier to use lua then , my memory is not good, and lots of time I have to open wx docs to find a method name etc.. but I can not forget : for i,v in pairs(bla) do :-) end Cheers, S.KIEU --------------------------------- Do you Yahoo!? Yahoo! Personals: It's free to check out our great singles! |
|
From: John L. <jla...@gm...> - 2006-07-20 16:03:00
|
On 7/19/06, Steve Kieu <ha...@ya...> wrote:
>
> I think it's ok. This is one of the overridden functions where the
> function call doesn't take the input wxArrayString, but rather returns
> the array as a lua table.
>
> // %override [unsigned int, lua string table] wxDir::GetAllFiles(const
> wxString& dirname, const wxString& filespec = "", int flags =
> wxDIR_DEFAULT)
>
> My apology, it is just that I read the un commented line
>
> %wxchkver23 static unsigned int GetAllFiles(const wxString& dirname,
> wxArrayString *files, const wxString& filespec = "", int flags =
> wxDIR_DEFAULT)
>
> and still think that the method is still using *files its argument so I
> still pass dummy args into it and it failled, then whining about it :-). I
> should look at the override line .
The uncommented line is written exactly as the C++ function is to make
it easy to check that the parameters are the same when the files are
updated to a newer version of wxWidgets. I've tried to document all
the %override functions in the .i files appropriately.
> What do you think? On one hand it's nice to use the native lua table
> for arrays like this, but on the other hand the bindings are easier
> with fewer overrides and confusion with the wxWidgets docs if we keep
> it as a wxArrayString.
> I personally prefer lua table; as I can get it out, process it using lua
> code etc. It is just much easier to use lua then , my memory is not good,
> and lots of time I have to open wx docs to find a method name etc.. but I
> can not forget :
> for i,v in pairs(bla) do :-) end
Ok then we'll keep it this way. There are only a few of these so it's
not a big deal to maintain them.
Regards,
John Labenski
|