diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-28 08:13:17 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-28 08:13:17 -0600 |
commit | f898850c2b4fef03f0d175ec052b3725bd406496 (patch) | |
tree | b7b3f7bde3c09cc32bfbe61d6d19d3ba26fe8281 | |
parent | 9d964629694d821b863a0cd6a6c416fe671d5944 (diff) |
tidy
-rw-r--r-- | lib9p/types.c | 637 | ||||
-rwxr-xr-x | lib9p/types.gen | 21 |
2 files changed, 106 insertions, 552 deletions
diff --git a/lib9p/types.c b/lib9p/types.c index f4718b6..91a503d 100644 --- a/lib9p/types.c +++ b/lib9p/types.c @@ -791,553 +791,110 @@ static bool marshal_Rswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rswrite * /* vtables ********************************************************************/ +#define _MSG(typ) [LIB9P_TYP_##typ] = { \ + .unmarshal_basesize = sizeof(struct lib9p_msg_##typ), \ + .unmarshal_extrasize = checksize_##typ, \ + .unmarshal = (_unmarshal_fn_t)unmarshal_##typ, \ + .marshal = (_marshal_fn_t)marshal_##typ, \ + } + struct _vtable_version _lib9p_vtables[LIB9P_VER_NUM] = { [LIB9P_VER_UNINITIALIZED] = { .msgs = { - [LIB9P_TYP_Tversion] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tversion), - .unmarshal_extrasize = checksize_Tversion, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tversion, - .marshal = (_marshal_fn_t)marshal_Tversion, - }, - [LIB9P_TYP_Rversion] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rversion), - .unmarshal_extrasize = checksize_Rversion, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rversion, - .marshal = (_marshal_fn_t)marshal_Rversion, - }, - [LIB9P_TYP_Rerror] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rerror), - .unmarshal_extrasize = checksize_Rerror, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rerror, - .marshal = (_marshal_fn_t)marshal_Rerror, - }, + _MSG(Tversion), + _MSG(Rversion), + _MSG(Rerror), }}, [LIB9P_VER_9P2000] = { .msgs = { - [LIB9P_TYP_Tversion] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tversion), - .unmarshal_extrasize = checksize_Tversion, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tversion, - .marshal = (_marshal_fn_t)marshal_Tversion, - }, - [LIB9P_TYP_Rversion] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rversion), - .unmarshal_extrasize = checksize_Rversion, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rversion, - .marshal = (_marshal_fn_t)marshal_Rversion, - }, - [LIB9P_TYP_Tauth] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tauth), - .unmarshal_extrasize = checksize_Tauth, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tauth, - .marshal = (_marshal_fn_t)marshal_Tauth, - }, - [LIB9P_TYP_Rauth] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rauth), - .unmarshal_extrasize = checksize_Rauth, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rauth, - .marshal = (_marshal_fn_t)marshal_Rauth, - }, - [LIB9P_TYP_Tattach] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tattach), - .unmarshal_extrasize = checksize_Tattach, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tattach, - .marshal = (_marshal_fn_t)marshal_Tattach, - }, - [LIB9P_TYP_Rattach] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rattach), - .unmarshal_extrasize = checksize_Rattach, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rattach, - .marshal = (_marshal_fn_t)marshal_Rattach, - }, - [LIB9P_TYP_Rerror] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rerror), - .unmarshal_extrasize = checksize_Rerror, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rerror, - .marshal = (_marshal_fn_t)marshal_Rerror, - }, - [LIB9P_TYP_Tflush] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tflush), - .unmarshal_extrasize = checksize_Tflush, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tflush, - .marshal = (_marshal_fn_t)marshal_Tflush, - }, - [LIB9P_TYP_Rflush] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rflush), - .unmarshal_extrasize = checksize_Rflush, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rflush, - .marshal = (_marshal_fn_t)marshal_Rflush, - }, - [LIB9P_TYP_Twalk] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Twalk), - .unmarshal_extrasize = checksize_Twalk, - .unmarshal = (_unmarshal_fn_t)unmarshal_Twalk, - .marshal = (_marshal_fn_t)marshal_Twalk, - }, - [LIB9P_TYP_Rwalk] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rwalk), - .unmarshal_extrasize = checksize_Rwalk, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rwalk, - .marshal = (_marshal_fn_t)marshal_Rwalk, - }, - [LIB9P_TYP_Topen] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Topen), - .unmarshal_extrasize = checksize_Topen, - .unmarshal = (_unmarshal_fn_t)unmarshal_Topen, - .marshal = (_marshal_fn_t)marshal_Topen, - }, - [LIB9P_TYP_Ropen] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Ropen), - .unmarshal_extrasize = checksize_Ropen, - .unmarshal = (_unmarshal_fn_t)unmarshal_Ropen, - .marshal = (_marshal_fn_t)marshal_Ropen, - }, - [LIB9P_TYP_Tcreate] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tcreate), - .unmarshal_extrasize = checksize_Tcreate, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tcreate, - .marshal = (_marshal_fn_t)marshal_Tcreate, - }, - [LIB9P_TYP_Rcreate] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rcreate), - .unmarshal_extrasize = checksize_Rcreate, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rcreate, - .marshal = (_marshal_fn_t)marshal_Rcreate, - }, - [LIB9P_TYP_Tread] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tread), - .unmarshal_extrasize = checksize_Tread, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tread, - .marshal = (_marshal_fn_t)marshal_Tread, - }, - [LIB9P_TYP_Rread] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rread), - .unmarshal_extrasize = checksize_Rread, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rread, - .marshal = (_marshal_fn_t)marshal_Rread, - }, - [LIB9P_TYP_Twrite] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Twrite), - .unmarshal_extrasize = checksize_Twrite, - .unmarshal = (_unmarshal_fn_t)unmarshal_Twrite, - .marshal = (_marshal_fn_t)marshal_Twrite, - }, - [LIB9P_TYP_Rwrite] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rwrite), - .unmarshal_extrasize = checksize_Rwrite, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rwrite, - .marshal = (_marshal_fn_t)marshal_Rwrite, - }, - [LIB9P_TYP_Tclunk] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tclunk), - .unmarshal_extrasize = checksize_Tclunk, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tclunk, - .marshal = (_marshal_fn_t)marshal_Tclunk, - }, - [LIB9P_TYP_Rclunk] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rclunk), - .unmarshal_extrasize = checksize_Rclunk, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rclunk, - .marshal = (_marshal_fn_t)marshal_Rclunk, - }, - [LIB9P_TYP_Tremove] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tremove), - .unmarshal_extrasize = checksize_Tremove, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tremove, - .marshal = (_marshal_fn_t)marshal_Tremove, - }, - [LIB9P_TYP_Rremove] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rremove), - .unmarshal_extrasize = checksize_Rremove, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rremove, - .marshal = (_marshal_fn_t)marshal_Rremove, - }, - [LIB9P_TYP_Tstat] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tstat), - .unmarshal_extrasize = checksize_Tstat, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tstat, - .marshal = (_marshal_fn_t)marshal_Tstat, - }, - [LIB9P_TYP_Rstat] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rstat), - .unmarshal_extrasize = checksize_Rstat, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rstat, - .marshal = (_marshal_fn_t)marshal_Rstat, - }, - [LIB9P_TYP_Twstat] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Twstat), - .unmarshal_extrasize = checksize_Twstat, - .unmarshal = (_unmarshal_fn_t)unmarshal_Twstat, - .marshal = (_marshal_fn_t)marshal_Twstat, - }, - [LIB9P_TYP_Rwstat] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rwstat), - .unmarshal_extrasize = checksize_Rwstat, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rwstat, - .marshal = (_marshal_fn_t)marshal_Rwstat, - }, + _MSG(Tversion), + _MSG(Rversion), + _MSG(Tauth), + _MSG(Rauth), + _MSG(Tattach), + _MSG(Rattach), + _MSG(Rerror), + _MSG(Tflush), + _MSG(Rflush), + _MSG(Twalk), + _MSG(Rwalk), + _MSG(Topen), + _MSG(Ropen), + _MSG(Tcreate), + _MSG(Rcreate), + _MSG(Tread), + _MSG(Rread), + _MSG(Twrite), + _MSG(Rwrite), + _MSG(Tclunk), + _MSG(Rclunk), + _MSG(Tremove), + _MSG(Rremove), + _MSG(Tstat), + _MSG(Rstat), + _MSG(Twstat), + _MSG(Rwstat), }}, [LIB9P_VER_9P2000_e] = { .msgs = { - [LIB9P_TYP_Tversion] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tversion), - .unmarshal_extrasize = checksize_Tversion, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tversion, - .marshal = (_marshal_fn_t)marshal_Tversion, - }, - [LIB9P_TYP_Rversion] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rversion), - .unmarshal_extrasize = checksize_Rversion, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rversion, - .marshal = (_marshal_fn_t)marshal_Rversion, - }, - [LIB9P_TYP_Tauth] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tauth), - .unmarshal_extrasize = checksize_Tauth, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tauth, - .marshal = (_marshal_fn_t)marshal_Tauth, - }, - [LIB9P_TYP_Rauth] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rauth), - .unmarshal_extrasize = checksize_Rauth, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rauth, - .marshal = (_marshal_fn_t)marshal_Rauth, - }, - [LIB9P_TYP_Tattach] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tattach), - .unmarshal_extrasize = checksize_Tattach, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tattach, - .marshal = (_marshal_fn_t)marshal_Tattach, - }, - [LIB9P_TYP_Rattach] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rattach), - .unmarshal_extrasize = checksize_Rattach, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rattach, - .marshal = (_marshal_fn_t)marshal_Rattach, - }, - [LIB9P_TYP_Rerror] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rerror), - .unmarshal_extrasize = checksize_Rerror, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rerror, - .marshal = (_marshal_fn_t)marshal_Rerror, - }, - [LIB9P_TYP_Tflush] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tflush), - .unmarshal_extrasize = checksize_Tflush, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tflush, - .marshal = (_marshal_fn_t)marshal_Tflush, - }, - [LIB9P_TYP_Rflush] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rflush), - .unmarshal_extrasize = checksize_Rflush, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rflush, - .marshal = (_marshal_fn_t)marshal_Rflush, - }, - [LIB9P_TYP_Twalk] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Twalk), - .unmarshal_extrasize = checksize_Twalk, - .unmarshal = (_unmarshal_fn_t)unmarshal_Twalk, - .marshal = (_marshal_fn_t)marshal_Twalk, - }, - [LIB9P_TYP_Rwalk] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rwalk), - .unmarshal_extrasize = checksize_Rwalk, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rwalk, - .marshal = (_marshal_fn_t)marshal_Rwalk, - }, - [LIB9P_TYP_Topen] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Topen), - .unmarshal_extrasize = checksize_Topen, - .unmarshal = (_unmarshal_fn_t)unmarshal_Topen, - .marshal = (_marshal_fn_t)marshal_Topen, - }, - [LIB9P_TYP_Ropen] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Ropen), - .unmarshal_extrasize = checksize_Ropen, - .unmarshal = (_unmarshal_fn_t)unmarshal_Ropen, - .marshal = (_marshal_fn_t)marshal_Ropen, - }, - [LIB9P_TYP_Tcreate] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tcreate), - .unmarshal_extrasize = checksize_Tcreate, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tcreate, - .marshal = (_marshal_fn_t)marshal_Tcreate, - }, - [LIB9P_TYP_Rcreate] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rcreate), - .unmarshal_extrasize = checksize_Rcreate, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rcreate, - .marshal = (_marshal_fn_t)marshal_Rcreate, - }, - [LIB9P_TYP_Tread] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tread), - .unmarshal_extrasize = checksize_Tread, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tread, - .marshal = (_marshal_fn_t)marshal_Tread, - }, - [LIB9P_TYP_Rread] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rread), - .unmarshal_extrasize = checksize_Rread, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rread, - .marshal = (_marshal_fn_t)marshal_Rread, - }, - [LIB9P_TYP_Twrite] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Twrite), - .unmarshal_extrasize = checksize_Twrite, - .unmarshal = (_unmarshal_fn_t)unmarshal_Twrite, - .marshal = (_marshal_fn_t)marshal_Twrite, - }, - [LIB9P_TYP_Rwrite] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rwrite), - .unmarshal_extrasize = checksize_Rwrite, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rwrite, - .marshal = (_marshal_fn_t)marshal_Rwrite, - }, - [LIB9P_TYP_Tclunk] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tclunk), - .unmarshal_extrasize = checksize_Tclunk, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tclunk, - .marshal = (_marshal_fn_t)marshal_Tclunk, - }, - [LIB9P_TYP_Rclunk] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rclunk), - .unmarshal_extrasize = checksize_Rclunk, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rclunk, - .marshal = (_marshal_fn_t)marshal_Rclunk, - }, - [LIB9P_TYP_Tremove] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tremove), - .unmarshal_extrasize = checksize_Tremove, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tremove, - .marshal = (_marshal_fn_t)marshal_Tremove, - }, - [LIB9P_TYP_Rremove] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rremove), - .unmarshal_extrasize = checksize_Rremove, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rremove, - .marshal = (_marshal_fn_t)marshal_Rremove, - }, - [LIB9P_TYP_Tstat] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tstat), - .unmarshal_extrasize = checksize_Tstat, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tstat, - .marshal = (_marshal_fn_t)marshal_Tstat, - }, - [LIB9P_TYP_Rstat] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rstat), - .unmarshal_extrasize = checksize_Rstat, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rstat, - .marshal = (_marshal_fn_t)marshal_Rstat, - }, - [LIB9P_TYP_Twstat] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Twstat), - .unmarshal_extrasize = checksize_Twstat, - .unmarshal = (_unmarshal_fn_t)unmarshal_Twstat, - .marshal = (_marshal_fn_t)marshal_Twstat, - }, - [LIB9P_TYP_Rwstat] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rwstat), - .unmarshal_extrasize = checksize_Rwstat, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rwstat, - .marshal = (_marshal_fn_t)marshal_Rwstat, - }, - [LIB9P_TYP_Tsession] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tsession), - .unmarshal_extrasize = checksize_Tsession, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tsession, - .marshal = (_marshal_fn_t)marshal_Tsession, - }, - [LIB9P_TYP_Rsession] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rsession), - .unmarshal_extrasize = checksize_Rsession, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rsession, - .marshal = (_marshal_fn_t)marshal_Rsession, - }, - [LIB9P_TYP_Tsread] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tsread), - .unmarshal_extrasize = checksize_Tsread, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tsread, - .marshal = (_marshal_fn_t)marshal_Tsread, - }, - [LIB9P_TYP_Rsread] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rsread), - .unmarshal_extrasize = checksize_Rsread, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rsread, - .marshal = (_marshal_fn_t)marshal_Rsread, - }, - [LIB9P_TYP_Tswrite] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tswrite), - .unmarshal_extrasize = checksize_Tswrite, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tswrite, - .marshal = (_marshal_fn_t)marshal_Tswrite, - }, - [LIB9P_TYP_Rswrite] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rswrite), - .unmarshal_extrasize = checksize_Rswrite, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rswrite, - .marshal = (_marshal_fn_t)marshal_Rswrite, - }, + _MSG(Tversion), + _MSG(Rversion), + _MSG(Tauth), + _MSG(Rauth), + _MSG(Tattach), + _MSG(Rattach), + _MSG(Rerror), + _MSG(Tflush), + _MSG(Rflush), + _MSG(Twalk), + _MSG(Rwalk), + _MSG(Topen), + _MSG(Ropen), + _MSG(Tcreate), + _MSG(Rcreate), + _MSG(Tread), + _MSG(Rread), + _MSG(Twrite), + _MSG(Rwrite), + _MSG(Tclunk), + _MSG(Rclunk), + _MSG(Tremove), + _MSG(Rremove), + _MSG(Tstat), + _MSG(Rstat), + _MSG(Twstat), + _MSG(Rwstat), + _MSG(Tsession), + _MSG(Rsession), + _MSG(Tsread), + _MSG(Rsread), + _MSG(Tswrite), + _MSG(Rswrite), }}, [LIB9P_VER_9P2000_u] = { .msgs = { - [LIB9P_TYP_Tversion] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tversion), - .unmarshal_extrasize = checksize_Tversion, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tversion, - .marshal = (_marshal_fn_t)marshal_Tversion, - }, - [LIB9P_TYP_Rversion] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rversion), - .unmarshal_extrasize = checksize_Rversion, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rversion, - .marshal = (_marshal_fn_t)marshal_Rversion, - }, - [LIB9P_TYP_Tauth] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tauth), - .unmarshal_extrasize = checksize_Tauth, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tauth, - .marshal = (_marshal_fn_t)marshal_Tauth, - }, - [LIB9P_TYP_Rauth] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rauth), - .unmarshal_extrasize = checksize_Rauth, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rauth, - .marshal = (_marshal_fn_t)marshal_Rauth, - }, - [LIB9P_TYP_Tattach] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tattach), - .unmarshal_extrasize = checksize_Tattach, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tattach, - .marshal = (_marshal_fn_t)marshal_Tattach, - }, - [LIB9P_TYP_Rattach] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rattach), - .unmarshal_extrasize = checksize_Rattach, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rattach, - .marshal = (_marshal_fn_t)marshal_Rattach, - }, - [LIB9P_TYP_Rerror] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rerror), - .unmarshal_extrasize = checksize_Rerror, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rerror, - .marshal = (_marshal_fn_t)marshal_Rerror, - }, - [LIB9P_TYP_Tflush] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tflush), - .unmarshal_extrasize = checksize_Tflush, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tflush, - .marshal = (_marshal_fn_t)marshal_Tflush, - }, - [LIB9P_TYP_Rflush] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rflush), - .unmarshal_extrasize = checksize_Rflush, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rflush, - .marshal = (_marshal_fn_t)marshal_Rflush, - }, - [LIB9P_TYP_Twalk] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Twalk), - .unmarshal_extrasize = checksize_Twalk, - .unmarshal = (_unmarshal_fn_t)unmarshal_Twalk, - .marshal = (_marshal_fn_t)marshal_Twalk, - }, - [LIB9P_TYP_Rwalk] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rwalk), - .unmarshal_extrasize = checksize_Rwalk, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rwalk, - .marshal = (_marshal_fn_t)marshal_Rwalk, - }, - [LIB9P_TYP_Topen] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Topen), - .unmarshal_extrasize = checksize_Topen, - .unmarshal = (_unmarshal_fn_t)unmarshal_Topen, - .marshal = (_marshal_fn_t)marshal_Topen, - }, - [LIB9P_TYP_Ropen] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Ropen), - .unmarshal_extrasize = checksize_Ropen, - .unmarshal = (_unmarshal_fn_t)unmarshal_Ropen, - .marshal = (_marshal_fn_t)marshal_Ropen, - }, - [LIB9P_TYP_Tcreate] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tcreate), - .unmarshal_extrasize = checksize_Tcreate, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tcreate, - .marshal = (_marshal_fn_t)marshal_Tcreate, - }, - [LIB9P_TYP_Rcreate] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rcreate), - .unmarshal_extrasize = checksize_Rcreate, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rcreate, - .marshal = (_marshal_fn_t)marshal_Rcreate, - }, - [LIB9P_TYP_Tread] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tread), - .unmarshal_extrasize = checksize_Tread, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tread, - .marshal = (_marshal_fn_t)marshal_Tread, - }, - [LIB9P_TYP_Rread] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rread), - .unmarshal_extrasize = checksize_Rread, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rread, - .marshal = (_marshal_fn_t)marshal_Rread, - }, - [LIB9P_TYP_Twrite] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Twrite), - .unmarshal_extrasize = checksize_Twrite, - .unmarshal = (_unmarshal_fn_t)unmarshal_Twrite, - .marshal = (_marshal_fn_t)marshal_Twrite, - }, - [LIB9P_TYP_Rwrite] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rwrite), - .unmarshal_extrasize = checksize_Rwrite, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rwrite, - .marshal = (_marshal_fn_t)marshal_Rwrite, - }, - [LIB9P_TYP_Tclunk] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tclunk), - .unmarshal_extrasize = checksize_Tclunk, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tclunk, - .marshal = (_marshal_fn_t)marshal_Tclunk, - }, - [LIB9P_TYP_Rclunk] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rclunk), - .unmarshal_extrasize = checksize_Rclunk, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rclunk, - .marshal = (_marshal_fn_t)marshal_Rclunk, - }, - [LIB9P_TYP_Tremove] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tremove), - .unmarshal_extrasize = checksize_Tremove, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tremove, - .marshal = (_marshal_fn_t)marshal_Tremove, - }, - [LIB9P_TYP_Rremove] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rremove), - .unmarshal_extrasize = checksize_Rremove, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rremove, - .marshal = (_marshal_fn_t)marshal_Rremove, - }, - [LIB9P_TYP_Tstat] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Tstat), - .unmarshal_extrasize = checksize_Tstat, - .unmarshal = (_unmarshal_fn_t)unmarshal_Tstat, - .marshal = (_marshal_fn_t)marshal_Tstat, - }, - [LIB9P_TYP_Rstat] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rstat), - .unmarshal_extrasize = checksize_Rstat, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rstat, - .marshal = (_marshal_fn_t)marshal_Rstat, - }, - [LIB9P_TYP_Twstat] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Twstat), - .unmarshal_extrasize = checksize_Twstat, - .unmarshal = (_unmarshal_fn_t)unmarshal_Twstat, - .marshal = (_marshal_fn_t)marshal_Twstat, - }, - [LIB9P_TYP_Rwstat] = { - .unmarshal_basesize = sizeof(struct lib9p_msg_Rwstat), - .unmarshal_extrasize = checksize_Rwstat, - .unmarshal = (_unmarshal_fn_t)unmarshal_Rwstat, - .marshal = (_marshal_fn_t)marshal_Rwstat, - }, + _MSG(Tversion), + _MSG(Rversion), + _MSG(Tauth), + _MSG(Rauth), + _MSG(Tattach), + _MSG(Rattach), + _MSG(Rerror), + _MSG(Tflush), + _MSG(Rflush), + _MSG(Twalk), + _MSG(Rwalk), + _MSG(Topen), + _MSG(Ropen), + _MSG(Tcreate), + _MSG(Rcreate), + _MSG(Tread), + _MSG(Rread), + _MSG(Twrite), + _MSG(Rwrite), + _MSG(Tclunk), + _MSG(Rclunk), + _MSG(Tremove), + _MSG(Rremove), + _MSG(Tstat), + _MSG(Rstat), + _MSG(Twstat), + _MSG(Rwstat), }}, }; diff --git a/lib9p/types.gen b/lib9p/types.gen index 70f4697..15936e7 100755 --- a/lib9p/types.gen +++ b/lib9p/types.gen @@ -581,26 +581,23 @@ static inline bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { ret += ";\n}\n" # vtables ################################################################## - def msg_entry(msg: Struct) -> str: - ret = "" - ret += f"\t\t[{idprefix.upper()}TYP_{msg.name}] = {{\n" - ret += f"\t\t\t.unmarshal_basesize = sizeof({c_typename(idprefix, msg)}),\n" - ret += f"\t\t\t.unmarshal_extrasize = checksize_{msg.name},\n" - ret += f"\t\t\t.unmarshal = (_unmarshal_fn_t)unmarshal_{msg.name},\n" - ret += f"\t\t\t.marshal = (_marshal_fn_t)marshal_{msg.name},\n" - ret += "\t\t},\n" - return ret - ret += f""" /* vtables ********************************************************************/ +#define _MSG(typ) [{idprefix.upper()}TYP_##typ] = {{ \\ + .unmarshal_basesize = sizeof(struct {idprefix}msg_##typ), \\ + .unmarshal_extrasize = checksize_##typ, \\ + .unmarshal = (_unmarshal_fn_t)unmarshal_##typ, \\ + .marshal = (_marshal_fn_t)marshal_##typ, \\ + }} + struct _vtable_version _{idprefix}vtables[LIB9P_VER_NUM] = {{ """ ret += f"\t[{idprefix.upper()}VER_UNINITIALIZED] = {{ .msgs = {{\n" for msg in structs: if msg.name in ["Tversion", "Rversion", "Rerror"]: # SPECIAL - ret += msg_entry(msg) + ret += f"\t\t_MSG({msg.name}),\n" ret += "\t}},\n" for ver in sorted(versions): @@ -608,7 +605,7 @@ struct _vtable_version _{idprefix}vtables[LIB9P_VER_NUM] = {{ for msg in structs: if ver not in msg.msgver: continue - ret += msg_entry(msg) + ret += f"\t\t_MSG({msg.name}),\n" ret += "\t}},\n" ret += "};\n" |