Re: The Euphoria IDE Project

new topic     » goto parent     » topic index » view thread      » older message » newer message
petelomax said...

I had a look this weekend at getting wxEuphoria to run on Phix, and I made some notes on the matter. My apologies if this isn't helpful.

It seems I would need to suck alot of complexity out of libwxeu.dll (C++) into wxeud.e, specifically defaults, reference counting, and delete routines. In short, libwxeu.dll/so should contain absolutely no knowledge whatsoever of underlying data structures, and hence be compatible with both OpenEu and Phix.

Routines must be called/defined with atoms/pointers (C_INT etc), rather than E_SEQUENCE/E_OBJECT/E_ATOM/E_INTEGER. The logic for defaulted parameters would need to be moved out of wxeu.cpp, so for example (simplified/untested) instead of:

I appreciate that with some 1,400 routines that may be a massive amount of work and I have no idea what impact it would have on performance, but it may lead to better errors, eg "type check error, caption is 0".

Actually Pete, you and I are on a similar page here. For the next major release of wxEuphoria, I am working on separating all functionality back out into namespaces that match the existing class structure of wxWidgets.

A few nice side-effect of this will be:

  • all default parameters would be part of the Euphoria code
  • custom types will allow type-checking on all wxWidgets controls
  • the API will more closely match native wxWidgets code (and wxPerl, wxPython, etc.)
  • you will only have to include the files necessary for the controls you use

Here's a chunk of an include file:

-- wxFrame.e 
namespace wxFrame 
 
-- wxFrame inherits from wxTopLevelWindow 
public include "wxeu/wxTopLevelWindow.e" 
 
constant wxFrame_Create = define_c_func( libwxeu, "wxFrame_Create", {C_POINTER,C_UINT,E_OBJECT,C_INT,C_INT,C_INT,C_INT,C_LONG,E_OBJECT}, C_POINTER ) 
constant wxFrame_IsTypeOf = define_c_func( libwxeu, "wxFrame_IsTypeOf", {C_POINTER}, C_UINT ) 
 
public type wxFrame( atom x ) 
    return c_func( wxFrame_IsTypeOf, {x} ) 
end type 
 
public function Create( wxWindow parent, integer id = -1, sequence text = "", integer x = -1, integer y = -1, integer width = -1, integer height = -1, atom flags = wxDEFAULT_FRAME_STYLE, sequence name = wxFrameNameStr ) 
    return c_func( wxFrame_Create, {parent, id, text, x, y, width, height, flags, name} ) 
end function 

Hopefully when I'm done, we'll be writing code like this:

-- demo.exw 
include "wxeu/wxFrame.e" 
include "wxeu/wxPanel.e" 
include "wxeu/wxStaticText.e" 
 
wxFrame frame1 = wxFrame:Create( 0, -1, "Demo" ) 
wxPanel panel1 = wxPanel:Create( frame1 ) 
wxStaticText staticText1 = wxStaticText:Create( panel1, -1, "Text" ) 
 
wxMain( wxFrame ) 
petelomax said...

Also, I don't really understand why it needs wxDeRefDS() etc; I can only assume that because it is using E_SEQUENCE; params gets incref'd and ends up in libwxeu.dll with a ref count >=2? Unless you do on-the-fly creation in wxeud.e then the actual deallocation/calling of any delete routine etc will occur not in libwxeu.dll but in exeud.e when "params" gets decref'd or when some callee variable drops out of scope.

Anyway, that's where I got, like I said don't know if that is of any interest or use.

The alternative would be to rewrite wxeu.cpp pretty much from scratch, but embed the knowledge of the underlying Phix data structures rather than those of OpenEu.

The calls to wxDeRefDS() are necessary to decrement the reference counter on Euphoria objects, which happens automatically in translated Euphoria code, but has to be done manually in our hand-coded C++ library. It's really just this simple macro...

#define wxDeRefDS(a) assert(DBL_PTR(a)->ref); --(DBL_PTR(a)->ref); 

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu