From: "Steve Simon" <steve@quintile.net>
To: 9fans@9fans.net
Subject: [9fans] stub function generator
Date: Thu, 5 Jun 2008 15:18:49 +0100 [thread overview]
Message-ID: <5895fd23ff8b59e5f6037141fdbed713@quintile.net> (raw)
Anyone know of some nice simple code to parse C prototype definitions
and split them into nicely awk'able bits so I can generate stub functions:
I have been playing with mkptypes | awk which works well
for simple stuff, say my source contains:
void
func(int a, char *b)
and I want to generate
void
stub_func(int a, char *b)
{
func(a, b);
}
however when you get into
int syspipe(int fd[2])
let alone
int sysnotify(void (*func)(void*, char*))
it is starting to push at the limits of what awk is good for.
I guess I am looking for some yacc and lex which
parses C and spits out somthing like this:
func#a|int a#b|char *b
syspipe#fd|int fd[2]
sysnotify#func|void (*func)(void*, char*)
I understand knowledge of types is harder but if I use just basic types
this sounds doable to me. Before I write it, does anyone seem such a beast?
-Steve
next reply other threads:[~2008-06-05 14:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-05 14:18 Steve Simon [this message]
2008-06-05 15:14 ` erik quanstrom
2008-06-05 18:44 ` John Stalker
2008-06-09 9:02 ` Steve Simon
2008-06-09 11:56 ` Bruce Ellis
2008-06-06 1:39 ` Pietro Gagliardi
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5895fd23ff8b59e5f6037141fdbed713@quintile.net \
--to=steve@quintile.net \
--cc=9fans@9fans.net \
/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 NNTP newsgroup(s).