Re: Autogenerating wxEuphoria wrappers
- Posted by dcuny Dec 05, 2014
- 3676 views
OK, the prototype:
wxScrollBar(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSB_HORIZONTAL, const wxValidator& validator = wxDefaultValidator, const wxString& name = "scrollBar")
now generates:
{
int seq_len = ((s1_ptr)SEQ_PTR(parms))->length;
wxWindow parent = parent = (wxWindow*)get_int( parms, 1 );
wxWindowID id = id = (wxWindowID*)get_int( parms, 2 );
wxPoint pos = wxPoint( get_int( parms, 3 ), get_int( parms, 4 ) );
wxSize size = wxSize( get_int( parms, 5 ), get_int( parms, 6 ) );
int style = wxSB_HORIZONTAL;
if (seq_len >= 7) style = get_int( parms, 7 );
wxValidator validator = wxDefaultValidator;
if (seq_len >= 8) validator = (wxValidator*)get_int( parms, 8 );
wxString name = "scrollBar";
if (seq_len >= 9) name = get_string( parms, 9 );
wxDeRefDS( parms );
return BOX_INT( new wxScrollBar( parent, id, pos, size, style, validator, name ) );
}
So wxPoint and wxSize are automatically assumed to be integer pairs in constructors.
But I started looking through the code, and noticed how wxEuphoria handles polymorphism. In short, it doesn't seem to have a consistent approach. hit_test is a good example - the routine can be called from three different classes. So the code is basically:
{
wxObject * obj = (wxObject*)window;
if ( obj->IsKindOf( CLASSINFO(wxListCtrl) ) ) {
// handle wxListCtrl
} else if ( obj->IsKindOf( CLASSINFO(wxTreeCtrl) ) ) {
// handle wxTreeCtrl
} else if ( obj->IsKindOf( CLASSINFO(wxTextCtrl) ) ) {
// handle wxTextCtrl
}
return 0;
}
In contrast, sizer_calc_min prefixes the class name to the routine to make it unique.
The first approach is fine... assuming that all the calls to different class method have the same signature. If they don't... Well, you're screwed.
Is there a scheme here that I'm not seeing?
- David