mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 16:47:28 +01:00
Handle structs that contain structs.
This commit is contained in:
1 parent
b3c12e05cf
commit
86c6b79e1a
9 files changed
+263
-96
No files matched your search
+49
-3
@@ -73,7 +73,7 @@ bool puffs_gif_status_is_error(puffs_gif_status s);
|
||||
|
||||
const char* puffs_gif_status_string(puffs_gif_status s);
|
||||
|
||||
// ---------------- Public Structs
|
||||
// ---------------- Structs
|
||||
|
||||
typedef struct {
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
@@ -93,6 +93,21 @@ typedef struct {
|
||||
} private_impl;
|
||||
} puffs_gif_lzw_decoder;
|
||||
|
||||
typedef struct {
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so. Instead, use the
|
||||
// puffs_gif_decoder_etc functions.
|
||||
//
|
||||
// In C++, these fields would be "private", but C does not support that.
|
||||
//
|
||||
// It is a struct, not a struct*, so that it can be stack allocated.
|
||||
struct {
|
||||
puffs_gif_status status;
|
||||
uint32_t magic;
|
||||
puffs_gif_lzw_decoder f_lzw;
|
||||
} private_impl;
|
||||
} puffs_gif_decoder;
|
||||
|
||||
// ---------------- Public Constructor and Destructor Prototypes
|
||||
|
||||
// puffs_gif_lzw_decoder_constructor is a constructor function.
|
||||
@@ -106,6 +121,17 @@ void puffs_gif_lzw_decoder_constructor(puffs_gif_lzw_decoder* self,
|
||||
|
||||
void puffs_gif_lzw_decoder_destructor(puffs_gif_lzw_decoder* self);
|
||||
|
||||
// puffs_gif_decoder_constructor is a constructor function.
|
||||
//
|
||||
// It should be called before any other puffs_gif_decoder_* function.
|
||||
//
|
||||
// Pass PUFFS_VERSION and 0 for puffs_version and for_internal_use_only.
|
||||
void puffs_gif_decoder_constructor(puffs_gif_decoder* self,
|
||||
uint32_t puffs_version,
|
||||
uint32_t for_internal_use_only);
|
||||
|
||||
void puffs_gif_decoder_destructor(puffs_gif_decoder* self);
|
||||
|
||||
// ---------------- Public Function Prototypes
|
||||
|
||||
void puffs_gif_lzw_decoder_set_literal_width(puffs_gif_lzw_decoder* self,
|
||||
@@ -164,8 +190,6 @@ const char* puffs_gif_status_string(puffs_gif_status s) {
|
||||
return "gif: unknown status";
|
||||
}
|
||||
|
||||
// ---------------- Private Structs
|
||||
|
||||
// ---------------- Private Constructor and Destructor Prototypes
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
@@ -209,6 +233,28 @@ void puffs_gif_lzw_decoder_destructor(puffs_gif_lzw_decoder* self) {
|
||||
}
|
||||
}
|
||||
|
||||
void puffs_gif_decoder_constructor(puffs_gif_decoder* self,
|
||||
uint32_t puffs_version,
|
||||
uint32_t for_internal_use_only) {
|
||||
if (!self) {
|
||||
return;
|
||||
}
|
||||
if (puffs_version != PUFFS_VERSION) {
|
||||
self->private_impl.status = puffs_gif_error_bad_version;
|
||||
return;
|
||||
}
|
||||
if (for_internal_use_only != PUFFS_ALREADY_ZEROED) {
|
||||
memset(self, 0, sizeof(*self));
|
||||
}
|
||||
self->private_impl.magic = PUFFS_MAGIC;
|
||||
}
|
||||
|
||||
void puffs_gif_decoder_destructor(puffs_gif_decoder* self) {
|
||||
if (!self) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- Function Implementations
|
||||
|
||||
void puffs_gif_lzw_decoder_set_literal_width(puffs_gif_lzw_decoder* self,
|
||||
|
||||
+27
-1
@@ -73,7 +73,7 @@ bool puffs_gif_status_is_error(puffs_gif_status s);
|
||||
|
||||
const char* puffs_gif_status_string(puffs_gif_status s);
|
||||
|
||||
// ---------------- Public Structs
|
||||
// ---------------- Structs
|
||||
|
||||
typedef struct {
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
@@ -93,6 +93,21 @@ typedef struct {
|
||||
} private_impl;
|
||||
} puffs_gif_lzw_decoder;
|
||||
|
||||
typedef struct {
|
||||
// Do not access the private_impl's fields directly. There is no API/ABI
|
||||
// compatibility or safety guarantee if you do so. Instead, use the
|
||||
// puffs_gif_decoder_etc functions.
|
||||
//
|
||||
// In C++, these fields would be "private", but C does not support that.
|
||||
//
|
||||
// It is a struct, not a struct*, so that it can be stack allocated.
|
||||
struct {
|
||||
puffs_gif_status status;
|
||||
uint32_t magic;
|
||||
puffs_gif_lzw_decoder f_lzw;
|
||||
} private_impl;
|
||||
} puffs_gif_decoder;
|
||||
|
||||
// ---------------- Public Constructor and Destructor Prototypes
|
||||
|
||||
// puffs_gif_lzw_decoder_constructor is a constructor function.
|
||||
@@ -106,6 +121,17 @@ void puffs_gif_lzw_decoder_constructor(puffs_gif_lzw_decoder* self,
|
||||
|
||||
void puffs_gif_lzw_decoder_destructor(puffs_gif_lzw_decoder* self);
|
||||
|
||||
// puffs_gif_decoder_constructor is a constructor function.
|
||||
//
|
||||
// It should be called before any other puffs_gif_decoder_* function.
|
||||
//
|
||||
// Pass PUFFS_VERSION and 0 for puffs_version and for_internal_use_only.
|
||||
void puffs_gif_decoder_constructor(puffs_gif_decoder* self,
|
||||
uint32_t puffs_version,
|
||||
uint32_t for_internal_use_only);
|
||||
|
||||
void puffs_gif_decoder_destructor(puffs_gif_decoder* self);
|
||||
|
||||
// ---------------- Public Function Prototypes
|
||||
|
||||
void puffs_gif_lzw_decoder_set_literal_width(puffs_gif_lzw_decoder* self,
|
||||
|
||||
Reference in new issue
Block a user