8#ifndef DISCORD_REQUEST_H 
    9#define DISCORD_REQUEST_H 
   24#define _RET_COPY_TYPED(dest, src)                                            \ 
   26        memcpy(&(dest), &(src), sizeof(discord_ret_default_fields));          \ 
   27        (dest).has_type = true;                                               \ 
   28        (dest).done.typed = (cast_done_typed)(src).done;                      \ 
   29        (dest).sync = (src).sync;                                             \ 
   32#define _RET_COPY_TYPELESS(dest, src)                                         \ 
   34        memcpy(&(dest), &(src), sizeof(discord_ret_default_fields));          \ 
   35        (dest).has_type = false;                                              \ 
   36        (dest).done.typeless = (src).done;                                    \ 
   37        (dest).sync = (void *)(src).sync;                                     \ 
   48#define DISCORD_ATTR_INIT(attr, type, ret, _reason)                           \ 
   50        (attr).response.size = sizeof(struct type);                           \ 
   51        (attr).response.init = (cast_init)type##_init;                        \ 
   52        (attr).response.from_json = (cast_from_json)type##_from_json;         \ 
   53        (attr).response.cleanup = (cast_cleanup)type##_cleanup;               \ 
   54        (attr).reason = _reason;                                              \ 
   55        if (ret) _RET_COPY_TYPED(attr.dispatch, *ret);                        \ 
   66#define DISCORD_ATTR_LIST_INIT(attr, type, ret, _reason)                      \ 
   68        (attr).response.size = sizeof(struct type);                           \ 
   69        (attr).response.from_json = (cast_from_json)type##_from_json;         \ 
   70        (attr).response.cleanup = (cast_cleanup)type##_cleanup;               \ 
   71        (attr).reason = _reason;                                              \ 
   72        if (ret) _RET_COPY_TYPED(attr.dispatch, *ret);                        \ 
   83#define DISCORD_ATTR_BLANK_INIT(attr, ret, _reason)                           \ 
   85        (attr).reason = _reason;                                              \ 
   86        if (ret) _RET_COPY_TYPELESS(attr.dispatch, *ret);                     \ 
   94#define DISCORD_ATTACHMENTS_IDS_INIT(attchs)                                  \ 
   96        for (int i = 0; i < attchs->size; ++i) {                              \ 
   97            attchs->array[i].id = (u64snowflake)i;                            \ 
size_t(* cast_from_json)(const char *, size_t, void *)
Definition: discord-request.h:17
 
void(* cast_init)(void *)
Definition: discord-request.h:15
 
void(* cast_done_typed)(struct discord *, struct discord_response *, const void *)
Definition: discord-request.h:12
 
void(* cast_cleanup)(void *)
Definition: discord-request.h:16
 
The response for the completed request.
Definition: discord-response.h:12
 
Definition: discord-request.h:20
 
DISCORD_RET_DEFAULT_FIELDS
Definition: discord-request.h:21
 
The Discord client handler.
Definition: discord-internal.h:1182