On 8 June 2011 10:48, Marko Lindqvist <cazf...@gmail.com> wrote:
> On 8 June 2011 04:33, David Lowe <doctorjl...@verizon.net> wrote:
>> On 7 Jun, 2011, at 9:32 AM, Marko Lindqvist wrote:
>>
>>> Qt-client development
>>>
>>        Until somebody better comes along, i can at least at least keep this 
>> ball rolling.  Caveat: i've only worked through the TrollTech tutorials last 
>> semester while learning C++, so i'm far from being an expert.  Since i've 
>> never done anything this big before, i could benefit if somebody with "the 
>> big picture" gave a breakdown of the tasks.
>>
>
>  By the time I had to stop Qt-client development due to time
> restrictions, I had also encountered design problem in fitting client
> common code and Qt models of graphics canvas together. This probably
> needs to be resolved before any other work on Qt-client makes sense.

 Easier, maybe even boring, task could be checking that all functions
belonging to client common -> gui API go through function pointer
layer. I just implemented it with minimum effort -> only those cases
that caused actual compilation errors. I think that for consistency
callback layer should be used even for those functions that don't
cause compilation failures. In any case going through all these
functions teaches one a lot about client common -> gui-specific
interface.
Function pointer layer exist to overcome different symbol mangling in
C and C++. C-code, such as client common code, cannot call functions
from C++ (gui-qt) with the usual convention of just giving function
name as deep down the C and C++ have different idea what the name
looks like even when in source code it seems the same. So gui-qt just
sets up table of function pointers (C++ code itself can put those
pointers correctly) and C-side uses those pointers to call functions.

For example for gui-specific function ui_init():
- Actual implementation is in gui_main.cpp with name qtg_ui_init()
(named so that prefix 'qtg_' is added)
- qtg_ui_init() in header qtg_cxxside.h (all the functions accessed by
function pointer layer are here)
- In qtg_cxxside.cpp function setup_gui_funcs() sets function pointer
funcs->ui_init (named after the gui-specific function) to point to
qtg_ui_main()
- In qtg_cside.h that pointer is defined to be part of gui_funcs-structure
- In qtg_side.c is qt-client version of ui_init() that just calls
qtg_ui_init() through function pointer (wraps it)




 - ML

_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to