Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Generate initializers
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

robiwan
New Member

8 Posts

Posted - Oct 26 2007 :  05:18:06 AM  Show Profile  Reply with Quote
(C++)

Would be nice to be able to generate initializers for class members, and/or rearrange them so that they are in the order specified in the header file. Otherwise gcc is spewing out warnings of initializers not being in the correct order (they are always initialized by the compiler in the order they appear in the header)

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Oct 26 2007 :  09:19:36 AM  Show Profile  Reply with Quote
We are considering a command to sort the initializers into the correct order:

case=8368

Generating the list of initializers is harder, since VA will not know how to initialize complex types. If all your class members are "int" and "float" then it is easy, but for classes and structures VA will nto really have any way of producing a default initial value.

zen is the art of being at one with the two'ness
Go to Top of Page

tabir
Starting Member

1 Posts

Posted - Nov 14 2007 :  02:20:39 AM  Show Profile  Reply with Quote
It could be a wonderfull tool.
Pointers could be initialized to zero.
Referenced could be initialized to the relevant argument.

If you give the basic tool to the user and a flexible customization it will work just fine.

Tal.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Nov 14 2007 :  08:16:58 AM  Show Profile  Reply with Quote
In general how is VA to work out the relevant argument for a reference?

If you only have one parameter of the same type as the reference then this is fine, but what about a default constructor? A copy constructor?

I do understand the appeal, but I can also see a lot of problems here that need to be considered.

zen is the art of being at one with the two'ness
Go to Top of Page

SMaton
New Member

7 Posts

Posted - Nov 27 2007 :  1:17:00 PM  Show Profile  Reply with Quote
Hi,

well... I really get this idea from the eclipse IDE which I'm using very often for now: Perhaps it would be possible to initialize the standard types (such as int, float, etc) with 0/NULL. For those which are more complex, put the cursor to the first complex variable, let the user write his initialisation and mark the others. Jump from marker to marker with 'tab' until the user hits enter...

Have fun,
Stefan

Edited by - SMaton on Nov 27 2007 1:17:38 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Nov 29 2007 :  5:07:49 PM  Show Profile  Reply with Quote
It is an interesting idea, but I wonder what happens as soon as you need to jump to a different file to lookup or check the details of this complex type, so you can correctly initialize it.

Is this how Eclipse works? How does it handle you having to jump around the file, or to a different file, in the middle of doing this?

zen is the art of being at one with the two'ness
Go to Top of Page

sl@sh
Tomato Guru

Switzerland
204 Posts

Posted - Dec 03 2007 :  06:00:24 AM  Show Profile  Reply with Quote
How about using the Find References window for the marking? Might be a bit of an overkill for most cases, but the users are already familiar with it and it should be easy to implement, no?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Dec 03 2007 :  10:17:45 AM  Show Profile  Reply with Quote
I don't understand. What sort of thing are you thinking of?

zen is the art of being at one with the two'ness
Go to Top of Page

sl@sh
Tomato Guru

Switzerland
204 Posts

Posted - Dec 04 2007 :  10:04:01 AM  Show Profile  Reply with Quote
Nevermind, I didn't get the intended functionality...
Go to Top of Page

shawnee6d
New Member

USA
3 Posts

Posted - Dec 07 2007 :  3:25:52 PM  Show Profile  Reply with Quote
Actually, couldn't the current refactor feature do some of this?

I suppose for complex types structs, classes, v1 of the feature might simply add something like:

foo::foo():
int i(0),
void* pPtr(NULL)
{
//foobar();//TODO: add initializer for complex type
//foobar2();//TODO: add initializer for complex type
}

or something similar in the order specificied in the header. Maybe mark initializer lines that were added to the ctor itself due to complex type? Or am I in outer space?

I'd think that would fit in nicely on the refactor menu, be applicable to a single ctor. Possibly a Refactor::AddCopyCTOR or smart detect that element is a copy ctor is code element the current selection, then generate initializers for that particular ctor using it's reference or ptr param. Kind of a cool notion, but not a trivial or over night feature to do would be my guess.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Dec 07 2007 :  3:42:57 PM  Show Profile  Reply with Quote
I don't think I follow. If you want comments in the function in order you might be as well off simply copy / pasting the class member variables and using VA to wrap them in /* */ comments. This is something I have done before, so I have them in front of me in the cpp file, in order, with their type information on hand.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000