mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
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:
parent
753ffa563b
commit
b15d715cbc
1
event.h
1
event.h
@ -32,6 +32,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -82,7 +82,7 @@ class Struct:
|
|||||||
self.PrintIdented(file, ' ', dcl)
|
self.PrintIdented(file, ' ', dcl)
|
||||||
print >>file, ''
|
print >>file, ''
|
||||||
for entry in self._entries:
|
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, '};\n'
|
||||||
|
|
||||||
print >>file, (
|
print >>file, (
|
||||||
@ -95,9 +95,9 @@ class Struct:
|
|||||||
self._name, self._name) +
|
self._name, self._name) +
|
||||||
'int %s_complete(struct %s *);' % (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)
|
'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)
|
'struct %s *);') % ( self._name, self._name)
|
||||||
|
|
||||||
# Write a setting function of every variable
|
# Write a setting function of every variable
|
||||||
@ -198,7 +198,7 @@ class Struct:
|
|||||||
' struct evbuffer *evbuf)\n' % (
|
' struct evbuffer *evbuf)\n' % (
|
||||||
self._name, self._name) +
|
self._name, self._name) +
|
||||||
'{\n'
|
'{\n'
|
||||||
' u_int8_t tag;\n'
|
' uint8_t tag;\n'
|
||||||
' while (EVBUFFER_LENGTH(evbuf) > 0) {\n'
|
' while (EVBUFFER_LENGTH(evbuf) > 0) {\n'
|
||||||
' if (evtag_peek(evbuf, &tag) == -1)\n'
|
' if (evtag_peek(evbuf, &tag) == -1)\n'
|
||||||
' return (-1);\n'
|
' return (-1);\n'
|
||||||
@ -247,12 +247,12 @@ class Struct:
|
|||||||
# Complete message unmarshaling
|
# Complete message unmarshaling
|
||||||
print >>file, (
|
print >>file, (
|
||||||
'int\n'
|
'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)'
|
' struct %s *msg)'
|
||||||
) % (self._name, self._name)
|
) % (self._name, self._name)
|
||||||
print >>file, (
|
print >>file, (
|
||||||
'{\n'
|
'{\n'
|
||||||
' u_int8_t tag;\n'
|
' uint8_t tag;\n'
|
||||||
' int res = -1;\n'
|
' int res = -1;\n'
|
||||||
'\n'
|
'\n'
|
||||||
' struct evbuffer *tmp = evbuffer_new();\n'
|
' struct evbuffer *tmp = evbuffer_new();\n'
|
||||||
@ -274,7 +274,7 @@ class Struct:
|
|||||||
# Complete message marshaling
|
# Complete message marshaling
|
||||||
print >>file, (
|
print >>file, (
|
||||||
'void\n'
|
'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) +
|
'const struct %s *msg)\n' % (self._name, self._name) +
|
||||||
'{\n'
|
'{\n'
|
||||||
' struct evbuffer *_buf = evbuffer_new();\n'
|
' struct evbuffer *_buf = evbuffer_new();\n'
|
||||||
@ -425,7 +425,7 @@ class EntryBytes(Entry):
|
|||||||
Entry.__init__(self, type, name, tag)
|
Entry.__init__(self, type, name, tag)
|
||||||
|
|
||||||
self._length = length
|
self._length = length
|
||||||
self._ctype = 'u_int8_t'
|
self._ctype = 'uint8_t'
|
||||||
|
|
||||||
def GetDeclaration(self, funcname):
|
def GetDeclaration(self, funcname):
|
||||||
code = [ 'int %s(struct %s *, %s **);' % (
|
code = [ 'int %s(struct %s *, %s **);' % (
|
||||||
@ -438,7 +438,7 @@ class EntryBytes(Entry):
|
|||||||
return code
|
return code
|
||||||
|
|
||||||
def Declaration(self):
|
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
|
return dcl
|
||||||
|
|
||||||
@ -513,7 +513,7 @@ class EntryInt(Entry):
|
|||||||
# Init base class
|
# Init base class
|
||||||
Entry.__init__(self, type, name, tag)
|
Entry.__init__(self, type, name, tag)
|
||||||
|
|
||||||
self._ctype = 'u_int32_t'
|
self._ctype = 'uint32_t'
|
||||||
|
|
||||||
def CodeUnmarshal(self, buf, tag_name, var_name):
|
def CodeUnmarshal(self, buf, tag_name, var_name):
|
||||||
code = ['if (evtag_unmarshal_int(%s, %s, &%s->%s_data) == -1) {' % (
|
code = ['if (evtag_unmarshal_int(%s, %s, &%s->%s_data) == -1) {' % (
|
||||||
@ -530,7 +530,7 @@ class EntryInt(Entry):
|
|||||||
return code
|
return code
|
||||||
|
|
||||||
def Declaration(self):
|
def Declaration(self):
|
||||||
dcl = ['u_int32_t %s_data;' % self._name]
|
dcl = ['uint32_t %s_data;' % self._name]
|
||||||
|
|
||||||
return dcl
|
return dcl
|
||||||
|
|
||||||
@ -744,15 +744,15 @@ class EntryVarBytes(Entry):
|
|||||||
# Init base class
|
# Init base class
|
||||||
Entry.__init__(self, type, name, tag)
|
Entry.__init__(self, type, name, tag)
|
||||||
|
|
||||||
self._ctype = 'u_int8_t *'
|
self._ctype = 'uint8_t *'
|
||||||
|
|
||||||
def GetDeclaration(self, funcname):
|
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 ) ]
|
funcname, self._struct.Name(), self._ctype ) ]
|
||||||
return code
|
return code
|
||||||
|
|
||||||
def AssignDeclaration(self, funcname):
|
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 ) ]
|
funcname, self._struct.Name(), self._ctype ) ]
|
||||||
return code
|
return code
|
||||||
|
|
||||||
@ -760,7 +760,7 @@ class EntryVarBytes(Entry):
|
|||||||
name = self._name
|
name = self._name
|
||||||
code = [ 'int',
|
code = [ 'int',
|
||||||
'%s_%s_assign(struct %s *msg, '
|
'%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(), name,
|
||||||
self._struct.Name(), self._ctype),
|
self._struct.Name(), self._ctype),
|
||||||
'{',
|
'{',
|
||||||
@ -779,7 +779,7 @@ class EntryVarBytes(Entry):
|
|||||||
def CodeGet(self):
|
def CodeGet(self):
|
||||||
name = self._name
|
name = self._name
|
||||||
code = [ 'int',
|
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(), name,
|
||||||
self._struct.Name(), self._ctype),
|
self._struct.Name(), self._ctype),
|
||||||
'{',
|
'{',
|
||||||
@ -841,8 +841,8 @@ class EntryVarBytes(Entry):
|
|||||||
return code
|
return code
|
||||||
|
|
||||||
def Declaration(self):
|
def Declaration(self):
|
||||||
dcl = ['u_int8_t *%s_data;' % self._name,
|
dcl = ['uint8_t *%s_data;' % self._name,
|
||||||
'u_int32_t %s_length;' % self._name]
|
'uint32_t %s_length;' % self._name]
|
||||||
|
|
||||||
return dcl
|
return dcl
|
||||||
|
|
||||||
@ -1295,6 +1295,9 @@ def HeaderPreamble(name):
|
|||||||
'#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 <stdint.h>\n'
|
||||||
|
|
||||||
for statement in headerdirect:
|
for statement in headerdirect:
|
||||||
pre += '%s\n' % statement
|
pre += '%s\n' % statement
|
||||||
if headerdirect:
|
if headerdirect:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user