1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

c++: establish a single place for opaque forward references

This commit is contained in:
Andy Green 2019-08-17 06:55:11 +01:00
parent d7f0521aeb
commit 2a98642cff
9 changed files with 30 additions and 31 deletions

View file

@ -41,6 +41,11 @@ extern "C" {
#include "lws_config.h"
/* place for one-shot opaque forward references */
struct lws_sequencer;
struct lws_dsh;
/*
* CARE: everything using cmake defines needs to be below here
*/

View file

@ -76,7 +76,7 @@ typedef struct lws_abs {
const struct lws_abs_transport *at;
const lws_token_map_t *at_tokens;
lws_seq_t *seq;
struct lws_sequencer *seq;
void *opaque_user_data;
/*

View file

@ -50,8 +50,6 @@ enum lws_client_connect_ssl_connection_flags {
* */
};
typedef struct lws_sequencer lws_seq_t;
/** struct lws_client_connect_info - parameters to connect with when using
* lws_client_connect_via_info() */
@ -122,7 +120,7 @@ struct lws_client_connect_info {
* tokens
*/
lws_seq_t *seq;
struct lws_sequencer *seq;
/**< NULL, or an lws_seq_t that wants to be given messages about
* this wsi's lifecycle as it connects, errors or closes.
*/

View file

@ -42,8 +42,6 @@
* All management structures exist inside the allocated buffer.
*/
typedef struct lws_dsh lws_dsh_t;
/**
* lws_dsh_create() - Allocate a DSH buffer
*
@ -64,7 +62,7 @@ typedef struct lws_dsh lws_dsh_t;
*
* Returns an opaque pointer to the dsh, or NULL if allocation failed.
*/
LWS_VISIBLE LWS_EXTERN lws_dsh_t *
LWS_VISIBLE LWS_EXTERN struct lws_dsh *
lws_dsh_create(lws_dll2_owner_t *owner, size_t buffer_size, int count_kinds);
/**
@ -82,7 +80,7 @@ lws_dsh_create(lws_dll2_owner_t *owner, size_t buffer_size, int count_kinds);
* unmigratable objects are cleanly destroyed.
*/
LWS_VISIBLE LWS_EXTERN void
lws_dsh_destroy(lws_dsh_t **pdsh);
lws_dsh_destroy(struct lws_dsh **pdsh);
/**
* lws_dsh_alloc_tail() - make a suballocation inside a dsh
@ -103,8 +101,8 @@ lws_dsh_destroy(lws_dsh_t **pdsh);
* The suballocation is added to the kind-specific FIFO at the tail.
*/
LWS_VISIBLE LWS_EXTERN int
lws_dsh_alloc_tail(lws_dsh_t *dsh, int kind, const void *src1, size_t size1,
const void *src2, size_t size2);
lws_dsh_alloc_tail(struct lws_dsh *dsh, int kind, const void *src1,
size_t size1, const void *src2, size_t size2);
/**
* lws_dsh_free() - free a suballocation from the dsh
@ -133,7 +131,7 @@ lws_dsh_free(void **obj);
* free list.
*/
LWS_VISIBLE LWS_EXTERN int
lws_dsh_get_head(lws_dsh_t *dsh, int kind, void **obj, size_t *size);
lws_dsh_get_head(struct lws_dsh *dsh, int kind, void **obj, size_t *size);
/**
* lws_dsh_describe() - DEBUG BUILDS ONLY dump the dsh to the logs
@ -144,4 +142,4 @@ lws_dsh_get_head(lws_dsh_t *dsh, int kind, void **obj, size_t *size);
* Useful information for debugging lws_dsh
*/
LWS_VISIBLE LWS_EXTERN void
lws_dsh_describe(lws_dsh_t *dsh, const char *desc);
lws_dsh_describe(struct lws_dsh *dsh, const char *desc);

View file

@ -57,8 +57,6 @@ typedef enum lws_seq_cb_return {
LWSSEQ_RET_DESTROY
} lws_seq_cb_return_t;
typedef struct lws_sequencer lws_seq_t; /* opaque */
/*
* handler for this sequencer. Return 0 if OK else nonzero to destroy the
* sequencer. LWSSEQ_DESTROYED will be called back to the handler so it can
@ -98,7 +96,7 @@ typedef struct lws_seq_info {
*
* pt locking is used to protect the related data structures.
*/
LWS_VISIBLE LWS_EXTERN lws_seq_t *
LWS_VISIBLE LWS_EXTERN struct lws_sequencer *
lws_seq_create(lws_seq_info_t *info);
/**
@ -112,7 +110,7 @@ lws_seq_create(lws_seq_info_t *info);
* set to NULL.
*/
LWS_VISIBLE LWS_EXTERN void
lws_seq_destroy(lws_seq_t **seq);
lws_seq_destroy(struct lws_sequencer **seq);
/**
* lws_seq_queue_event() - queue an event on the given sequencer
@ -132,7 +130,7 @@ lws_seq_destroy(lws_seq_t **seq);
* values here.
*/
LWS_VISIBLE LWS_EXTERN int
lws_seq_queue_event(lws_seq_t *seq, lws_seq_events_t e, void *data,
lws_seq_queue_event(struct lws_sequencer *seq, lws_seq_events_t e, void *data,
void *aux);
/**
@ -152,7 +150,7 @@ lws_seq_queue_event(lws_seq_t *seq, lws_seq_events_t e, void *data,
* close message yet.
*/
LWS_VISIBLE LWS_EXTERN int
lws_seq_check_wsi(lws_seq_t *seq, struct lws *wsi);
lws_seq_check_wsi(struct lws_sequencer *seq, struct lws *wsi);
#define LWSSEQTO_NONE 0
@ -182,7 +180,7 @@ lws_seq_check_wsi(lws_seq_t *seq, struct lws *wsi);
* react appropriately.
*/
LWS_VISIBLE LWS_EXTERN int
lws_seq_timeout_us(lws_seq_t *seq, lws_usec_t us);
lws_seq_timeout_us(struct lws_sequencer *seq, lws_usec_t us);
/**
* lws_seq_from_user(): get the lws_seq_t pointer from the user ptr
@ -197,7 +195,7 @@ lws_seq_timeout_us(lws_seq_t *seq, lws_usec_t us);
* size of the lws_seq_t is unknown to user code, this helper does it for
* you.
*/
LWS_VISIBLE LWS_EXTERN lws_seq_t *
LWS_VISIBLE LWS_EXTERN struct lws_sequencer *
lws_seq_from_user(void *u);
/**
@ -210,7 +208,7 @@ lws_seq_from_user(void *u);
* step considering a global sequencer lifetime limit.
*/
LWS_VISIBLE LWS_EXTERN lws_usec_t
lws_seq_us_since_creation(lws_seq_t *seq);
lws_seq_us_since_creation(struct lws_sequencer *seq);
/**
* lws_seq_name(): get the name of this sequencer
@ -221,7 +219,7 @@ lws_seq_us_since_creation(lws_seq_t *seq);
* annotate logging when then are multiple sequencers in play.
*/
LWS_VISIBLE LWS_EXTERN const char *
lws_seq_name(lws_seq_t *seq);
lws_seq_name(struct lws_sequencer *seq);
/**
* lws_seq_get_context(): get the lws_context sequencer was created on
@ -232,4 +230,4 @@ lws_seq_name(lws_seq_t *seq);
* pointer handy.
*/
LWS_VISIBLE LWS_EXTERN struct lws_context *
lws_seq_get_context(lws_seq_t *seq);
lws_seq_get_context(struct lws_sequencer *seq);

View file

@ -194,9 +194,9 @@ lws_timed_callback_vh_protocol_us(struct lws_vhost *vh,
const struct lws_protocols *prot, int reason,
lws_usec_t us);
struct lws_sorted_usec_list;
typedef struct lws_sorted_usec_list lws_sorted_usec_list_t;
typedef void (*sul_cb_t)(lws_sorted_usec_list_t *sul);
typedef void (*sul_cb_t)(struct lws_sorted_usec_list *sul);
typedef struct lws_sorted_usec_list {
struct lws_dll2 list; /* simplify the code by keeping this at start */

View file

@ -275,11 +275,9 @@ typedef struct lws_dsh_obj_head {
int kind;
} lws_dsh_obj_head_t;
typedef struct lws_dsh lws_dsh_t;
typedef struct lws_dsh_obj {
lws_dll2_t list; /* must be first */
lws_dsh_t *dsh; /* invalid when on free list */
struct lws_dsh *dsh; /* invalid when on free list */
size_t size; /* invalid when on free list */
size_t asize;
} lws_dsh_obj_t;
@ -581,7 +579,7 @@ struct lws {
const struct lws_protocols *protocol;
struct lws_dll2 same_vh_protocol;
lws_seq_t *seq; /* associated sequencer if any */
struct lws_sequencer *seq; /* associated sequencer if any */
struct lws_dll2 dll_buflist; /* guys with pending rxflow */

View file

@ -305,7 +305,5 @@ int
lws_http_proxy_start(struct lws *wsi, const struct lws_http_mount *hit,
char *uri_ptr, char ws);
typedef struct lws_sorted_usec_list lws_sorted_usec_list_t;
void
lws_sul_http_ah_lifecheck(lws_sorted_usec_list_t *sul);

View file

@ -61,7 +61,10 @@ MACRO(require_lws_config reqconfig _val result)
endif()
ENDMACRO()
set(requirements 1)
require_lws_config(LWS_WITH_STRUCT_JSON 1 requirements)
if (requirements)
add_executable(${SAMP} ${SRCS})
@ -71,3 +74,4 @@ ENDMACRO()
else()
target_link_libraries(${SAMP} websockets)
endif()
endif()