From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!not-for-mail
From: Sarir Khamsi <sarir.khamsi@raytheon.com>
Newsgroups: gmane.emacs.help
Subject: Creating C++ constructor member init lists
Date: Tue, 27 Oct 2009 13:08:46 -0700
Organization: Raytheon Company
Message-ID: <u3a5438hd.fsf@raytheon.com>
NNTP-Posting-Host: lo.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: ger.gmane.org 1256676055 9366 80.91.229.12 (27 Oct 2009 20:40:55 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 27 Oct 2009 20:40:55 +0000 (UTC)
To: help-gnu-emacs@gnu.org
Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 27 21:40:49 2009
Return-path: <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org>
Envelope-to: geh-help-gnu-emacs@m.gmane.org
Original-Received: from lists.gnu.org ([199.232.76.165])
	by lo.gmane.org with esmtp (Exim 4.50)
	id 1N2sqT-0007aR-Lk
	for geh-help-gnu-emacs@m.gmane.org; Tue, 27 Oct 2009 21:40:45 +0100
Original-Received: from localhost ([127.0.0.1]:38833 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43)
	id 1N2sqT-0001tb-8J
	for geh-help-gnu-emacs@m.gmane.org; Tue, 27 Oct 2009 16:40:45 -0400
Original-Path: news.stanford.edu!usenet.stanford.edu!panix!bloom-beacon.mit.edu!4.24.21.218.MISMATCH!newsfeed2.dallas1.level3.net!news.level3.com!bos-service1.raytheon.com!bos-service2b.ext.ray.com.POSTED!53ab2750!not-for-mail
Original-Newsgroups: gnu.emacs.help
User-Agent: Gnus/5.101 (Gnus v5.10.10) Emacs/22.2 (windows-nt)
Cancel-Lock: sha1:36tNJYkDz0W7ciDX9zFOzvbFNE4=
Original-Lines: 55
Original-NNTP-Posting-Host: 147.24.52.80
Original-X-Complaints-To: news@ext.ray.com
Original-X-Trace: bos-service2b.ext.ray.com 1256674127 147.24.52.80 (Tue,
	27 Oct 2009 20:08:47 UTC)
Original-NNTP-Posting-Date: Tue, 27 Oct 2009 20:08:47 UTC
Original-Xref: news.stanford.edu gnu.emacs.help:174210
X-BeenThere: help-gnu-emacs@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Users list for the GNU Emacs text editor <help-gnu-emacs.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/help-gnu-emacs>,
	<mailto:help-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/help-gnu-emacs>
List-Post: <mailto:help-gnu-emacs@gnu.org>
List-Help: <mailto:help-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/help-gnu-emacs>,
	<mailto:help-gnu-emacs-request@gnu.org?subject=subscribe>
Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org
Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org
Xref: news.gmane.org gmane.emacs.help:69294
Archived-At: <http://permalink.gmane.org/gmane.emacs.help/69294>

I'd like to write some code in some language (preferably in Emacs
Lisp) to take a C++ class and add member variables to the
constructor's member initialization list in an automated
fashion. Given something like:

   struct MyType
   {
      MyType();
      // ...
   private:
      int i1_;
      double d_;
      T1 *pT1_;
      T2 t2_;
   };

I'd like the code to generate:

   struct MyType
   {
      MyType() :
         i1_(0),
         d_(0.0),
         pT1_(0),
         t2_()
      {
      }
      // ...
   private:
      int i1_;
      double d_;
      T1 *pT1_;
      T2 t2_;
   };

It would be easy to write something that just default-constructs the
members, but I'd like to make it smart enough to init bools to
"false", ints to "0", doubles to "0.0", etc. My questions are:

 - Are there helper functions in c++-mode that can be used to
   enumerate member variables, or make life easier?
 - Is there code to do something like this already (I looked a bit and
   didn't find exactly what I wanted)?
 - Is GCC-XML worth looking into? I've looked at the output of a small
   C++ class and could use Python to do what I want.

I haven't started the coding and wanted to get other people's
input. Thanks.

Sarir

-- 
Sarir Khamsi
software guy
sarir.khamsi@raytheon.com