mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-18 11:31:00 -05:00
Replace method-dispatch #defines with inline functions.
This replaces all the macros like ssh_key_sign() and win_draw_text() which take an object containing a vtable pointer and do the dereferencing to find the actual concrete method to call. Now they're all inline functions, which means more sensible type-checking and more comprehensible error reports when the types go wrong, and also means that there's no risk of double-evaluating the object argument.
This commit is contained in:
14
sshbpp.h
14
sshbpp.h
@ -42,11 +42,15 @@ struct BinaryPacketProtocol {
|
||||
bool expect_close;
|
||||
};
|
||||
|
||||
#define ssh_bpp_handle_input(bpp) ((bpp)->vt->handle_input(bpp))
|
||||
#define ssh_bpp_handle_output(bpp) ((bpp)->vt->handle_output(bpp))
|
||||
#define ssh_bpp_new_pktout(bpp, type) ((bpp)->vt->new_pktout(type))
|
||||
#define ssh_bpp_queue_disconnect(bpp, msg, cat) \
|
||||
((bpp)->vt->queue_disconnect(bpp, msg, cat))
|
||||
static inline void ssh_bpp_handle_input(BinaryPacketProtocol *bpp)
|
||||
{ bpp->vt->handle_input(bpp); }
|
||||
static inline void ssh_bpp_handle_output(BinaryPacketProtocol *bpp)
|
||||
{ bpp->vt->handle_output(bpp); }
|
||||
static inline PktOut *ssh_bpp_new_pktout(BinaryPacketProtocol *bpp, int type)
|
||||
{ return bpp->vt->new_pktout(type); }
|
||||
static inline void ssh_bpp_queue_disconnect(BinaryPacketProtocol *bpp,
|
||||
const char *msg, int category)
|
||||
{ bpp->vt->queue_disconnect(bpp, msg, category); }
|
||||
|
||||
/* ssh_bpp_free is more than just a macro wrapper on the vtable; it
|
||||
* does centralised parts of the freeing too. */
|
||||
|
Reference in New Issue
Block a user