From 443feabad9caf05b2087d487246f77b03d010f92 Mon Sep 17 00:00:00 2001 From: robocop Date: Fri, 28 Mar 2008 13:36:19 +0000 Subject: [PATCH] Since Vlad and Alex did the hard work, I took the comment from Mike (approx 6 years ago) and did the small change function->method. --- src/remote/interface.cpp | 43 ++++++++++++++-------------- src/remote/parser.cpp | 2 +- src/remote/remote.h | 61 ++++++++++++++++++++-------------------- src/remote/server.cpp | 8 +++--- 4 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/remote/interface.cpp b/src/remote/interface.cpp index 6730d52fca..27151d8d4e 100644 --- a/src/remote/interface.cpp +++ b/src/remote/interface.cpp @@ -1344,7 +1344,7 @@ ISC_STATUS GDS_DSQL_EXECUTE2(ISC_STATUS* user_status, message->msg_address = in_msg; statement->rsr_flags &= ~Rsr::FETCHED; statement->rsr_format = statement->rsr_bind_format; - stmt_clear_exception(statement); + statement->clearException(); /* set up the packet for the other guy... */ @@ -1572,7 +1572,7 @@ ISC_STATUS GDS_DSQL_EXECUTE_IMMED2(ISC_STATUS* user_status, message->msg_address = in_msg; - stmt_clear_exception(statement); + statement->clearException(); /* set up the packet for the other guy... */ @@ -1681,11 +1681,11 @@ ISC_STATUS GDS_DSQL_FETCH(ISC_STATUS* user_status, if (!(statement->rsr_flags & Rsr::FETCHED)) { - stmt_raise_exception(statement); + statement->raiseException(); statement->rsr_flags &= ~(Rsr::EOF_SET | Rsr::STREAM_ERR | Rsr::PAST_EOF); statement->rsr_rows_pending = 0; - stmt_clear_exception(statement); + statement->clearException(); REM_MSG message = statement->rsr_message; if (message) @@ -1779,7 +1779,7 @@ ISC_STATUS GDS_DSQL_FETCH(ISC_STATUS* user_status, /* We've reached eof or there was an error */ !(statement->rsr_flags & (Rsr::EOF_SET | Rsr::STREAM_ERR)) && /* No error pending */ - (!stmt_have_exception(statement) ))) + (!statement->haveException() ))) { /* set up the packet for the other guy... */ @@ -1835,10 +1835,10 @@ ISC_STATUS GDS_DSQL_FETCH(ISC_STATUS* user_status, /* We've either got data, or some is on the way, or we have an error, or we have EOF */ fb_assert(statement->rsr_msgs_waiting || (statement->rsr_rows_pending > 0) - || stmt_have_exception(statement) + || statement->haveException() || statement->rsr_flags & (Rsr::EOF_SET)); - while (!stmt_have_exception(statement) /* received a database error */ + while (!statement->haveException() /* received a database error */ &&!(statement->rsr_flags & (Rsr::EOF_SET)) /* reached end of cursor */ &&!(statement->rsr_msgs_waiting >= 2) /* Have looked ahead for end of batch */ &&!(statement->rsr_rows_pending == 0)) @@ -2308,7 +2308,7 @@ ISC_STATUS GDS_DSQL_SET_CURSOR(ISC_STATUS* user_status, try { - stmt_raise_exception(statement); + statement->raiseException(); /* make sure the protocol supports it */ @@ -2361,7 +2361,7 @@ ISC_STATUS GDS_DSQL_SET_CURSOR(ISC_STATUS* user_status, if (!receive_response(rdb, packet)) { return user_status[1]; } - stmt_raise_exception(statement); + statement->raiseException(); } catch (const Firebird::Exception& ex) { @@ -2402,7 +2402,7 @@ ISC_STATUS GDS_DSQL_SQL_INFO(ISC_STATUS* user_status, try { - stmt_raise_exception(statement); + statement->raiseException(); /* make sure the protocol supports it */ @@ -2413,7 +2413,7 @@ ISC_STATUS GDS_DSQL_SQL_INFO(ISC_STATUS* user_status, status = info(user_status, rdb, op_info_sql, statement->rsr_id, 0, item_length, items, 0, 0, buffer_length, buffer); - stmt_raise_exception(statement); + statement->raiseException(); } catch (const Firebird::Exception& ex) { @@ -4791,13 +4791,13 @@ static bool clear_stmt_que(rem_port* port, ISC_STATUS* user_status, RSR statemen return false; // We must receive isc_req_sync as we did fetch after EOF - fb_assert(stmt_have_exception(statement) == isc_req_sync); + fb_assert(statement->haveException() == isc_req_sync); } // hvlad: clear isc_req_sync error as it is received because of our batch // fetching code, not because of wrong client application - if (stmt_have_exception(statement) == isc_req_sync) { - stmt_clear_exception(statement); + if (statement->haveException() == isc_req_sync) { + statement->clearException(); } return true; @@ -4913,7 +4913,7 @@ static bool batch_dsql_fetch(rem_port* port, /* save the status vector in a safe place */ - stmt_save_exception(statement, tmp_status, false); + statement->saveException(tmp_status, false); statement->rsr_rows_pending = 0; --statement->rsr_batch_count; @@ -6096,8 +6096,7 @@ static bool receive_packet_noqueue(rem_port* port, if (!check_response(rdb, &p->packet)) { // save error within the corresponding statement - stmt_save_exception(statement, - p->packet.p_resp.p_resp_status_vector, false); + statement->saveException(p->packet.p_resp.p_resp_status_vector, false); } else { @@ -6149,7 +6148,7 @@ static bool receive_queued_packet(rem_port* port, /* Grab first queue entry */ - RMTQUE que_inst = port->port_receive_rmtque; + rmtque* que_inst = port->port_receive_rmtque; /* Receive the data */ @@ -6176,7 +6175,7 @@ static void enqueue_receive(rem_port* port, * Functional description * **************************************/ - RMTQUE que_inst = new rmtque; + rmtque* const que_inst = new rmtque; /* Prepare a queue entry */ @@ -6187,7 +6186,7 @@ static void enqueue_receive(rem_port* port, que_inst->rmtque_rdb = rdb; /* Walk to the end of the current queue */ - RMTQUE* queptr = &port->port_receive_rmtque; + rmtque** queptr = &port->port_receive_rmtque; while (*queptr) queptr = &(*queptr)->rmtque_next; @@ -6211,7 +6210,7 @@ static void dequeue_receive( rem_port* port) /* Grab first queue entry & de-queue it*/ - RMTQUE que_inst = port->port_receive_rmtque; + rmtque* que_inst = port->port_receive_rmtque; port->port_receive_rmtque = que_inst->rmtque_next; que_inst->rmtque_next = NULL; @@ -6376,7 +6375,7 @@ static void release_statement( RSR* statement) delete (*statement)->rsr_user_select_format; } delete (*statement)->rsr_select_format; - stmt_release_exception(*statement); + (*statement)->releaseException(); REMOTE_release_messages((*statement)->rsr_message); delete *statement; diff --git a/src/remote/parser.cpp b/src/remote/parser.cpp index ba3698c176..dc11d73731 100644 --- a/src/remote/parser.cpp +++ b/src/remote/parser.cpp @@ -67,7 +67,7 @@ REM_MSG PARSE_messages(const UCHAR* blr, USHORT blr_length) const USHORT msg_number = *blr++; USHORT count = *blr++; count += (*blr++) << 8; - rem_fmt* format = new rem_fmt(count); + rem_fmt* const format = new rem_fmt(count); #ifdef DEBUG_REMOTE_MEMORY printf("PARSE_messages allocate format %x\n", format); #endif diff --git a/src/remote/remote.h b/src/remote/remote.h index 07075000f2..a445667a15 100644 --- a/src/remote/remote.h +++ b/src/remote/remote.h @@ -215,7 +215,7 @@ struct rem_fmt : public Firebird::GlobalStorage Firebird::Array fmt_desc; public: - rem_fmt(size_t rpt) : + explicit rem_fmt(size_t rpt) : fmt_length(0), fmt_net_length(0), fmt_count(0), fmt_version(0), fmt_desc(getPool(), rpt) { @@ -238,7 +238,7 @@ typedef struct Message : public Firebird::GlobalStorage UCharArrayAutoPtr msg_buffer; /* Allocated message */ public: - Message(size_t rpt) : + explicit Message(size_t rpt) : msg_next(0), #ifdef SCROLLABLE_CURSORS msg_prior(0), msg_absolute(0), @@ -310,7 +310,7 @@ public: #endif public: - Rrq(size_t rpt) : + explicit Rrq(size_t rpt) : rrq_rdb(0), rrq_rtr(0), rrq_next(0), rrq_levels(0), rrq_handle(0), rrq_id(0), rrq_max_msg(0), rrq_level(0), rrq_rpt(getPool(), rpt) @@ -374,6 +374,12 @@ public: rsr_rows_pending(0), rsr_msgs_waiting(0), rsr_reorder_level(0), rsr_batch_count(0) { } + void saveException(const ISC_STATUS* status, bool overwrite); + void clearException(); + ISC_STATUS haveException(); + void raiseException(); + void releaseException(); + static ISC_STATUS badHandle() { return isc_bad_req_handle; } } *RSR; @@ -391,6 +397,8 @@ private: } ptr; public: + RemoteObject() { ptr.rdb = 0; } + template R* get(R* r) { @@ -401,62 +409,55 @@ public: return r; } -public: void operator=(Rdb* v) { ptr.rdb = v; } void operator=(Rtr* v) { ptr.rtr = v; } void operator=(Rbl* v) { ptr.rbl = v; } void operator=(Rrq* v) { ptr.rrq = v; } void operator=(Rsr* v) { ptr.rsr = v; } -public: operator Rdb*() { return get(ptr.rdb); } operator Rtr*() { return get(ptr.rtr); } operator Rbl*() { return get(ptr.rbl); } operator Rrq*() { return get(ptr.rrq); } operator Rsr*() { return get(ptr.rsr); } - bool isMissing() { return ptr.rdb == NULL; } + bool isMissing() const { return ptr.rdb == NULL; } void release() { ptr.rdb = 0; } }; -// will be methods of remote statement class -inline void stmt_save_exception(RSR statement, const ISC_STATUS* status, bool overwrite) +inline void Rsr::saveException(const ISC_STATUS* status, bool overwrite) { - if (!statement->rsr_status) { - statement->rsr_status = new Firebird::StatusHolder(); + if (!rsr_status) { + rsr_status = new Firebird::StatusHolder(); } - if (overwrite || !statement->rsr_status->getError()) { - statement->rsr_status->save(status); + if (overwrite || !rsr_status->getError()) { + rsr_status->save(status); } } -inline void stmt_clear_exception(RSR statement) +inline void Rsr::clearException() { - if (statement->rsr_status) - statement->rsr_status->clear(); + if (rsr_status) + rsr_status->clear(); } -inline ISC_STATUS stmt_have_exception(RSR statement) +inline ISC_STATUS Rsr::haveException() { - return (statement->rsr_status ? - statement->rsr_status->getError() : 0); + return (rsr_status ? rsr_status->getError() : 0); } -inline void stmt_raise_exception(RSR statement) +inline void Rsr::raiseException() { - if (statement->rsr_status) - statement->rsr_status->raise(); + if (rsr_status) + rsr_status->raise(); } -inline void stmt_release_exception(RSR statement) +inline void Rsr::releaseException() { - if (statement->rsr_status) - { - delete statement->rsr_status; - statement->rsr_status = NULL; - } + delete rsr_status; + rsr_status = NULL; } #include "../remote/xdr.h" @@ -503,7 +504,7 @@ public: // port_flags -const USHORT PORT_symmetric = 0x0001; // Server/client archiectures are symmetic +const USHORT PORT_symmetric = 0x0001; // Server/client architectures are symmetic const USHORT PORT_rpc = 0x0002; // Protocol is remote procedure call const USHORT PORT_async = 0x0004; // Port is asynchronous channel for events const USHORT PORT_no_oob = 0x0008; // Don't send out of band data @@ -849,7 +850,7 @@ public: typedef bool (*t_rmtque_fn)(rem_port*, rmtque*, ISC_STATUS*, USHORT); -typedef struct rmtque : public Firebird::GlobalStorage +struct rmtque : public Firebird::GlobalStorage { rmtque* rmtque_next; // Next entry in queue void* rmtque_parm; // What request has response in queue @@ -863,6 +864,6 @@ public: rmtque() : rmtque_next(0), rmtque_parm(0), rmtque_message(0), rmtque_rdb(0), rmtque_function(0) { } -} *RMTQUE; +}; #endif // REMOTE_REMOTE_H diff --git a/src/remote/server.cpp b/src/remote/server.cpp index 1a60e60726..4683ab4ed3 100644 --- a/src/remote/server.cpp +++ b/src/remote/server.cpp @@ -84,7 +84,7 @@ typedef struct srvr : public Firebird::GlobalStorage USHORT srvr_flags; public: - srvr(srvr *servers, rem_port* port, USHORT flags) : + srvr(srvr* servers, rem_port* port, USHORT flags) : srvr_next(servers), srvr_parent_port(port), srvr_port_type(port->port_type), srvr_flags(flags) { } @@ -2165,7 +2165,7 @@ ISC_STATUS rem_port::fetch(P_SQLDATA * sqldata, PACKET* sendL) if (!(statement->rsr_flags & Rsr::FETCHED)) { statement->rsr_flags &= ~(Rsr::EOF_SET | Rsr::STREAM_ERR); - stmt_clear_exception(statement); + statement->clearException(); REM_MSG message = statement->rsr_message; if (message != NULL) { statement->rsr_buffer = message; @@ -2323,7 +2323,7 @@ ISC_STATUS rem_port::fetch(P_SQLDATA * sqldata, PACKET* sendL) /* If already have an error queued, don't overwrite it */ if (!(statement->rsr_flags & Rsr::STREAM_ERR)) { statement->rsr_flags |= Rsr::STREAM_ERR; - stmt_save_exception(statement, status_vector, true); + statement->saveException(status_vector, true); } } if (s == 100) @@ -4010,7 +4010,7 @@ static void release_statement( RSR * statement) delete (*statement)->rsr_select_format; delete (*statement)->rsr_bind_format; - stmt_release_exception(*statement); + (*statement)->releaseException(); REMOTE_release_messages((*statement)->rsr_message); delete *statement;