diff options
author | Niels Provos <provos@gmail.com> | 2006-11-29 02:24:23 +0000 |
---|---|---|
committer | Niels Provos <provos@gmail.com> | 2006-11-29 02:24:23 +0000 |
commit | f7c1bc93fab0a539421595af24a2f0db3f673fe1 (patch) | |
tree | 7ce34084fa9d4f3af9840e981c335cc81fe5f1ec | |
parent | 5a5d231cedc5e87093e1b8a5a75a7f1fac1056e8 (diff) | |
download | libevent-f7c1bc93fab0a539421595af24a2f0db3f673fe1.tar.gz |
merge from trunk: support #define in .rpc descriptions
svn:r288
-rwxr-xr-x | event_rpcgen.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/event_rpcgen.py b/event_rpcgen.py index d9265120..75a2b0fe 100755 --- a/event_rpcgen.py +++ b/event_rpcgen.py @@ -20,6 +20,7 @@ leading = re.compile(r'^\s+') trailing = re.compile(r'\s+$') white = re.compile(r'^\s+') cppcomment = re.compile(r'\/\/.*$') +headerdirect = [] cppdirect = [] # Holds everything that makes a struct @@ -1224,6 +1225,10 @@ def GetNextStruct(file): cppdirect.append(line) continue + if re.match(r'^#define', line): + headerdirect.append(line) + continue + if not re.match(r'^struct %s {$' % _STRUCT_RE, line, re.IGNORECASE): print >>sys.stderr, 'Missing struct on line %d: %s' % ( @@ -1288,6 +1293,12 @@ def HeaderPreamble(name): '#ifndef %s\n' '#define %s\n\n' ) % ( name, guard, guard) + + for statement in headerdirect: + pre += '%s\n' % statement + if headerdirect: + pre += '\n' + pre += ( '#define EVTAG_HAS(msg, member) ((msg)->member##_set == 1)\n' '#define EVTAG_ASSIGN(msg, member, args...) ' @@ -1322,8 +1333,8 @@ def BodyPreamble(name): '#include <assert.h>\n' '#include <event.h>\n\n' ) - for include in cppdirect: - pre += '%s\n' % include + for statement in cppdirect: + pre += '%s\n' % statement pre += '\n#include "%s"\n\n' % header_file |