Skip to content

Commit

Permalink
add __tb_typeref__ keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Aug 23, 2016
1 parent e0e3306 commit e20b121
Show file tree
Hide file tree
Showing 28 changed files with 46 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/tbox/asio/dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ __tb_extern_c_enter__
*/

/// the aicp dns ref type
typedef struct{}* tb_aicp_dns_ref_t;
typedef __tb_typeref__(aicp_dns);

/// the aicp dns done func type
typedef tb_void_t (*tb_aicp_dns_done_func_t)(tb_aicp_dns_ref_t dns, tb_char_t const* host, tb_ipaddr_ref_t addr, tb_cpointer_t priv);
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/asio/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ __tb_extern_c_enter__
*/

/// the aicp http ref type
typedef struct{}* tb_aicp_http_ref_t;
typedef __tb_typeref__(aicp_http);

/*! the aicp http open func type
*
Expand Down
8 changes: 4 additions & 4 deletions src/tbox/asio/prefix.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
*/

/// the aioo ref type
typedef struct{}* tb_aioo_ref_t;
typedef __tb_typeref__(aioo);

/// the aico ref type
typedef struct{}* tb_aico_ref_t;
typedef __tb_typeref__(aico);

/*! the aico pool ref type
*
Expand Down Expand Up @@ -119,7 +119,7 @@ typedef struct{}* tb_aico_ref_t;
* </pre>
*
*/
typedef struct{}* tb_aicp_ref_t;
typedef __tb_typeref__(aicp);

/*! the asio poll pool type
*
Expand All @@ -132,6 +132,6 @@ typedef struct{}* tb_aicp_ref_t;
* </pre>
*
*/
typedef struct{}* tb_aiop_ref_t;
typedef __tb_typeref__(aiop);

#endif
2 changes: 1 addition & 1 deletion src/tbox/asio/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ __tb_extern_c_enter__
*/

/// the aicp ssl ref type
typedef struct{}* tb_aicp_ssl_ref_t;
typedef __tb_typeref__(aicp_ssl);

/*! the aicp ssl open func type
*
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/container/bloom_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ __tb_extern_c_enter__
* c = p^(1/k)
* s = m / n = 2k / (2c + c * c)
*/
typedef struct{}* tb_bloom_filter_ref_t;
typedef __tb_typeref__(bloom_filter);

/// the probability of false positives
typedef enum __tb_bloom_filter_probability_e
Expand Down
4 changes: 2 additions & 2 deletions src/tbox/database/sql.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ typedef enum __tb_database_sql_type_e
}tb_database_sql_type_e;

/// the database sql ref type
typedef struct{}* tb_database_sql_ref_t;
typedef __tb_typeref__(database_sql);

/// the database sql statement ref type
typedef struct{}* tb_database_sql_statement_ref_t;
typedef __tb_typeref__(database_sql_statement);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/memory/fixed_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ __tb_extern_c_enter__
*
* </pre>
*/
typedef struct{}* tb_fixed_pool_ref_t;
typedef __tb_typeref__(fixed_pool);

/// the item init func type
typedef tb_bool_t (*tb_fixed_pool_item_init_func_t)(tb_pointer_t data, tb_cpointer_t priv);
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/memory/impl/static_fixed_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ __tb_extern_c_enter__
* pred
* </pre>
*/
typedef struct{}* tb_static_fixed_pool_ref_t;
typedef __tb_typeref__(static_fixed_pool);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/memory/string_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ __tb_extern_c_enter__
*/

/// the string pool ref type
typedef struct{}* tb_string_pool_ref_t;
typedef __tb_typeref__(string_pool);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/network/cookies.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ __tb_extern_c_enter__
*/

/// the cookies ref type
typedef struct{}* tb_cookies_ref_t;
typedef __tb_typeref__(cookies);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/network/dns/looker.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/

/// the dns looker type
typedef struct{}* tb_dns_looker_ref_t;
typedef __tb_typeref__(dns_looker);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/network/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ typedef struct __tb_http_range_t
}tb_http_range_t;

/// the http ref type
typedef struct{}* tb_http_ref_t;
typedef __tb_typeref__(http);

/*! the http head func type
*
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/network/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ typedef tb_long_t (*tb_ssl_func_writ_t)(tb_cpointer_t priv, tb_byte_t const* d
typedef tb_long_t (*tb_ssl_func_wait_t)(tb_cpointer_t priv, tb_size_t code, tb_long_t timeout);

/// the ssl ref type
typedef struct{}* tb_ssl_ref_t;
typedef __tb_typeref__(ssl);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/platform/dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ __tb_extern_c_enter__
*/

/// the dynamic ref type
typedef struct{}* tb_dynamic_ref_t;
typedef __tb_typeref__(dynamic);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/platform/ifaddrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ typedef struct __tb_ifaddrs_interface_t
}tb_ifaddrs_interface_t, *tb_ifaddrs_interface_ref_t;

/// the ifaddrs type
typedef struct{}* tb_ifaddrs_ref_t;
typedef __tb_typeref__(ifaddrs);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
4 changes: 2 additions & 2 deletions src/tbox/platform/ltimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ typedef enum __tb_ltimer_tick_e
typedef tb_timer_task_func_t tb_ltimer_task_func_t;

/// the ltimer ref type
typedef struct{}* tb_ltimer_ref_t;
typedef __tb_typeref__(ltimer);

/// the ltimer task ref type
typedef struct{}* tb_ltimer_task_ref_t;
typedef __tb_typeref__(ltimer_task);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/platform/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ typedef struct __tb_process_attr_t
}tb_process_attr_t, *tb_process_attr_ref_t;

/// the process ref type
typedef struct{}* tb_process_ref_t;
typedef __tb_typeref__(process);

/// the process wait info type
typedef struct __tb_process_waitinfo_t
Expand Down
6 changes: 3 additions & 3 deletions src/tbox/platform/thread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ __tb_extern_c_enter__
*/

/// the thread pool ref type
typedef struct{}* tb_thread_pool_ref_t;
typedef __tb_typeref__(thread_pool);

/// the thread pool task ref type
typedef struct{}* tb_thread_pool_task_ref_t;
typedef __tb_typeref__(thread_pool_task);

/// the thread pool worker ref type
typedef struct{}* tb_thread_pool_worker_ref_t;
typedef __tb_typeref__(thread_pool_worker);

/// the thread pool priv exit func type
typedef tb_void_t (*tb_thread_pool_priv_exit_func_t)(tb_thread_pool_worker_ref_t worker, tb_cpointer_t priv);
Expand Down
4 changes: 2 additions & 2 deletions src/tbox/platform/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ __tb_extern_c_enter__
typedef tb_void_t (*tb_timer_task_func_t)(tb_bool_t killed, tb_cpointer_t priv);

/// the timer ref type
typedef struct{}* tb_timer_ref_t;
typedef __tb_typeref__(timer);

/// the timer task ref type
typedef struct{}* tb_timer_task_ref_t;
typedef __tb_typeref__(timer_task);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
3 changes: 3 additions & 0 deletions src/tbox/prefix/keyword.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@
# define __tb_no_sanitize_address__
#endif

// the object reference type, .e.g tb_xxx_ref_t
#define __tb_typeref__(object) struct __tb_##object##_dummy_t{tb_int_t dummy;}* tb_##object##_ref_t

// macros
#define __tb_mstring__(x) #x
#define __tb_mstring_ex__(x) __tb_mstring__(x)
Expand Down
18 changes: 9 additions & 9 deletions src/tbox/prefix/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,31 +161,31 @@ typedef tb_atomic_t tb_spinlock_t;
typedef tb_spinlock_t* tb_spinlock_ref_t;

/// the pool ref type
typedef struct{}* tb_pool_ref_t;
typedef __tb_typeref__(pool);

/// the file ref type
typedef struct{}* tb_file_ref_t;
typedef __tb_typeref__(file);

/// the socket ref type
typedef struct{}* tb_socket_ref_t;
typedef __tb_typeref__(socket);

/// the event ref type
typedef struct{}* tb_event_ref_t;
typedef __tb_typeref__(event);

/// the mutex ref type
typedef struct{}* tb_mutex_ref_t;
typedef __tb_typeref__(mutex);

/// the thread ref type
typedef struct{}* tb_thread_ref_t;
typedef __tb_typeref__(thread);

/// the semaphore ref type
typedef struct{}* tb_semaphore_ref_t;
typedef __tb_typeref__(semaphore);

/// the stream ref type
typedef struct{}* tb_stream_ref_t;
typedef __tb_typeref__(stream);

/// the async stream ref type
typedef struct{}* tb_async_stream_ref_t;
typedef __tb_typeref__(async_stream);

/// the time type
typedef tb_hong_t tb_time_t;
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/regex/regex.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ __tb_extern_c_enter__
*/

/// the regex ref type
typedef struct{}* tb_regex_ref_t;
typedef __tb_typeref__(regex);

/// the regex match type
typedef struct _tb_regex_match_t
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/stream/async_transfer.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ typedef tb_bool_t (*tb_async_transfer_ctrl_func_t)(tb_async_stream_ref_t i
typedef tb_bool_t (*tb_async_transfer_done_func_t)(tb_size_t state, tb_hize_t offset, tb_hong_t size, tb_hize_t save, tb_size_t rate, tb_cpointer_t priv);

/// the async transfer ref type
typedef struct{}* tb_async_transfer_ref_t;
typedef __tb_typeref__(async_transfer);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/stream/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ typedef enum __tb_stream_filter_ctrl_e
}tb_stream_filter_ctrl_e;

/// the stream filter ref type
typedef struct{}* tb_stream_filter_ref_t;
typedef __tb_typeref__(stream_filter);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/stream/transfer_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ __tb_extern_c_enter__
*/

/// the transfer pool ref type
typedef struct{}* tb_transfer_pool_ref_t;
typedef __tb_typeref__(transfer_pool);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/utils/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ typedef struct __tb_option_item_t
}tb_option_item_t;

/// the option ref type
typedef struct{}* tb_option_ref_t;
typedef __tb_typeref__(option);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/xml/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ typedef enum __tb_xml_reader_event_t
}tb_xml_reader_event_t;

/// the xml reader ref type
typedef struct{}* tb_xml_reader_ref_t;
typedef __tb_typeref__(xml_reader);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down
2 changes: 1 addition & 1 deletion src/tbox/xml/writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ __tb_extern_c_enter__
*/

/// the xml writer ref type
typedef struct{}* tb_xml_writer_ref_t;
typedef __tb_typeref__(xml_writer);

/* //////////////////////////////////////////////////////////////////////////////////////
* interfaces
Expand Down

0 comments on commit e20b121

Please sign in to comment.