Author Topic: cbStyledTextCtrl/cbEditor.h refactoring (rev 4755-4756)  (Read 5267 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
cbStyledTextCtrl/cbEditor.h refactoring (rev 4755-4756)
« 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
« Last Edit: December 28, 2007, 12:45:33 pm by killerbot »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: cbStyledTextCtrl/cbEditor.h refactoring (rev 4755-4756)
« Reply #1 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)
« Last Edit: December 29, 2007, 12:04:50 am by killerbot »

Offline XayC

  • Multiple posting newcomer
  • *
  • Posts: 94
Re: cbStyledTextCtrl/cbEditor.h refactoring (rev 4755-4756)
« Reply #2 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.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: cbStyledTextCtrl/cbEditor.h refactoring (rev 4755-4756)
« Reply #3 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 ;-)

Offline XayC

  • Multiple posting newcomer
  • *
  • Posts: 94
Re: cbStyledTextCtrl/cbEditor.h refactoring (rev 4755-4756)
« Reply #4 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.