fx: re-arrange type system to allow for reflection

This commit is contained in:
2026-05-05 19:03:22 +01:00
parent 8c12868651
commit 90a3905f48
83 changed files with 768 additions and 842 deletions
+5 -5
View File
@@ -162,7 +162,7 @@ static bool compressor_eof(const struct compressor_data *p)
/*** PUBLIC FUNCTIONS *********************************************************/
enum fx_status fx_compressor_get_buffer_size(
fx_type type,
fx_type_id type,
fx_compressor_mode mode,
size_t *inbuf_size,
size_t *outbuf_size)
@@ -248,11 +248,11 @@ static void compressor_fini(fx_object *obj, void *priv)
/*** CLASS DEFINITION *********************************************************/
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_compressor)
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
FX_TYPE_CLASS_BEGIN(fx_compressor)
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
FX_INTERFACE_ENTRY(to_string) = NULL;
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
FX_TYPE_CLASS_DEFINITION_END(fx_compressor)
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
FX_TYPE_CLASS_END(fx_compressor)
FX_TYPE_DEFINITION_BEGIN(fx_compressor)
FX_TYPE_ID(0x452ee0f9, 0xfe12, 0x48a1, 0xb596, 0xad5b7a3940e7);
+7 -7
View File
@@ -782,7 +782,7 @@ static enum fx_status cstream_restore_cursor_position(
enum fx_status fx_cstream_open(
fx_stream *endpoint,
fx_type compressor_type,
fx_type_id compressor_type,
fx_compressor_mode mode,
fx_cstream **out)
{
@@ -989,12 +989,12 @@ static void cstream_fini(fx_object *obj, void *priv)
/*** CLASS DEFINITION *********************************************************/
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_cstream)
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
FX_TYPE_CLASS_BEGIN(fx_cstream)
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
FX_INTERFACE_ENTRY(to_string) = NULL;
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_stream, FX_TYPE_STREAM)
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_stream, FX_TYPE_STREAM)
FX_INTERFACE_ENTRY(s_close) = NULL;
FX_INTERFACE_ENTRY(s_seek) = NULL;
FX_INTERFACE_ENTRY(s_tell) = NULL;
@@ -1002,8 +1002,8 @@ FX_TYPE_CLASS_DEFINITION_BEGIN(fx_cstream)
FX_INTERFACE_ENTRY(s_read) = fx_cstream_read;
FX_INTERFACE_ENTRY(s_write) = fx_cstream_write;
FX_INTERFACE_ENTRY(s_reserve) = NULL;
FX_TYPE_CLASS_INTERFACE_END(fx_stream, FX_TYPE_STREAM)
FX_TYPE_CLASS_DEFINITION_END(fx_cstream)
FX_TYPE_VTABLE_INTERFACE_END(fx_stream, FX_TYPE_STREAM)
FX_TYPE_CLASS_END(fx_cstream)
FX_TYPE_DEFINITION_BEGIN(fx_cstream)
FX_TYPE_ID(0xe1e899b5, 0x6a3c, 0x4f9c, 0xafd0, 0xaab3f156615c);
+6 -6
View File
@@ -361,12 +361,12 @@ static enum fx_status set_mode(
/*** CLASS DEFINITION *********************************************************/
FX_TYPE_CLASS_DEFINITION_BEGIN(fx_zstd_compressor)
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
FX_TYPE_CLASS_BEGIN(fx_zstd_compressor)
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_object, FX_TYPE_OBJECT)
FX_INTERFACE_ENTRY(to_string) = NULL;
FX_TYPE_CLASS_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
FX_TYPE_VTABLE_INTERFACE_END(fx_object, FX_TYPE_OBJECT)
FX_TYPE_CLASS_INTERFACE_BEGIN(fx_compressor, FX_TYPE_COMPRESSOR)
FX_TYPE_VTABLE_INTERFACE_BEGIN(fx_compressor, FX_TYPE_COMPRESSOR)
FX_INTERFACE_ENTRY(c_buffer_size)
= fx_zstd_compressor_get_buffer_size;
FX_INTERFACE_ENTRY(c_compress) = compress;
@@ -374,8 +374,8 @@ FX_TYPE_CLASS_DEFINITION_BEGIN(fx_zstd_compressor)
FX_INTERFACE_ENTRY(c_decompress) = decompress;
FX_INTERFACE_ENTRY(c_reset) = reset;
FX_INTERFACE_ENTRY(c_set_mode) = set_mode;
FX_TYPE_CLASS_INTERFACE_END(fx_compressor, FX_TYPE_COMPRESSOR)
FX_TYPE_CLASS_DEFINITION_END(fx_zstd_compressor)
FX_TYPE_VTABLE_INTERFACE_END(fx_compressor, FX_TYPE_COMPRESSOR)
FX_TYPE_CLASS_END(fx_zstd_compressor)
FX_TYPE_DEFINITION_BEGIN(fx_zstd_compressor)
FX_TYPE_ID(0x51d437fc, 0xe789, 0x4105, 0xbac7, 0xe6b3f45df198);
@@ -38,7 +38,7 @@ typedef struct fx_compressor_data {
fx_ringbuffer *c_in, *c_out;
} fx_compressor_data;
FX_API fx_type fx_compressor_get_type(void);
FX_API fx_type_id fx_compressor_get_type(void);
#if 0
FX_API fx_status fx_compressor_create(
@@ -48,7 +48,7 @@ FX_API fx_status fx_compressor_create(
#endif
FX_API fx_status fx_compressor_get_buffer_size(
fx_type type,
fx_type_id type,
fx_compressor_mode mode,
size_t *inbuf_size,
size_t *outbuf_size);
@@ -16,11 +16,11 @@ FX_DECLARE_TYPE(fx_cstream);
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_cstream)
FX_TYPE_CLASS_DECLARATION_END(fx_cstream)
FX_API fx_type fx_cstream_get_type(void);
FX_API fx_type_id fx_cstream_get_type(void);
FX_API fx_status fx_cstream_open(
fx_stream *endpoint,
fx_type compressor_type,
fx_type_id compressor_type,
enum fx_compressor_mode mode,
fx_cstream **out);
+1 -1
View File
@@ -16,7 +16,7 @@ FX_DECLARE_TYPE(fx_zstd_compressor);
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_zstd_compressor)
FX_TYPE_CLASS_DECLARATION_END(fx_compressor)
FX_API fx_type fx_zstd_compressor_get_type(void);
FX_API fx_type_id fx_zstd_compressor_get_type(void);
FX_API fx_status fx_zstd_compressor_get_buffer_size(
fx_compressor_mode mode,
+1 -1
View File
@@ -96,7 +96,7 @@ int main(int argc, const char **argv)
}
fx_status status = FX_SUCCESS;
fx_type compressor_type = FX_TYPE_ZSTD_COMPRESSOR;
fx_type_id compressor_type = FX_TYPE_ZSTD_COMPRESSOR;
fx_compressor *compressor = fx_object_create(compressor_type);
size_t inbuf_size, outbuf_size;
+2 -2
View File
@@ -9,7 +9,7 @@
#define BUF_SIZE 32
static int compress(fx_type compressor_type, FILE *in, FILE *out)
static int compress(fx_type_id compressor_type, FILE *in, FILE *out)
{
fx_stream *out_stream = fx_stream_open_fp(out);
@@ -48,7 +48,7 @@ static int compress(fx_type compressor_type, FILE *in, FILE *out)
return 0;
}
static int decompress(fx_type compressor_type, FILE *in, FILE *out)
static int decompress(fx_type_id compressor_type, FILE *in, FILE *out)
{
fx_stream *in_stream = fx_stream_open_fp(in);