diff options
author | Niels Provos <provos@gmail.com> | 2008-06-21 02:21:25 +0000 |
---|---|---|
committer | Niels Provos <provos@gmail.com> | 2008-06-21 02:21:25 +0000 |
commit | 99a1063e735f70443268b50d14f042c87cb9b99a (patch) | |
tree | 2789eb33ecbbb259c280e9c290f183b31ba40d72 /event_rpcgen.py | |
parent | 4c56ba1cede32ba30624208e8e84672531e644e3 (diff) | |
download | libevent-99a1063e735f70443268b50d14f042c87cb9b99a.tar.gz |
support 64-bit integers in rpc structs
svn:r856
Diffstat (limited to 'event_rpcgen.py')
-rwxr-xr-x | event_rpcgen.py | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/event_rpcgen.py b/event_rpcgen.py index ea480a25..b3770830 100755 --- a/event_rpcgen.py +++ b/event_rpcgen.py @@ -575,12 +575,17 @@ class EntryBytes(Entry): Entry.Verify(self) class EntryInt(Entry): - def __init__(self, type, name, tag): + def __init__(self, type, name, tag, bits=32): # Init base class Entry.__init__(self, type, name, tag) self._can_be_array = 1 - self._ctype = 'ev_uint32_t' + if bits == 32: + self._ctype = 'ev_uint32_t' + self._marshal_type = 'int' + if bits == 64: + self._ctype = 'ev_uint64_t' + self._marshal_type = 'int64' def GetInitializer(self): return "0" @@ -598,23 +603,26 @@ class EntryInt(Entry): 'value' : value } ] def CodeUnmarshal(self, buf, tag_name, var_name, var_len): - code = ['if (evtag_unmarshal_int(%(buf)s, %(tag)s, &%(var)s) == -1) {', - ' event_warnx("%%s: failed to unmarshal %(name)s", __func__);', - ' return (-1);', - '}' ] + code = [ + 'if (evtag_unmarshal_%(ma)s(%(buf)s, %(tag)s, &%(var)s) == -1) {', + ' event_warnx("%%s: failed to unmarshal %(name)s", __func__);', + ' return (-1);', + '}' ] code = '\n'.join(code) % self.GetTranslation({ + 'ma' : self._marshal_type, 'buf' : buf, 'tag' : tag_name, 'var' : var_name }) return code.split('\n') def CodeMarshal(self, buf, tag_name, var_name, var_len): - code = ['evtag_marshal_int(%s, %s, %s);' % ( - buf, tag_name, var_name)] + code = [ + 'evtag_marshal_%s(%s, %s, %s);' % ( + self._marshal_type, buf, tag_name, var_name)] return code def Declaration(self): - dcl = ['ev_uint32_t %s_data;' % self._name] + dcl = ['%s %s_data;' % (self._ctype, self._name)] return dcl @@ -1338,6 +1346,8 @@ def ProcessOneEntry(factory, newstruct, entry): newentry = factory.EntryVarBytes(entry_type, name, tag) elif entry_type == 'int' and not fixed_length: newentry = factory.EntryInt(entry_type, name, tag) + elif entry_type == 'int64' and not fixed_length: + newentry = factory.EntryInt(entry_type, name, tag, bits=64) elif entry_type == 'string' and not fixed_length: newentry = factory.EntryString(entry_type, name, tag) else: @@ -1593,8 +1603,8 @@ class CCodeGenerator: def EntryVarBytes(self, entry_type, name, tag): return EntryVarBytes(entry_type, name, tag) - def EntryInt(self, entry_type, name, tag): - return EntryInt(entry_type, name, tag) + def EntryInt(self, entry_type, name, tag, bits=32): + return EntryInt(entry_type, name, tag, bits) def EntryString(self, entry_type, name, tag): return EntryString(entry_type, name, tag) |