Helpers for wrapping Discord data types for easier management.
More...
|
| #define | __CAT(_a, _b) _a##_b |
| |
| #define | _CAT(_a, _b) __CAT(_a, _b) |
| |
| #define | _EXPECT_CONTAINER__struct |
| |
| #define | _EXPECT_CONTAINER__union |
| |
| #define | _DISCORD_SYMBOL_WITHOUT_CONTAINER(_symbol) _CAT(_EXPECT_CONTAINER__, _symbol) |
| |
| #define | discord_data_wrap reflectc_wrap |
| | The Discord data wrap structure. More...
|
| |
| #define | discord_data_wrap_from(_symbol, _client, _data) |
| | Wrap a Discord data type into a reflectc_wrap structure. More...
|
| |
| #define | discord_data_cleanup(_client, _data) discord_data_free(discord_get_registry((_client)), (_data)) |
| | Cleanup a Discord data type wrapped into a reflectc_wrap structure. More...
|
| |
| #define | discord_data_unwrap(_client, _data) discord_data_release(discord_get_registry((_client)), (_data)) |
| | Drop the wrap cached for _data without touching its contents. More...
|
| |
Helpers for wrapping Discord data types for easier management.
◆ __CAT
| #define __CAT |
( |
|
_a, |
|
|
|
_b |
|
) |
| _a##_b |
◆ _CAT
| #define _CAT |
( |
|
_a, |
|
|
|
_b |
|
) |
| __CAT(_a, _b) |
◆ _EXPECT_CONTAINER__struct
| #define _EXPECT_CONTAINER__struct |
◆ _EXPECT_CONTAINER__union
| #define _EXPECT_CONTAINER__union |
◆ _DISCORD_SYMBOL_WITHOUT_CONTAINER
| #define _DISCORD_SYMBOL_WITHOUT_CONTAINER |
( |
|
_symbol | ) |
_CAT(_EXPECT_CONTAINER__, _symbol) |
◆ discord_data_wrap
| #define discord_data_wrap reflectc_wrap |
The Discord data wrap structure.
This struct is used to wrap Discord data types for easier management
◆ discord_data_wrap_from
| #define discord_data_wrap_from |
( |
|
_symbol, |
|
|
|
_client, |
|
|
|
_data |
|
) |
| |
Value:
discord_get_registry((_client)), _data, NULL)
#define _DISCORD_SYMBOL_WITHOUT_CONTAINER(_symbol)
Definition: discord.h:462
#define _CAT(_a, _b)
Definition: discord.h:459
Wrap a Discord data type into a reflectc_wrap structure.
- Parameters
-
| _symbol | the Discord data type symbol (with struct or union) |
| _client | the client created with discord_from_token() |
| _data | the Discord data type to be wrapped |
- Returns
- the discord_data_wrap Discord data type
◆ discord_data_cleanup
Cleanup a Discord data type wrapped into a reflectc_wrap structure.
Releases everything discord_data_from_json() allocated for _data — strings, nested objects, list arrays — plus the reflect-c wrap and its registry entry. Every non-NULL pointer member is treated as owned: do not call this on hand-built structs pointing at literals or stack objects.
- Parameters
-
- Examples
- components.c, embed.c, fetch-messages.c, manual-dm.c, and slash-commands2.c.
◆ discord_data_unwrap
Drop the wrap cached for _data without touching its contents.
discord_data_to_json() caches a reflect-c wrap keyed by _data's address; release it with this once done encoding a caller-owned struct (e.g. stack-built params). Without it the stale registry entry would be wrongly reused by a future object at the same address. Decoded structs don't need this — discord_data_cleanup() releases both the data and the wrap.
- Parameters
-
| _client | the client created with discord_from_token() |
| _data | the encoded Discord data type to drop the wrap for |
◆ discord_data_free()
| void discord_data_free |
( |
struct reflectc * |
registry, |
|
|
void * |
data |
|
) |
| |
◆ discord_data_release()
| void discord_data_release |
( |
struct reflectc * |
registry, |
|
|
void * |
data |
|
) |
| |