make event_rpcgen.py use the uint_ types;

make event.h include stdint.h (wonder which OS that will break)


svn:r369
This commit is contained in:
Niels Provos 2007-07-06 03:36:31 +00:00
parent 753ffa563b
commit b15d715cbc
2 changed files with 22 additions and 18 deletions

View File

@ -32,6 +32,7 @@ extern "C" {
#endif
#include <sys/time.h>
#include <stdint.h>
#include <stdarg.h>
#ifdef WIN32

View File

@ -82,7 +82,7 @@ class Struct:
self.PrintIdented(file, ' ', dcl)
print >>file, ''
for entry in self._entries:
print >>file, ' u_int8_t %s_set;' % entry.Name()
print >>file, ' uint8_t %s_set;' % entry.Name()
print >>file, '};\n'
print >>file, (
@ -95,9 +95,9 @@ class Struct:
self._name, self._name) +
'int %s_complete(struct %s *);' % (self._name, self._name)
)
print >>file, ('void evtag_marshal_%s(struct evbuffer *, u_int8_t, '
print >>file, ('void evtag_marshal_%s(struct evbuffer *, uint8_t, '
'const struct %s *);') % ( self._name, self._name)
print >>file, ('int evtag_unmarshal_%s(struct evbuffer *, u_int8_t, '
print >>file, ('int evtag_unmarshal_%s(struct evbuffer *, uint8_t, '
'struct %s *);') % ( self._name, self._name)
# Write a setting function of every variable
@ -198,7 +198,7 @@ class Struct:
' struct evbuffer *evbuf)\n' % (
self._name, self._name) +
'{\n'
' u_int8_t tag;\n'
' uint8_t tag;\n'
' while (EVBUFFER_LENGTH(evbuf) > 0) {\n'
' if (evtag_peek(evbuf, &tag) == -1)\n'
' return (-1);\n'
@ -247,12 +247,12 @@ class Struct:
# Complete message unmarshaling
print >>file, (
'int\n'
'evtag_unmarshal_%s(struct evbuffer *evbuf, u_int8_t need_tag, '
'evtag_unmarshal_%s(struct evbuffer *evbuf, uint8_t need_tag, '
' struct %s *msg)'
) % (self._name, self._name)
print >>file, (
'{\n'
' u_int8_t tag;\n'
' uint8_t tag;\n'
' int res = -1;\n'
'\n'
' struct evbuffer *tmp = evbuffer_new();\n'
@ -274,7 +274,7 @@ class Struct:
# Complete message marshaling
print >>file, (
'void\n'
'evtag_marshal_%s(struct evbuffer *evbuf, u_int8_t tag, '
'evtag_marshal_%s(struct evbuffer *evbuf, uint8_t tag, '
'const struct %s *msg)\n' % (self._name, self._name) +
'{\n'
' struct evbuffer *_buf = evbuffer_new();\n'
@ -425,7 +425,7 @@ class EntryBytes(Entry):
Entry.__init__(self, type, name, tag)
self._length = length
self._ctype = 'u_int8_t'
self._ctype = 'uint8_t'
def GetDeclaration(self, funcname):
code = [ 'int %s(struct %s *, %s **);' % (
@ -438,7 +438,7 @@ class EntryBytes(Entry):
return code
def Declaration(self):
dcl = ['u_int8_t %s_data[%s];' % (self._name, self._length)]
dcl = ['uint8_t %s_data[%s];' % (self._name, self._length)]
return dcl
@ -513,7 +513,7 @@ class EntryInt(Entry):
# Init base class
Entry.__init__(self, type, name, tag)
self._ctype = 'u_int32_t'
self._ctype = 'uint32_t'
def CodeUnmarshal(self, buf, tag_name, var_name):
code = ['if (evtag_unmarshal_int(%s, %s, &%s->%s_data) == -1) {' % (
@ -530,7 +530,7 @@ class EntryInt(Entry):
return code
def Declaration(self):
dcl = ['u_int32_t %s_data;' % self._name]
dcl = ['uint32_t %s_data;' % self._name]
return dcl
@ -744,15 +744,15 @@ class EntryVarBytes(Entry):
# Init base class
Entry.__init__(self, type, name, tag)
self._ctype = 'u_int8_t *'
self._ctype = 'uint8_t *'
def GetDeclaration(self, funcname):
code = [ 'int %s(struct %s *, %s *, u_int32_t *);' % (
code = [ 'int %s(struct %s *, %s *, uint32_t *);' % (
funcname, self._struct.Name(), self._ctype ) ]
return code
def AssignDeclaration(self, funcname):
code = [ 'int %s(struct %s *, const %s, u_int32_t);' % (
code = [ 'int %s(struct %s *, const %s, uint32_t);' % (
funcname, self._struct.Name(), self._ctype ) ]
return code
@ -760,7 +760,7 @@ class EntryVarBytes(Entry):
name = self._name
code = [ 'int',
'%s_%s_assign(struct %s *msg, '
'const %s value, u_int32_t len)' % (
'const %s value, uint32_t len)' % (
self._struct.Name(), name,
self._struct.Name(), self._ctype),
'{',
@ -779,7 +779,7 @@ class EntryVarBytes(Entry):
def CodeGet(self):
name = self._name
code = [ 'int',
'%s_%s_get(struct %s *msg, %s *value, u_int32_t *plen)' % (
'%s_%s_get(struct %s *msg, %s *value, uint32_t *plen)' % (
self._struct.Name(), name,
self._struct.Name(), self._ctype),
'{',
@ -841,8 +841,8 @@ class EntryVarBytes(Entry):
return code
def Declaration(self):
dcl = ['u_int8_t *%s_data;' % self._name,
'u_int32_t %s_length;' % self._name]
dcl = ['uint8_t *%s_data;' % self._name,
'uint32_t %s_length;' % self._name]
return dcl
@ -1295,6 +1295,9 @@ def HeaderPreamble(name):
'#define %s\n\n' ) % (
name, guard, guard)
# insert stdint.h - let's hope everyone has it
pre += '#include <stdint.h>\n'
for statement in headerdirect:
pre += '%s\n' % statement
if headerdirect: