From: John L. <jla...@gm...> - 2006-05-18 02:59:12
|
In going through the the interface files I've noticed that there are a few naming inconsistencies for C++ overloaded functions and constructors. Typically they have the names that wxPython uses (where noted in the docs) and for the most part are fine, but... Since we can overloaded function in wxLua directly (usually) we don't actually need to give them unique names, however they need some sort of name for the C function and might as well be accessible in wxLua using that name as well as the overloaded way. Suggested rules for renaming: 1) Most "commonly used" or default function gets actual name 2) Function names use the original name + [With][Data type] ex. Append(int n), Append(wxString s) -> AppendString(s) ex. Append(int n), Append(int n, Stuff s) -> AppendWithStuff(n, s) 3) Class constructors start with the ClassName + From[Data type] Default constructors are always wxClassNameDefault() Copy constructors are always wxClassNameCopy(const wxClassName& c) Obviously there will be exceptions or cases where the name may sound awkward, but the number of these will be small. Some examples of the inconsistencies I'm talking about: -------------------------- These member functions will be out of alphabetical order and may be difficult to directly associate with the original function without looking through the docs. It is true that the wxPython ones may be more syntactically "correct", but I think that directly associating them with the original function is more compelling. wxListCtrl wxPython naming (currently wxLua uses this) InsertItem(item) Inserts an item using a wxListItem. InsertStringItem(index, label) Inserts a string item. InsertImageItem(index, imageIndex) Inserts an image item. InsertImageStringItem(index, label, imageIndex) Insert an image/string = item. I would prefer InsertItem(item) Inserts an item using a wxListItem. InsertItemString(index, label) Inserts a string item. InsertItemImage(index, imageIndex) Inserts an image item. InsertItemImageString(index, label, imageIndex) Insert an image/string = item. --------------------------- Some constructor examples, currently it's this way wxColour(const unsigned char red, const unsigned char green, const unsigned char blue) wxNamedColour(const wxString& colourNname) // python compatibility wxColourCopy(const wxColour& colour) I would prefer wxColour(const unsigned char red, const unsigned char green, const unsigned char blue) wxColourFromString(const wxString& colourNname) // python compatibility wxColourCopy(const wxColour& colour) other examples %constructor wxDefaultBitmap() %win wxBitmap(void * data, int type, int width, int height, int depth = =3D -1) %constructor wxBitmapCopy(const wxBitmap& bitmap) %constructor wxEmptyBitmap( int width, int height, int depth =3D -1) %constructor wxBitmapFromFile( const wxString& name, long type) %constructor wxBitmapFromXPMData(const char **data) %wxchkver23 %constructor wxBitmapFromImage(const wxImage &image, int depth =3D -1) and wxImage(const wxImage& image) %constructor wxDefaultImage() %wxchkver23 %constructor wxImageFromBitmap(const wxBitmap& bitmap) %constructor wxEmptyImage(int width, int height, bool clear=3Dtrue) %constructor wxImageFromData(int width, int height, unsigned char* data, bool static_data =3D false) %constructor wxImageFromFile(const wxString& name, long type =3D wxBITMAP_TYPE_ANY) Hopefully you can see that the naming right now can be fairly arbitrary, where the default wxImage constructor makes a copy? wxEmptyImage? wxDefaultImage? The default for wxBitmap takes the bitmap data itself, but only for MSW, how useful is that? I would like to normalize all of these, obviously breaking compatibility, but better sooner than later. :) There's probably about 2 dozen of them to change. Regards, John Labenski |