fix preamble of rpcgen-generated files to rely on event2 includes; based on work by jmansion; patch from Zack Weinberg.

svn:r1334
This commit is contained in:
Niels Provos 2009-07-03 17:25:45 +00:00
parent 37d3e16ce9
commit bbcc54ef9c
2 changed files with 14 additions and 16 deletions

View File

@ -37,6 +37,7 @@ Changes in 2.0.2-alpha:
o Replace some read()/write() instances with send()/recv() to work properly on win32. o Replace some read()/write() instances with send()/recv() to work properly on win32.
o Set truncated flag correctly in evdns server replies. o Set truncated flag correctly in evdns server replies.
o Raise RpcGenError in event_rpcgen.py; from jmanison and Zack Weinberg o Raise RpcGenError in event_rpcgen.py; from jmanison and Zack Weinberg
o Fix preamble of rpcgen-generated files to rely on event2 includes; based on work by jmansion; patch from Zack Weinberg.
Changes in 2.0.1-alpha: Changes in 2.0.1-alpha:

View File

@ -18,6 +18,7 @@ line_count = 0
white = re.compile(r'^\s+') white = re.compile(r'^\s+')
cppcomment = re.compile(r'\/\/.*$') cppcomment = re.compile(r'\/\/.*$')
nonident = re.compile(r'[^a-zA-Z0-9_]')
headerdirect = [] headerdirect = []
cppdirect = [] cppdirect = []
@ -1507,11 +1508,10 @@ class CCodeGenerator:
pass pass
def GuardName(self, name): def GuardName(self, name):
name = '_'.join(name.split('.')) # Use the complete provided path to the input file, with all
name = '_'.join(name.split('/')) # non-identifier characters replaced with underscores, to
guard = '_' + name.upper() + '_' # reduce the chance of a collision between guard macros.
return '_' + nonident.sub('_', name).upper() + '_'
return guard
def HeaderPreamble(self, name): def HeaderPreamble(self, name):
guard = self.GuardName(name) guard = self.GuardName(name)
@ -1523,19 +1523,15 @@ class CCodeGenerator:
'#define %s\n\n' ) % ( '#define %s\n\n' ) % (
name, guard, guard) name, guard, guard)
# insert stdint.h - let's hope everyone has it
pre += (
'#include <event-config.h>\n'
'#ifdef _EVENT_HAVE_STDINT_H\n'
'#include <stdint.h>\n'
'#endif\n' )
for statement in headerdirect: for statement in headerdirect:
pre += '%s\n' % statement pre += '%s\n' % statement
if headerdirect: if headerdirect:
pre += '\n' pre += '\n'
pre += '#include <event2/rpc.h>' pre += (
'#include <event2/util.h> /* for ev_uint*_t */\n'
'#include <event2/rpc.h>\n'
)
return pre return pre
@ -1548,14 +1544,15 @@ class CCodeGenerator:
global _VERSION global _VERSION
header_file = '.'.join(name.split('.')[:-1]) + '.gen.h' header_file = '.'.join(name.split('.')[:-1]) + '.gen.h'
slash = header_file.rfind('/')
if slash != -1:
header_file = header_file[slash+1:]
pre = ( '/*\n' pre = ( '/*\n'
' * Automatically generated from %s\n' ' * Automatically generated from %s\n'
' * by %s/%s. DO NOT EDIT THIS FILE.\n' ' * by %s/%s. DO NOT EDIT THIS FILE.\n'
' */\n\n' ) % (name, _NAME, _VERSION) ' */\n\n' ) % (name, _NAME, _VERSION)
pre += ( '#include <sys/types.h>\n' pre += ( '#include <stdlib.h>\n'
'#include <sys/time.h>\n'
'#include <stdlib.h>\n'
'#include <string.h>\n' '#include <string.h>\n'
'#include <assert.h>\n' '#include <assert.h>\n'
'#include <event2/event.h>\n' '#include <event2/event.h>\n'