adds documentation and removes unused parameters references #376

This commit is contained in:
Peter Thorson
2014-10-07 10:04:54 -04:00
parent fe6d82e7a3
commit e8d25d22bc
20 changed files with 215 additions and 73 deletions

View File

@@ -101,12 +101,14 @@ if env['CXX'].startswith('g++'):
#env.Append(CCFLAGS = ['-Wconversion'])
env.Append(CCFLAGS = ['-Wcast-align'])
env.Append(CCFLAGS = ['-Wshadow'])
env.Append(CCFLAGS = ['-Werror=unused-parameter'])
elif env['CXX'].startswith('clang++'):
#env.Append(CCFLAGS = ['-Wcast-align'])
#env.Append(CCFLAGS = ['-Wglobal-constructors'])
#env.Append(CCFLAGS = ['-Wconversion'])
env.Append(CCFLAGS = ['-Wno-padded'])
env.Append(CCFLAGS = ['-Wshadow'])
env.Append(CCFLAGS = ['-Werror=unused-parameter'])
# Wpadded
# Wsign-conversion

View File

@@ -86,11 +86,11 @@ public:
m_endpoint.run();
}
void on_socket_init(websocketpp::connection_hdl hdl) {
void on_socket_init(websocketpp::connection_hdl) {
m_socket_init = std::chrono::high_resolution_clock::now();
}
context_ptr on_tls_init(websocketpp::connection_hdl hdl) {
context_ptr on_tls_init(websocketpp::connection_hdl) {
m_tls_init = std::chrono::high_resolution_clock::now();
context_ptr ctx(new boost::asio::ssl::context(boost::asio::ssl::context::tlsv1));
@@ -108,11 +108,11 @@ public:
m_open = std::chrono::high_resolution_clock::now();
m_endpoint.send(hdl, "", websocketpp::frame::opcode::text);
}
void on_message(websocketpp::connection_hdl hdl, message_ptr msg) {
void on_message(websocketpp::connection_hdl hdl, message_ptr) {
m_message = std::chrono::high_resolution_clock::now();
m_endpoint.close(hdl,websocketpp::close::status::going_away,"");
}
void on_close(websocketpp::connection_hdl hdl) {
void on_close(websocketpp::connection_hdl) {
m_close = std::chrono::high_resolution_clock::now();
std::cout << "Socket Init: " << std::chrono::duration_cast<dur_type>(m_socket_init-m_start).count() << std::endl;

View File

@@ -5,7 +5,7 @@
typedef websocketpp::server<websocketpp::config::asio> server;
void on_message(websocketpp::connection_hdl hdl, server::message_ptr msg) {
void on_message(websocketpp::connection_hdl, server::message_ptr msg) {
std::cout << msg->get_payload() << std::endl;
}

View File

@@ -65,7 +65,7 @@ public:
}
// The open handler will signal that we are ready to start sending telemetry
void on_open(websocketpp::connection_hdl hdl) {
void on_open(websocketpp::connection_hdl) {
m_client.get_alog().write(websocketpp::log::alevel::app,
"Connection opened, starting telemetry!");
@@ -74,7 +74,7 @@ public:
}
// The close handler will signal that we should stop sending telemetry
void on_close(websocketpp::connection_hdl hdl) {
void on_close(websocketpp::connection_hdl) {
m_client.get_alog().write(websocketpp::log::alevel::app,
"Connection closed, stopping telemetry!");
@@ -83,7 +83,7 @@ public:
}
// The fail handler will signal that we should stop sending telemetry
void on_fail(websocketpp::connection_hdl hdl) {
void on_fail(websocketpp::connection_hdl) {
m_client.get_alog().write(websocketpp::log::alevel::app,
"Connection failed, stopping telemetry!");

View File

@@ -80,7 +80,7 @@ void on_message(server* s, websocketpp::connection_hdl hdl, message_ptr msg) {
s->send(hdl, msg->get_payload(), msg->get_opcode());
}
void on_socket_init(websocketpp::connection_hdl hdl, boost::asio::ip::tcp::socket & s) {
void on_socket_init(websocketpp::connection_hdl, boost::asio::ip::tcp::socket & s) {
boost::asio::ip::tcp::no_delay option(true);
s.set_option(option);
}

View File

@@ -40,7 +40,7 @@ struct stub {
stub() : recycled(false) {}
bool recycle(message * msg) {
bool recycle(message *) {
this->recycled = true;
return false;
}

View File

@@ -10,7 +10,7 @@ Import('polyfill_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
BOOST_LIBS = boostlibs(['unit_test_framework','random'],env) + [platform_libs]
BOOST_LIBS = boostlibs(['unit_test_framework','random','system'],env) + [platform_libs]
objs = env.Object('random_none_boost.o', ["none.cpp"], LIBS = BOOST_LIBS)
objs += env.Object('random_device_boost.o', ["random_device.cpp"], LIBS = BOOST_LIBS)

View File

@@ -107,7 +107,7 @@ struct config {
// Mock context that does no validation
typedef websocketpp::lib::shared_ptr<boost::asio::ssl::context> context_ptr;
context_ptr on_tls_init(websocketpp::connection_hdl hdl) {
context_ptr on_tls_init(websocketpp::connection_hdl) {
return context_ptr(new boost::asio::ssl::context(boost::asio::ssl::context::tlsv1));
}

View File

@@ -273,11 +273,11 @@ void run_dummy_client(std::string port) {
}
}
bool on_ping(websocketpp::connection_hdl, std::string payload) {
bool on_ping(websocketpp::connection_hdl, std::string) {
return false;
}
void cancel_on_open(server * s, websocketpp::connection_hdl hdl) {
void cancel_on_open(server * s, websocketpp::connection_hdl) {
s->stop_listening();
}
@@ -294,25 +294,25 @@ void ping_on_open(T * c, std::string payload, websocketpp::connection_hdl hdl) {
con->ping(payload);
}
void fail_on_pong(websocketpp::connection_hdl hdl, std::string payload) {
void fail_on_pong(websocketpp::connection_hdl, std::string) {
BOOST_FAIL( "expected no pong handler" );
}
void fail_on_pong_timeout(websocketpp::connection_hdl hdl, std::string payload) {
void fail_on_pong_timeout(websocketpp::connection_hdl, std::string) {
BOOST_FAIL( "expected no pong timeout" );
}
void req_pong(std::string expected_payload, websocketpp::connection_hdl hdl,
void req_pong(std::string expected_payload, websocketpp::connection_hdl,
std::string payload)
{
BOOST_CHECK_EQUAL( expected_payload, payload );
}
void fail_on_open(websocketpp::connection_hdl hdl) {
void fail_on_open(websocketpp::connection_hdl) {
BOOST_FAIL( "expected no open handler" );
}
void delay(websocketpp::connection_hdl hdl, long duration) {
void delay(websocketpp::connection_hdl, long duration) {
sleep(duration);
}

View File

@@ -315,7 +315,7 @@ BOOST_AUTO_TEST_CASE( async_read_at_least2 ) {
BOOST_CHECK( std::string(buf,10) == "abcdefgxxx" );
}
void timer_callback_stub(const websocketpp::lib::error_code & ec) {}
void timer_callback_stub(websocketpp::lib::error_code const &) {}
BOOST_AUTO_TEST_CASE( set_timer ) {
stub_con::ptr con(new stub_con(true,alogger,elogger));

View File

@@ -45,7 +45,7 @@ public:
/// A fake lock guard implementation that does nothing
class fake_lock_guard {
public:
explicit fake_lock_guard(fake_mutex foo) {}
explicit fake_lock_guard(fake_mutex) {}
~fake_lock_guard() {}
};
} // namespace none_impl

View File

@@ -434,7 +434,7 @@ public:
* @param response The server response attribute list to validate
* @return Validation error or 0 on success
*/
lib::error_code validate_offer(http::attribute_list const & response) {
lib::error_code validate_offer(http::attribute_list const &) {
return make_error_code(error::general);
}

View File

@@ -39,20 +39,75 @@ namespace log {
/// Stub logger that ignores all input
class stub {
public:
explicit stub(channel_type_hint::value h) {}
stub(level c, channel_type_hint::value h) {}
/// Construct the logger
/**
* @param hint A channel type specific hint for how to construct the logger
*/
explicit stub(channel_type_hint::value) {}
/// Construct the logger
/**
* @param default_channels A set of channels to statically enable
* @param hint A channel type specific hint for how to construct the logger
*/
stub(level, channel_type_hint::value) {}
_WEBSOCKETPP_CONSTEXPR_TOKEN_ stub() {}
void set_channels(level channels) {}
void clear_channels(level channels) {}
/// Dynamically enable the given list of channels
/**
* All operations on the stub logger are no-ops and all arguments are
* ignored
*
* @param channels The package of channels to enable
*/
void set_channels(level) {}
/// Dynamically disable the given list of channels
/**
* All operations on the stub logger are no-ops and all arguments are
* ignored
*
* @param channels The package of channels to disable
*/
void clear_channels(level) {}
void write(level channel, std::string const & msg) {}
void write(level channel, char const * msg) {}
/// Write a string message to the given channel
/**
* Writing on the stub logger is a no-op and all arguments are ignored
*
* @param channel The package of channels to write to
* @param msg The message to write
*/
void write(level, std::string const &) {}
/// Write a cstring message to the given channel
/**
* Writing on the stub logger is a no-op and all arguments are ignored
*
* @param channel The package of channels to write to
* @param msg The message to write
*/
void write(level, char const *) {}
_WEBSOCKETPP_CONSTEXPR_TOKEN_ bool static_test(level channel) const {
/// Test whether a channel is statically enabled
/**
* The stub logger has no channels so all arguments are ignored and
* `static_test` always returns false.
*
* @param channel The package of channels to test
*/
_WEBSOCKETPP_CONSTEXPR_TOKEN_ bool static_test(level) const {
return false;
}
bool dynamic_test(level channel) {
/// Test whether a channel is dynamically enabled
/**
* The stub logger has no channels so all arguments are ignored and
* `dynamic_test` always returns false.
*
* @param channel The package of channels to test
*/
bool dynamic_test(level) {
return false;
}
};

View File

@@ -141,15 +141,32 @@ public:
return lib::error_code();
}
// outgoing client connection processing is not supported for this version
lib::error_code client_handshake_request(request_type& req, uri_ptr uri,
std::vector<std::string> const & subprotocols) const
/// Fill in a set of request headers for a client connection request
/**
* The Hybi 00 processor only implements incoming connections so this will
* always return an error.
*
* @param [out] req Set of headers to fill in
* @param [in] uri The uri being connected to
* @param [in] subprotocols The list of subprotocols to request
*/
lib::error_code client_handshake_request(request_type &, uri_ptr,
std::vector<std::string> const &) const
{
return error::make_error_code(error::no_protocol_support);
}
lib::error_code validate_server_handshake_response(request_type const & req,
response_type & res) const
/// Validate the server's response to an outgoing handshake request
/**
* The Hybi 00 processor only implements incoming connections so this will
* always return an error.
*
* @param req The original request sent
* @param res The reponse to generate
* @return An error code, 0 on success, non-zero for other errors
*/
lib::error_code validate_server_handshake_response(request_type const &,
response_type &) const
{
return error::make_error_code(error::no_protocol_support);
}
@@ -164,9 +181,16 @@ public:
return r.get_header("Origin");
}
// hybi00 doesn't support subprotocols so there never will be any requested
lib::error_code extract_subprotocols(request_type const & req,
std::vector<std::string> & subprotocol_list)
/// Extracts requested subprotocols from a handshake request
/**
* hybi00 doesn't support subprotocols so there never will be any requested
*
* @param [in] req The request to extract from
* @param [out] subprotocol_list A reference to a vector of strings to store
* the results in.
*/
lib::error_code extract_subprotocols(request_type const &,
std::vector<std::string> &)
{
return lib::error_code();
}
@@ -319,18 +343,44 @@ public:
return lib::error_code();
}
lib::error_code prepare_ping(std::string const & in, message_ptr out) const
/// Prepare a ping frame
/**
* Hybi 00 doesn't support pings so this will always return an error
*
* @param in The string to use for the ping payload
* @param out The message buffer to prepare the ping in.
* @return Status code, zero on success, non-zero on failure
*/
lib::error_code prepare_ping(std::string const &, message_ptr) const
{
return lib::error_code(error::no_protocol_support);
}
lib::error_code prepare_pong(const std::string & in, message_ptr out) const
/// Prepare a pong frame
/**
* Hybi 00 doesn't support pongs so this will always return an error
*
* @param in The string to use for the pong payload
* @param out The message buffer to prepare the pong in.
* @return Status code, zero on success, non-zero on failure
*/
lib::error_code prepare_pong(const std::string &, message_ptr) const
{
return lib::error_code(error::no_protocol_support);
}
lib::error_code prepare_close(close::status::value code,
std::string const & reason, message_ptr out) const
/// Prepare a close frame
/**
* Hybi 00 doesn't support the close code or reason so these parameters are
* ignored.
*
* @param code The close code to send
* @param reason The reason string to send
* @param out The message buffer to prepare the fame in
* @return Status code, zero on success, non-zero on failure
*/
lib::error_code prepare_close(close::status::value, std::string const &,
message_ptr out) const
{
if (!out) {
return lib::error_code(error::invalid_arguments);

View File

@@ -48,9 +48,17 @@ public:
explicit hybi07(bool secure, bool p_is_server, msg_manager_ptr manager, rng_type& rng)
: hybi08<config>(secure, p_is_server, manager, rng) {}
// outgoing client connection processing is not supported for this version
lib::error_code client_handshake_request(request_type & req, uri_ptr uri,
std::vector<std::string> const & subprotocols) const
/// Fill in a set of request headers for a client connection request
/**
* The Hybi 07 processor only implements incoming connections so this will
* always return an error.
*
* @param [out] req Set of headers to fill in
* @param [in] uri The uri being connected to
* @param [in] subprotocols The list of subprotocols to request
*/
lib::error_code client_handshake_request(request_type &, uri_ptr,
std::vector<std::string> const &) const
{
return error::make_error_code(error::no_protocol_support);
}

View File

@@ -49,9 +49,17 @@ public:
explicit hybi08(bool secure, bool p_is_server, msg_manager_ptr manager, rng_type& rng)
: hybi13<config>(secure, p_is_server, manager, rng) {}
// outgoing client connection processing is not supported for this version
lib::error_code client_handshake_request(request_type& req, uri_ptr uri,
std::vector<std::string> const & subprotocols) const
/// Fill in a set of request headers for a client connection request
/**
* The Hybi 08 processor only implements incoming connections so this will
* always return an error.
*
* @param [out] req Set of headers to fill in
* @param [in] uri The uri being connected to
* @param [in] subprotocols The list of subprotocols to request
*/
lib::error_code client_handshake_request(request_type &, uri_ptr,
std::vector<std::string> const &) const
{
return error::make_error_code(error::no_protocol_support);
}

View File

@@ -182,7 +182,13 @@ public:
return lib::error_code();
}
lib::error_code client_handshake_request(request_type& req, uri_ptr
/// Fill in a set of request headers for a client connection request
/**
* @param [out] req Set of headers to fill in
* @param [in] uri The uri being connected to
* @param [in] subprotocols The list of subprotocols to request
*/
lib::error_code client_handshake_request(request_type & req, uri_ptr
uri, std::vector<std::string> const & subprotocols) const
{
req.set_method("GET");
@@ -219,6 +225,12 @@ public:
return lib::error_code();
}
/// Validate the server's response to an outgoing handshake request
/**
* @param req The original request sent
* @param res The reponse to generate
* @return An error code, 0 on success, non-zero for other errors
*/
lib::error_code validate_server_handshake_response(request_type const & req,
response_type& res) const
{

View File

@@ -212,8 +212,10 @@ public:
* Reads the Sec-WebSocket-Extensions header and determines if any of the
* requested extensions are supported by this processor. If they are their
* settings data is initialized.
*
* @param request The request headers to look at.
*/
virtual err_str_pair negotiate_extensions(request_type const & request) {
virtual err_str_pair negotiate_extensions(request_type const &) {
return err_str_pair();
}
@@ -253,9 +255,7 @@ public:
/// Validate the server's response to an outgoing handshake request
/**
* @param req The original request sent
*
* @param res The reponse to generate
*
* @return An error code, 0 on success, non-zero for other errors
*/
virtual lib::error_code validate_server_handshake_response(request_type
@@ -272,10 +272,9 @@ public:
* Extracts a list of all subprotocols that the client has requested in the
* given opening handshake request.
*
* @param req The request to extract from
*
* @param subprotocol_list A reference to a vector of strings to store the
* results in.
* @param [in] req The request to extract from
* @param [out] subprotocol_list A reference to a vector of strings to store
* the results in.
*/
virtual lib::error_code extract_subprotocols(const request_type & req,
std::vector<std::string> & subprotocol_list) = 0;
@@ -289,11 +288,8 @@ public:
* interpreted by a protocol processor into discrete frames.
*
* @param buf Buffer from which bytes should be read.
*
* @param len Length of buffer
*
* @param ec Reference to an error code to return any errors in
*
* @return Number of bytes processed
*/
virtual size_t consume(uint8_t *buf, size_t len, lib::error_code & ec) = 0;
@@ -346,9 +342,7 @@ public:
* other than length. Payload need not be UTF-8.
*
* @param in The string to use for the ping payload
*
* @param out The message buffer to prepare the ping in.
*
* @return Status code, zero on success, non-zero on failure
*/
virtual lib::error_code prepare_ping(std::string const & in, message_ptr out) const
@@ -360,9 +354,7 @@ public:
* other than length. Payload need not be UTF-8.
*
* @param in The string to use for the pong payload
*
* @param out The message buffer to prepare the pong in.
*
* @return Status code, zero on success, non-zero on failure
*/
virtual lib::error_code prepare_pong(std::string const & in, message_ptr out) const
@@ -376,11 +368,8 @@ public:
* indicate no code. If no code is supplied a reason may not be specified.
*
* @param code The close code to send
*
* @param reason The reason string to send
*
* @param out The message buffer to prepare the fame in
*
* @return Status code, zero on success, non-zero on failure
*/
virtual lib::error_code prepare_close(close::status::value code,

View File

@@ -645,7 +645,7 @@ public:
return new_timer;
}
/// Timer callback
/// Timer handler
/**
* The timer pointer is included to ensure the timer isn't destroyed until
* after it has expired.
@@ -654,7 +654,7 @@ public:
* @param callback The function to call back
* @param ec A status code indicating an error, if any.
*/
void handle_timer(timer_ptr t, timer_handler callback,
void handle_timer(timer_ptr, timer_handler callback,
boost::system::error_code const & ec)
{
if (ec) {
@@ -842,7 +842,16 @@ protected:
}
}
void handle_resolve_timeout(timer_ptr dns_timer, connect_handler callback,
/// DNS resolution timeout handler
/**
* The timer pointer is included to ensure the timer isn't destroyed until
* after it has expired.
*
* @param dns_timer Pointer to the timer in question
* @param callback The function to call back
* @param ec A status code indicating an error, if any.
*/
void handle_resolve_timeout(timer_ptr, connect_handler callback,
lib::error_code const & ec)
{
lib::error_code ret_ec;
@@ -941,7 +950,17 @@ protected:
}
}
void handle_connect_timeout(transport_con_ptr tcon, timer_ptr con_timer,
/// Asio connect timeout handler
/**
* The timer pointer is included to ensure the timer isn't destroyed until
* after it has expired.
*
* @param tcon Pointer to the transport connection that is being connected
* @param con_timer Pointer to the timer in question
* @param callback The function to call back
* @param ec A status code indicating an error, if any.
*/
void handle_connect_timeout(transport_con_ptr tcon, timer_ptr,
connect_handler callback, lib::error_code const & ec)
{
lib::error_code ret_ec;

View File

@@ -158,8 +158,7 @@ protected:
* @param strand A shared pointer to the connection's asio strand
* @param is_server Whether or not the endpoint is a server or not.
*/
lib::error_code init_asio (io_service_ptr service, strand_ptr strand,
bool is_server)
lib::error_code init_asio (io_service_ptr service, strand_ptr, bool)
{
if (m_state != UNINITIALIZED) {
return socket::make_error_code(socket::error::invalid_state);
@@ -246,7 +245,7 @@ protected:
* @param ec The error code to translate_ec
* @return The translated error code
*/
lib::error_code translate_ec(boost::system::error_code ec) {
lib::error_code translate_ec(boost::system::error_code) {
// We don't know any more information about this error so pass through
return make_error_code(transport::error::pass_through);
}