X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/430fd33a4f9b29fb5051580878c48e991e5f3d43..267dd3e78997ba6f5a0801c0afab2148dd049f16:/lib/sod.h diff --git a/lib/sod.h b/lib/sod.h index 594e343..919b927 100644 --- a/lib/sod.h +++ b/lib/sod.h @@ -168,6 +168,19 @@ struct sod_chain { #define SOD_CONVERT(cls, obj) ((cls *)sod_convert(cls##__class, (obj))) +/* --- @SOD_DECL@ --- * + * + * Arguments: @cls_@ = a class type name + * @var_@ = a variable name + * + * Use: Declare @var_@ as a pointer to an initialized instance of + * @cls_@ with automatic lifetime. + */ + +#define SOD_DECL(cls_, var_) \ + struct cls_##__ilayout var_##__layout; \ + cls_ *var_ = cls_##__class->cls.init(&var_##__layout) + /*----- Functions provided ------------------------------------------------*/ /* --- @sod_subclassp@ --- *