Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: killerbot on December 28, 2007, 12:41:25 pm

Title: cbStyledTextCtrl/cbEditor.h refactoring (rev 4755-4756)
Post by: killerbot on December 28, 2007, 12:41:25 pm
I have carried out a little refactoring. I have put the definition/implementation of the cbStyledTextCtrl in a separate header/source file.
This used to be in the same files of cbEditor. This was for sure not the best solution. 1 thing in 1 place, remember.
Now why did I end up at this refactoring. Well I have some plug-ins and all of them have in their include list the wxScintilla path. In my plug-ins I am not working with the wxScintilla object, just a few simple methods on the cbEditor, but for sure not dealing with wxScintilla. To be honest my plug-ins couldn't give a f*** how the cbEditor is implemented, scintilla, or WhatEverEditorCoreWeMightBeUsing.
The cbEditor class's methods and members are all pointer or references of cbStyledTextCtrl, so in the header we can live with a forward declaration of cbStyledTextCtrl, instead of having it's definition in cbEditor.h. Note : cbStyledTextCtrl inherits from wxScintilla, as such the (include) dependency on the wxScintilla headers.

So I made this split up and have adjusted all clients of cbStyledTextCtrl. All clients include the new header (cbstyledtextctrl.h).
Searching on the include now correctly show all clients [just searching on the type is not sufficient because of method chaining with temp pointers or objects]. Let's try to keep it that way ;-)


NOTE : once again, code broke because cbEditor was using some types for which I didn't include the correct headers, but apparantly we were lucky that wxScintilla.h came across those headers defining those types. This shows once more we HAVE to do a better job at our includes.

NOTE2 : thanks to this I discovered 2 places where pch are used incorrectly (gcc sometimes crashes on such misuses), the pch where included in the headers instead of the cpp's, and the ifdef constructs are not correct. This will be fixed afterwards.


REV 47
Title: Re: cbStyledTextCtrl/cbEditor.h refactoring (rev 4755-4756)
Post by: killerbot on December 28, 2007, 02:05:10 pm
part 1 of those pch fixes is done (cbkeybinder : rev 4757)

part 2 of those pch fixes is done (dragscroll : rev 4758-4759)
Title: Re: cbStyledTextCtrl/cbEditor.h refactoring (rev 4755-4756)
Post by: XayC on January 05, 2008, 10:38:15 am
Why isn't this new header cbstyledtextctrl.h included in the sdk.h (actually sdk_common.h)? Now I need to explicitly include it, but I don't see a good reason for that.

Thanks, XayC.
Title: Re: cbStyledTextCtrl/cbEditor.h refactoring (rev 4755-4756)
Post by: killerbot on January 05, 2008, 10:43:47 am
we thought about it, but decided not to, to keep the depenceny away from wxscintilla.

You should always include explicitly the headers you need, otherwise your code won't build on systems(compilers) which don't support pch's, and for many other reasons too ;-)
Title: Re: cbStyledTextCtrl/cbEditor.h refactoring (rev 4755-4756)
Post by: XayC on January 05, 2008, 10:51:46 am
we thought about it, but decided not to, to keep the depenceny away from wxscintilla.
Ok, it makes sense, thanks.

You should always include explicitly the headers you need, otherwise your code won't build on systems(compilers) which don't support pch's, and for many other reasons too ;-)
I do :-), all my source files have includes required when pch are not used included in a #ifndef CB_PRECOMP / #endif section. But thanks for the suggestion.

Regards, XayC.