1. wxEuphoria development
I've been getting more messages lately about unwrapped stuff in the
library. After the restructure, it's in some ways more difficult to
start using unwrapped routines. I've started beefing up parts of the
documentation that explains how to contribute and expand the library.
Below, I've pasted in what I've got so far. I'd appreciate any feedback
from people on how useful this is.
I realize that most people here don't use C++, but I'd like to emphasize
that it's really pretty straightforward to add wrappers for most wxWidgets
classes. If you look in the wx*.cpp files, you'll notice that most of them
are one-liners.
I try to include whatever requests I get from users, but it may be a while
before you see something usable (though you could see it quicker through
svn and building yourself). I'm considering posting bleeding edge releases
to the web page for testing and early access to pre-built binaries,
probably with an RSS feed to announce new uploads.
From the new docs:
Wrapping HOWTO
Wrapping additional functions is usually pretty easy. Take a look at both
wxeud.e and the *.cpp source files for some examples. Most of the wxEuphoria
C++ source code is made up of one-liners that call the appropriate wxWidgets
routine. Here are a few tips:
* Declare any pointers to wxWidgets objects as 'int's in the C++
code, and as C_POINTERs in the define_c_* statements in wxeud.e.
To use these as the appropriate C++ object, you just have to do a
simple cast: ((wxObject*)the_object)->SomeRoutine();.
* Make sure that you put WXEUAPI in front of the routine definition
(look at the code for examples).
* Use the helper functions in wxeu.cpp:
o get_int( seq, index ): Basic subscript operation
( seq[index] ), and returns the value as a C++ int. It's
used for extracting values from a sequence that's passed to a C++ routine from
Euphoria, and handles any conversion from an atom.
o get_int( x ): Converts a Euphoria atom to a C++ int.
o get_string( seq ): Converts a sequence to a wxString.
o get_string( seq, index): Converts a subscript of a
sequence to a wxString.
o get_sequence( string ): Converts a wxString into a Euphoria
sequence
* Declare any Euphoria objects (i.e., when the define_c_* uses
E_OBJECT, E_SEQUENCE, E_ATOM) passed to C++ as "object" in the C++ code.
* Make sure you dereference the Euphoria objects that are passed
to C++ code using the wxEuphoria macros defined in wxeu.h. Not doing
so will cause memory leaks, since their reference counts will never
go to zero.
o wxDeRef( obj ): Checks to see if the object is a sequence
or an atom stored as a double, and dereferences it if either condition is
true.
o wxDeRefDS( obj ): Dereferences the object. Use this only
if you know that a variable is either a double or a sequence.
* When you import the new routine using define_c_*, the constant
should be the same as the routine name, except uppercase, and with a "WX_"
prepended to the name.
* To build on windows, the wat_mswdll\exports.lbc file needs to be
updated. If you have grep and sed installed (possibly through
Cygwin, or GnuWin32), then you can use the OpenWatcom makefile to
regenerate this file using the command: "wmake -f makefile.wat
exports". Otherwise, just add a line at the bottom.
2. Re: wxEuphoria development
Matt Lewis wrote:
>
> * Declare any pointers to wxWidgets objects as 'int's in the C++
> code, and as C_POINTERs in the define_c_* statements in wxeud.e.
> To use these as the appropriate C++ object, you just have to do a
> simple cast: ((wxObject*)the_object)->SomeRoutine();.
I'm not an expert, but shouldn't that be "void *" instead of "int *"? Or are you
saying to declare them as an actual int (not a pointer)? Can you explain why? I'm
kinda curious.
Anyway, sounds interesting! I've started looking again at the latest version of
the library.
--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.
3. Re: wxEuphoria development
Jason Gade wrote:
>
> Matt Lewis wrote:
> >
> > * Declare any pointers to wxWidgets objects as 'int's in the C++
> > code, and as C_POINTERs in the define_c_* statements in wxeud.e.
> > To use these as the appropriate C++ object, you just have to do a
> > simple cast: ((wxObject*)the_object)->SomeRoutine();.
>
> I'm not an expert, but shouldn't that be "void *" instead of "int *"? Or are
> you saying to declare them as an actual int (not a pointer)? Can you explain
> why? I'm kinda curious.
Something like that would work, too, I suppose, although it's not "int *",
but just "int". However, sometimes the pointers come from inside a sequence,
so you can just use get_int(s, index) to get an int, and use the same
technique. Just more consistent that way, so it reduces errors.
Matt
4. Re: wxEuphoria development
Matt Lewis wrote:
> Something like that would work, too, I suppose, although it's not "int *",
> but just "int". However, sometimes the pointers come from inside a sequence,
>
> so you can just use get_int(s, index) to get an int, and use the same
> technique. Just more consistent that way, so it reduces errors.
>
> Matt
Thanks, that explains it.
--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.
5. Re: wxEuphoria development
Just curious:
I notice that Sourceforge has both wiki and forums for developer discussion. Why
does no one seem to use them either for Euphoria or for WxEuphoria?
--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.
6. Re: wxEuphoria development
Jason Gade wrote:
>
> Just curious:
>
> I notice that Sourceforge has both wiki and forums for developer discussion.
> Why does no one seem to use them either for Euphoria or for WxEuphoria?
Well, I have set up the sf-provided wiki for wxEuphoria:
http://wxeuphoria.wiki.sourceforge.net/
There's not much there currently, but I think it would be great if users
started using it. It would also be possible to use the sf servers to
run, for example, MediaWiki, like the Euphoria wiki. I'm not trying to
take control away from anyone or anything, but we'd get a 'better' url
for it (the current URL gets blocked for me at work--I guess someone
hosts adult content in that domain).
The forums might be a good idea, too...
Matt