Author Topic: Noob question on adding function boiler plate comment  (Read 6645 times)

Offline cmattb

  • Single posting newcomer
  • *
  • Posts: 4
Noob question on adding function boiler plate comment
« on: January 22, 2009, 11:57:37 am »
I would like to write a script that takes a function and automatically adds boiler plate comments e.g.

User writes the following function

int foo(int bar)
{
   return(bar+1);
}

Then user selects the text "int foo(int bar)" in the editor and runs the script such that the text becomes

/*********
* function: foo <short description>
* args: int bar <description>
* returns <description>
* <long description>
**********/
int foo(int bar)
{
   return(bar+1);
}

Many apologies if this has been done already - but I could not find a reference to such functionality in the forumns.

Any hints/suggestions would be very much appreciated



Offline cmattb

  • Single posting newcomer
  • *
  • Posts: 4
Re: Noob question on adding function boiler plate comment
« Reply #1 on: February 04, 2009, 02:36:04 pm »
So after going through the information on scripting I realised that it was not possible to do this in the script as there was only GetText and SetText available in the cbEditor class.

Therefore I have gone through (the slightly larger than expected) pain of writing the plugin in C++ code. I have the basics working but still have some generalisation work to do. Given the lack of responses from anyone else here I assume that this feature is not widely required from the community. 

However, I would like to request (and I expect I'm posting in the wrong place) that the script API of cbEditor is extended a little further to include reading calls like GetCurrentPos(), GetSelectionStart(), GetSelectionEnd(), etc and writing calls like ReplaceSelection(), etc.

There may well be a very good philisophical reason why this is not done currently, in which case you can continue to ignore this post  ;)

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Noob question on adding function boiler plate comment
« Reply #2 on: February 04, 2009, 05:50:06 pm »
I suspect the only reason it hasn't been done is because noone has needed to do it until now. It wouldn't be too difficult add those extra functions to the exposed API, even for someone unfamiliar with C::B (just use the already exposed functions as templates)

EDIT: I guess there could be an issue with API/ABI stability, but just adding new functions shouldn't break old code. I doubt API/ABI stability is the key concern.
« Last Edit: February 04, 2009, 05:54:57 pm by dmoore »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9702
Re: Noob question on adding function boiler plate comment
« Reply #3 on: February 05, 2009, 08:49:49 am »
I doubt API/ABI stability is the key concern.
I'd say not anymore. ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ