unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Sarir Khamsi <sarir.khamsi@raytheon.com>
To: help-gnu-emacs@gnu.org
Subject: Creating C++ constructor member init lists
Date: Tue, 27 Oct 2009 13:08:46 -0700	[thread overview]
Message-ID: <u3a5438hd.fsf@raytheon.com> (raw)

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


             reply	other threads:[~2009-10-27 20:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-27 20:08 Sarir Khamsi [this message]
2009-10-27 21:21 ` Creating C++ constructor member init lists Pascal J. Bourguignon
2009-10-28 21:29   ` Sarir Khamsi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=u3a5438hd.fsf@raytheon.com \
    --to=sarir.khamsi@raytheon.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).