diff options
40 files changed, 102 insertions, 90 deletions
diff --git a/include/anope.h b/include/anope.h index c67b1decb..a5056d50c 100644 --- a/include/anope.h +++ b/include/anope.h @@ -596,25 +596,37 @@ template<typename T> inline T convertTo(const Anope::string &s, bool failIfLefto return x; } -/** Debug cast to be used instead of dynamic_cast, this uses dynamic_cast - * for debug builds and static_cast on releass builds to speed up the program - * because dynamic_cast relies on RTTI. +/** Casts to be used instead of dynamic_cast, this uses dynamic_cast + * for debug builds and static_cast/reinterpret_cast on releass builds + * to speed up the program because dynamic_cast relies on RTTI. */ #ifdef DEBUG_BUILD # include <typeinfo> #endif -template<typename T, typename O> inline T debug_cast(O ptr) +template<typename T, typename O> inline T anope_dynamic_static_cast(O ptr) { #ifdef DEBUG_BUILD T ret = dynamic_cast<T>(ptr); if (ptr != NULL && ret == NULL) - throw CoreException(Anope::string("debug_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail"); + throw CoreException(Anope::string("anope_dynamic_static_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail"); return ret; #else return static_cast<T>(ptr); #endif } +template<typename T, typename O> inline T anope_dynamic_reinterpret_cast(O ptr) +{ +#ifdef DEBUG_BUILD + T ret = dynamic_cast<T>(ptr); + if (ptr != NULL && ret == NULL) + throw CoreException(Anope::string("anope_dynamic_reinterpret_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail"); + return ret; +#else + return reinterpret_cast<T>(ptr); +#endif +} + /*************************************************************************/ /** Class with the ability to keep flags on items, they should extend from this diff --git a/include/extensible.h b/include/extensible.h index e0281c197..6e6d42fb7 100644 --- a/include/extensible.h +++ b/include/extensible.h @@ -90,7 +90,7 @@ class CoreExport Extensible { extensible_map::const_iterator it = this->extension_items.find(key); if (it != this->extension_items.end()) - return debug_cast<T>(it->second); + return anope_dynamic_static_cast<T>(it->second); return NULL; } diff --git a/include/modes.h b/include/modes.h index 0fb822b7e..52545d1b9 100644 --- a/include/modes.h +++ b/include/modes.h @@ -113,7 +113,7 @@ enum ModeClass /** This class is the basis of all modes in Anope */ -class CoreExport Mode : public virtual Base +class CoreExport Mode : public Base { public: /* Class of mode this is */ diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index a37446df2..30c291da3 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -50,7 +50,7 @@ class AccessChanAccess : public ChanAccess { if (access->provider->name == "access/access") { - const AccessChanAccess *aaccess = debug_cast<const AccessChanAccess *>(access); + const AccessChanAccess *aaccess = anope_dynamic_static_cast<const AccessChanAccess *>(access); return aaccess->level; } else @@ -160,7 +160,7 @@ class CommandCSAccess : public Command service_reference<AccessProvider> provider("AccessProvider", "access/access"); if (!provider) return; - AccessChanAccess *access = debug_cast<AccessChanAccess *>(provider->Create()); + AccessChanAccess *access = anope_dynamic_static_cast<AccessChanAccess *>(provider->Create()); access->ci = ci; access->mask = mask; access->creator = u->nick; diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index 9b5a6753c..3be4d53c7 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -63,7 +63,7 @@ Serializable* EntryMsg::unserialize(Serializable *obj, Serialize::Data &data) if (obj) { - EntryMsg *msg = debug_cast<EntryMsg *>(obj); + EntryMsg *msg = anope_dynamic_static_cast<EntryMsg *>(obj); msg->ci = ci; data["creator"] >> msg->creator; data["message"] >> msg->message; diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index 222409eca..35c2aac0a 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -196,7 +196,7 @@ class CommandCSFlags : public Command service_reference<AccessProvider> provider("AccessProvider", "access/flags"); if (!provider) return; - FlagsChanAccess *access = debug_cast<FlagsChanAccess *>(provider->Create()); + FlagsChanAccess *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create()); access->ci = ci; access->mask = mask; access->creator = u->nick; diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index 425a54a01..452b3b365 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -22,7 +22,7 @@ class CommandCSMode : public Command const Anope::string accesses[] = { "VOICE", "HALFOP", "OPDEOP", "PROTECT", "OWNER", "" }; const ChannelModeName modes[] = { CMODE_VOICE, CMODE_HALFOP, CMODE_OP, CMODE_PROTECT, CMODE_OWNER }; - ChannelModeStatus *cms = debug_cast<ChannelModeStatus *>(cm); + ChannelModeStatus *cms = anope_dynamic_static_cast<ChannelModeStatus *>(cm); AccessGroup access = ci->AccessFor(u); unsigned short u_level = 0; @@ -32,7 +32,7 @@ class CommandCSMode : public Command ChannelMode *cm2 = ModeManager::FindChannelModeByName(modes[i]); if (cm2 == NULL || cm2->Type != MODE_STATUS) continue; - ChannelModeStatus *cms2 = debug_cast<ChannelModeStatus *>(cm2); + ChannelModeStatus *cms2 = anope_dynamic_static_cast<ChannelModeStatus *>(cm2); if (cms2->Level > u_level) u_level = cms2->Level; } diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index 3f7b276f7..ec3ac708f 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -61,7 +61,7 @@ struct SeenInfo : Serializable { SeenInfo *s; if (obj) - s = debug_cast<SeenInfo *>(obj); + s = anope_dynamic_static_cast<SeenInfo *>(obj); else s = new SeenInfo(); diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index ab40f9fdc..4a2e8fec5 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -47,7 +47,7 @@ struct CSMiscData : ExtensibleItem, Serializable CSMiscData *d; if (obj) { - d = debug_cast<CSMiscData *>(obj); + d = anope_dynamic_static_cast<CSMiscData *>(obj); d->ci = ci; data["name"] >> d->name; data["data"] >> d->data; diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index d5898083e..803202a26 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -50,7 +50,7 @@ struct ChanSuspend : ExtensibleItem, Serializable ChanSuspend *cs; if (obj) - cs = debug_cast<ChanSuspend *>(obj); + cs = anope_dynamic_static_cast<ChanSuspend *>(obj); else cs = new ChanSuspend(); diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp index 807cbe1f6..18adeadb0 100644 --- a/modules/commands/cs_xop.cpp +++ b/modules/commands/cs_xop.cpp @@ -149,7 +149,7 @@ class XOPChanAccess : public ChanAccess { if (access->provider->name == "access/xop") { - const XOPChanAccess *xaccess = debug_cast<const XOPChanAccess *>(access); + const XOPChanAccess *xaccess = anope_dynamic_static_cast<const XOPChanAccess *>(access); return xaccess->type; } else @@ -263,7 +263,7 @@ class XOPBase : public Command service_reference<AccessProvider> provider("AccessProvider", "access/xop"); if (!provider) return; - XOPChanAccess *acc = debug_cast<XOPChanAccess *>(provider->Create()); + XOPChanAccess *acc = anope_dynamic_static_cast<XOPChanAccess *>(provider->Create()); acc->ci = ci; acc->mask = mask; acc->creator = u->nick; diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index e44fa06e2..ae1077a68 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -55,7 +55,7 @@ struct HostRequest : ExtensibleItem, Serializable HostRequest *req; if (obj) - req = debug_cast<HostRequest *>(obj); + req = anope_dynamic_static_cast<HostRequest *>(obj); else req = new HostRequest; req->nick = na->nick; diff --git a/modules/commands/ms_cancel.cpp b/modules/commands/ms_cancel.cpp index 059ca2f06..f6f863e71 100644 --- a/modules/commands/ms_cancel.cpp +++ b/modules/commands/ms_cancel.cpp @@ -39,8 +39,8 @@ class CommandMSCancel : public Command source.Reply(ischan ? CHAN_X_NOT_REGISTERED : _(NICK_X_NOT_REGISTERED), nname.c_str()); else { - ChannelInfo *ci; - NickAlias *na; + ChannelInfo *ci = NULL; + NickAlias *na = NULL; if (ischan) ci = cs_findchan(nname); else diff --git a/modules/commands/ms_del.cpp b/modules/commands/ms_del.cpp index 0ad906c49..bfee5124f 100644 --- a/modules/commands/ms_del.cpp +++ b/modules/commands/ms_del.cpp @@ -52,7 +52,7 @@ class CommandMSDel : public Command User *u = source.u; MemoInfo *mi; - ChannelInfo *ci; + ChannelInfo *ci = NULL; Anope::string numstr = !params.empty() ? params[0] : "", chan; if (!numstr.empty() && numstr[0] == '#') diff --git a/modules/commands/ms_info.cpp b/modules/commands/ms_info.cpp index 3f132f1d2..05d241ced 100644 --- a/modules/commands/ms_info.cpp +++ b/modules/commands/ms_info.cpp @@ -28,7 +28,7 @@ class CommandMSInfo : public Command const MemoInfo *mi; const NickAlias *na = NULL; - ChannelInfo *ci; + ChannelInfo *ci = NULL; const Anope::string &nname = !params.empty() ? params[0] : ""; int hardmax = 0; diff --git a/modules/commands/ms_list.cpp b/modules/commands/ms_list.cpp index bbf245b46..1ba0644aa 100644 --- a/modules/commands/ms_list.cpp +++ b/modules/commands/ms_list.cpp @@ -27,7 +27,7 @@ class CommandMSList : public Command User *u = source.u; Anope::string param = !params.empty() ? params[0] : "", chan; - ChannelInfo *ci; + ChannelInfo *ci = NULL; const MemoInfo *mi; if (!param.empty() && param[0] == '#') diff --git a/modules/commands/ms_read.cpp b/modules/commands/ms_read.cpp index c9d0c4345..341d8f828 100644 --- a/modules/commands/ms_read.cpp +++ b/modules/commands/ms_read.cpp @@ -96,7 +96,7 @@ class CommandMSRead : public Command User *u = source.u; MemoInfo *mi; - ChannelInfo *ci; + ChannelInfo *ci = NULL; Anope::string numstr = params[0], chan; if (!numstr.empty() && numstr[0] == '#') diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp index 50bce89e3..2e279256b 100644 --- a/modules/commands/ns_ajoin.cpp +++ b/modules/commands/ns_ajoin.cpp @@ -51,7 +51,7 @@ struct AJoinList : std::vector<std::pair<Anope::string, Anope::string> >, Extens AJoinList *aj; if (obj) - aj = debug_cast<AJoinList *>(obj); + aj = anope_dynamic_static_cast<AJoinList *>(obj); else { aj = new AJoinList(nc); diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp index f09b4ddee..f9000f387 100644 --- a/modules/commands/ns_set_misc.cpp +++ b/modules/commands/ns_set_misc.cpp @@ -48,7 +48,7 @@ struct NSMiscData : ExtensibleItem, Serializable NSMiscData *d; if (obj) { - d = debug_cast<NSMiscData *>(obj); + d = anope_dynamic_static_cast<NSMiscData *>(obj); d->nc = nc; data["name"] >> d->name; data["data"] >> d->data; diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp index dd20e47b8..f965be321 100644 --- a/modules/commands/ns_suspend.cpp +++ b/modules/commands/ns_suspend.cpp @@ -45,7 +45,7 @@ struct NickSuspend : ExtensibleItem, Serializable NickSuspend *ns; if (obj) - ns = debug_cast<NickSuspend *>(obj); + ns = anope_dynamic_static_cast<NickSuspend *>(obj); else ns = new NickSuspend(); diff --git a/modules/commands/os_config.cpp b/modules/commands/os_config.cpp index 6f7ebb90c..d1a890106 100644 --- a/modules/commands/os_config.cpp +++ b/modules/commands/os_config.cpp @@ -69,63 +69,63 @@ class CommandOSConfig : public Command { case DT_NOSPACES: { - ValueContainerString *vcs = debug_cast<ValueContainerString *>(v->val); + ValueContainerString *vcs = anope_dynamic_static_cast<ValueContainerString *>(v->val); Config->ValidateNoSpaces(vi.GetValue(), v->tag, v->value); vcs->Set(vi.GetValue()); break; } case DT_HOSTNAME: { - ValueContainerString *vcs = debug_cast<ValueContainerString *>(v->val); + ValueContainerString *vcs = anope_dynamic_static_cast<ValueContainerString *>(v->val); Config->ValidateHostname(vi.GetValue(), v->tag, v->value); vcs->Set(vi.GetValue()); break; } case DT_IPADDRESS: { - ValueContainerString *vcs = debug_cast<ValueContainerString *>(v->val); + ValueContainerString *vcs = anope_dynamic_static_cast<ValueContainerString *>(v->val); Config->ValidateIP(vi.GetValue(), v->tag, v->value, allow_wild); vcs->Set(vi.GetValue()); break; } case DT_STRING: { - ValueContainerString *vcs = debug_cast<ValueContainerString *>(v->val); + ValueContainerString *vcs = anope_dynamic_static_cast<ValueContainerString *>(v->val); vcs->Set(vi.GetValue()); break; } case DT_INTEGER: { int val = vi.GetInteger(); - ValueContainerInt *vci = debug_cast<ValueContainerInt *>(v->val); + ValueContainerInt *vci = anope_dynamic_static_cast<ValueContainerInt *>(v->val); vci->Set(&val, sizeof(int)); break; } case DT_UINTEGER: { unsigned val = vi.GetInteger(); - ValueContainerUInt *vci = debug_cast<ValueContainerUInt *>(v->val); + ValueContainerUInt *vci = anope_dynamic_static_cast<ValueContainerUInt *>(v->val); vci->Set(&val, sizeof(unsigned)); break; } case DT_LUINTEGER: { unsigned long val = vi.GetInteger(); - ValueContainerLUInt *vci = debug_cast<ValueContainerLUInt *>(v->val); + ValueContainerLUInt *vci = anope_dynamic_static_cast<ValueContainerLUInt *>(v->val); vci->Set(&val, sizeof(unsigned long)); break; } case DT_TIME: { time_t time = dotime(vi.GetValue()); - ValueContainerTime *vci = debug_cast<ValueContainerTime *>(v->val); + ValueContainerTime *vci = anope_dynamic_static_cast<ValueContainerTime *>(v->val); vci->Set(&time, sizeof(time_t)); break; } case DT_BOOLEAN: { bool val = vi.GetBool(); - ValueContainerBool *vcb = debug_cast<ValueContainerBool *>(v->val); + ValueContainerBool *vcb = anope_dynamic_static_cast<ValueContainerBool *>(v->val); vcb->Set(&val, sizeof(bool)); break; } diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp index 1cf09c259..6b305c736 100644 --- a/modules/commands/os_defcon.cpp +++ b/modules/commands/os_defcon.cpp @@ -293,7 +293,7 @@ class OSDefcon : public Module if (cm->Type == MODE_PARAM) { - cmp = debug_cast<ChannelModeParam *>(cm); + cmp = anope_dynamic_static_cast<ChannelModeParam *>(cm); if (!ss.GetToken(param)) { diff --git a/modules/commands/os_forbid.h b/modules/commands/os_forbid.h index 30fdb9611..dcc5a9d6e 100644 --- a/modules/commands/os_forbid.h +++ b/modules/commands/os_forbid.h @@ -60,7 +60,7 @@ Serializable* ForbidData::unserialize(Serializable *obj, Serialize::Data &data) ForbidData *fb; if (obj) - fb = debug_cast<ForbidData *>(obj); + fb = anope_dynamic_static_cast<ForbidData *>(obj); else fb = new ForbidData; diff --git a/modules/commands/os_ignore.h b/modules/commands/os_ignore.h index 1eb505398..7c9bf3db5 100644 --- a/modules/commands/os_ignore.h +++ b/modules/commands/os_ignore.h @@ -62,7 +62,7 @@ Serializable* IgnoreData::unserialize(Serializable *obj, Serialize::Data &data) if (obj) { - IgnoreData *ign = debug_cast<IgnoreData *>(obj); + IgnoreData *ign = anope_dynamic_static_cast<IgnoreData *>(obj); data["mask"] >> ign->mask; data["creator"] >> ign->creator; data["reason"] >> ign->reason; diff --git a/modules/commands/os_news.h b/modules/commands/os_news.h index f2507473a..e2ad1fc4f 100644 --- a/modules/commands/os_news.h +++ b/modules/commands/os_news.h @@ -60,7 +60,7 @@ Serializable* NewsItem::unserialize(Serializable *obj, Serialize::Data &data) NewsItem *ni; if (obj) - ni = debug_cast<NewsItem *>(obj); + ni = anope_dynamic_static_cast<NewsItem *>(obj); else ni = new NewsItem(); diff --git a/modules/commands/os_oper.cpp b/modules/commands/os_oper.cpp index 22560dd18..fe9b06f9f 100644 --- a/modules/commands/os_oper.cpp +++ b/modules/commands/os_oper.cpp @@ -43,7 +43,7 @@ struct MyOper : Oper, Serializable MyOper *myo; if (obj) - myo = debug_cast<MyOper *>(obj); + myo = anope_dynamic_static_cast<MyOper *>(obj); else myo = new MyOper(nc->display, ot); nc->o = myo; diff --git a/modules/commands/os_session.h b/modules/commands/os_session.h index b40177a32..75764b12d 100644 --- a/modules/commands/os_session.h +++ b/modules/commands/os_session.h @@ -72,7 +72,7 @@ Serializable* Exception::unserialize(Serializable *obj, Serialize::Data &data) Exception *ex; if (obj) - ex = debug_cast<Exception *>(obj); + ex = anope_dynamic_static_cast<Exception *>(obj); else ex = new Exception; data["mask"] >> ex->mask; diff --git a/modules/extra/m_ssl.cpp b/modules/extra/m_ssl.cpp index fcfbb8f28..9e7d702eb 100644 --- a/modules/extra/m_ssl.cpp +++ b/modules/extra/m_ssl.cpp @@ -228,7 +228,7 @@ ClientSocket *SSLSocketIO::Accept(ListenSocket *s) ClientSocket *newsocket = s->OnAccept(newsock, conaddr); me->service.Init(newsocket); - SSLSocketIO *IO = debug_cast<SSLSocketIO *>(newsocket->IO); + SSLSocketIO *IO = anope_dynamic_static_cast<SSLSocketIO *>(newsocket->IO); IO->sslsock = SSL_new(server_ctx); if (!IO->sslsock) @@ -254,7 +254,7 @@ SocketFlag SSLSocketIO::FinishAccept(ClientSocket *cs) else if (!cs->HasFlag(SF_ACCEPTING)) throw SocketException("SSLSocketIO::FinishAccept called for a socket not accepted nor accepting?"); - SSLSocketIO *IO = debug_cast<SSLSocketIO *>(cs->IO); + SSLSocketIO *IO = anope_dynamic_static_cast<SSLSocketIO *>(cs->IO); int ret = SSL_accept(IO->sslsock); if (ret <= 0) @@ -323,7 +323,7 @@ SocketFlag SSLSocketIO::FinishConnect(ConnectionSocket *s) else if (!s->HasFlag(SF_CONNECTING)) throw SocketException("SSLSocketIO::FinishConnect called for a socket not connected nor connecting?"); - SSLSocketIO *IO = debug_cast<SSLSocketIO *>(s->IO); + SSLSocketIO *IO = anope_dynamic_static_cast<SSLSocketIO *>(s->IO); if (IO->sslsock == NULL) { diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp index 0dec9997a..544935f7f 100644 --- a/modules/extra/m_xmlrpc_main.cpp +++ b/modules/extra/m_xmlrpc_main.cpp @@ -93,7 +93,7 @@ class MyXMLRPCEvent : public XMLRPCEvent if (created && u) { User *useru = u; - XMLRPCUser *myu = debug_cast<XMLRPCUser *>(useru); + XMLRPCUser *myu = anope_dynamic_static_cast<XMLRPCUser *>(useru); if (!myu->GetOut().empty()) request->reply("return", iface->Sanitize(myu->GetOut())); delete u; diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index e4bb63c64..8f1bc38e6 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -664,7 +664,7 @@ class Inspircd20IRCdMessage : public InspircdIRCdMessage continue; } - ChannelModeStatus *cms = debug_cast<ChannelModeStatus *>(cm); + ChannelModeStatus *cms = anope_dynamic_static_cast<ChannelModeStatus *>(cm); cms->Level = level--; } } diff --git a/src/access.cpp b/src/access.cpp index 1100d8e7c..189e275a3 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -116,7 +116,7 @@ Serializable* ChanAccess::unserialize(Serializable *obj, Serialize::Data &data) ChanAccess *access; if (obj) - access = debug_cast<ChanAccess *>(obj); + access = anope_dynamic_static_cast<ChanAccess *>(obj); else access = const_cast<ChanAccess *>(aprovider->Create()); access->provider = aprovider; diff --git a/src/bots.cpp b/src/bots.cpp index e9d279c3e..a4db8b5a3 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -97,7 +97,7 @@ Serializable* BotInfo::unserialize(Serializable *obj, Serialize::Data &data) { BotInfo *bi; if (obj) - bi = debug_cast<BotInfo *>(obj); + bi = anope_dynamic_static_cast<BotInfo *>(obj); else if (!(bi = findbot(data["nick"].astr()))) bi = new BotInfo(data["nick"].astr(), data["user"].astr(), data["host"].astr(), data["realname"].astr()); data["created"] >> bi->created; diff --git a/src/channels.cpp b/src/channels.cpp index 3cdfd8e7c..385376ea2 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -299,7 +299,7 @@ bool Channel::HasUserStatus(const User *u, ChannelModeStatus *cms) const */ bool Channel::HasUserStatus(const User *u, ChannelModeName Name) const { - return HasUserStatus(u, debug_cast<ChannelModeStatus *>(ModeManager::FindChannelModeByName(Name))); + return HasUserStatus(u, anope_dynamic_static_cast<ChannelModeStatus *>(ModeManager::FindChannelModeByName(Name))); } /** @@ -387,7 +387,7 @@ void Channel::SetModeInternal(User *setter, ChannelMode *cm, const Anope::string if (cm->Type == MODE_LIST) { - ChannelModeList *cml = debug_cast<ChannelModeList *>(cm); + ChannelModeList *cml = anope_dynamic_static_cast<ChannelModeList *>(cm); cml->OnAdd(this, param); } @@ -474,7 +474,7 @@ void Channel::RemoveModeInternal(User *setter, ChannelMode *cm, const Anope::str if (cm->Type == MODE_LIST) { - ChannelModeList *cml = debug_cast<ChannelModeList *>(cm); + ChannelModeList *cml = anope_dynamic_static_cast<ChannelModeList *>(cm); cml->OnDel(this, param); } @@ -515,7 +515,7 @@ void Channel::SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m, return; else if (cm->Type == MODE_PARAM) { - ChannelModeParam *cmp = debug_cast<ChannelModeParam *>(cm); + ChannelModeParam *cmp = anope_dynamic_static_cast<ChannelModeParam *>(cm); if (!cmp->IsValid(param)) return; @@ -526,12 +526,12 @@ void Channel::SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m, else if (cm->Type == MODE_STATUS) { User *u = finduser(param); - if (!u || HasUserStatus(u, debug_cast<ChannelModeStatus *>(cm))) + if (!u || HasUserStatus(u, anope_dynamic_static_cast<ChannelModeStatus *>(cm))) return; } else if (cm->Type == MODE_LIST) { - ChannelModeList *cml = debug_cast<ChannelModeList *>(cm); + ChannelModeList *cml = anope_dynamic_static_cast<ChannelModeList *>(cm); if (this->HasMode(cm->Name, param) || !cml->IsValid(param)) return; } @@ -569,7 +569,7 @@ void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶ else if (cm->Type == MODE_STATUS) { User *u = finduser(param); - if (!u || !HasUserStatus(u, debug_cast<ChannelModeStatus *>(cm))) + if (!u || !HasUserStatus(u, anope_dynamic_static_cast<ChannelModeStatus *>(cm))) return; } else if (cm->Type == MODE_LIST) @@ -583,7 +583,7 @@ void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶ if (cm->Type == MODE_PARAM) { realparam.clear(); - ChannelModeParam *cmp = debug_cast<ChannelModeParam *>(cm); + ChannelModeParam *cmp = anope_dynamic_static_cast<ChannelModeParam *>(cm); if (!cmp->MinusNoArg) this->GetParam(cmp->Name, realparam); } @@ -734,7 +734,7 @@ void Channel::SetModesInternal(User *setter, const Anope::string &mode, bool Enf } else if (cm->Type == MODE_PARAM) { - ChannelModeParam *cmp = debug_cast<ChannelModeParam *>(cm); + ChannelModeParam *cmp = anope_dynamic_static_cast<ChannelModeParam *>(cm); if (!add && cmp->MinusNoArg) { @@ -857,7 +857,7 @@ Anope::string Channel::GetModes(bool complete, bool plus) if (complete && !it->second.empty()) { - ChannelModeParam *cmp = debug_cast<ChannelModeParam *>(cm); + ChannelModeParam *cmp = anope_dynamic_static_cast<ChannelModeParam *>(cm); if (plus || !cmp->MinusNoArg) params += " " + it->second; @@ -1368,7 +1368,7 @@ bool Entry::Matches(const User *u, bool full) const ChannelMode *cm = ModeManager::FindChannelModeByName(this->modename); if (cm != NULL && cm->Type == MODE_LIST) { - ChannelModeList *cml = debug_cast<ChannelModeList *>(cm); + ChannelModeList *cml = anope_dynamic_static_cast<ChannelModeList *>(cm); if (cml->Matches(u, this)) ret = true; } diff --git a/src/config.cpp b/src/config.cpp index 66d8f6a8c..24b9e13b6 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -1501,63 +1501,63 @@ void ServerConfig::Read() { case DT_NOSPACES: { - ValueContainerString *vcs = debug_cast<ValueContainerString *>(configitems.Values[Index].val); + ValueContainerString *vcs = anope_dynamic_static_cast<ValueContainerString *>(configitems.Values[Index].val); ValidateNoSpaces(vi.GetValue(), configitems.Values[Index].tag, configitems.Values[Index].value); vcs->Set(vi.GetValue()); break; } case DT_HOSTNAME: { - ValueContainerString *vcs = debug_cast<ValueContainerString *>(configitems.Values[Index].val); + ValueContainerString *vcs = anope_dynamic_static_cast<ValueContainerString *>(configitems.Values[Index].val); ValidateHostname(vi.GetValue(), configitems.Values[Index].tag, configitems.Values[Index].value); vcs->Set(vi.GetValue()); break; } case DT_IPADDRESS: { - ValueContainerString *vcs = debug_cast<ValueContainerString *>(configitems.Values[Index].val); + ValueContainerString *vcs = anope_dynamic_static_cast<ValueContainerString *>(configitems.Values[Index].val); ValidateIP(vi.GetValue(), configitems.Values[Index].tag, configitems.Values[Index].value, allow_wild); vcs->Set(vi.GetValue()); break; } case DT_STRING: { - ValueContainerString *vcs = debug_cast<ValueContainerString *>(configitems.Values[Index].val); + ValueContainerString *vcs = anope_dynamic_static_cast<ValueContainerString *>(configitems.Values[Index].val); vcs->Set(vi.GetValue()); break; } case DT_INTEGER: { int val = vi.GetInteger(); - ValueContainerInt *vci = debug_cast<ValueContainerInt *>(configitems.Values[Index].val); + ValueContainerInt *vci = anope_dynamic_static_cast<ValueContainerInt *>(configitems.Values[Index].val); vci->Set(&val, sizeof(int)); break; } case DT_UINTEGER: { unsigned val = vi.GetInteger(); - ValueContainerUInt *vci = debug_cast<ValueContainerUInt *>(configitems.Values[Index].val); + ValueContainerUInt *vci = anope_dynamic_static_cast<ValueContainerUInt *>(configitems.Values[Index].val); vci->Set(&val, sizeof(unsigned)); break; } case DT_LUINTEGER: { unsigned long val = vi.GetInteger(); - ValueContainerLUInt *vci = debug_cast<ValueContainerLUInt *>(configitems.Values[Index].val); + ValueContainerLUInt *vci = anope_dynamic_static_cast<ValueContainerLUInt *>(configitems.Values[Index].val); vci->Set(&val, sizeof(unsigned long)); break; } case DT_TIME: { time_t time = dotime(vi.GetValue()); - ValueContainerTime *vci = debug_cast<ValueContainerTime *>(configitems.Values[Index].val); + ValueContainerTime *vci = anope_dynamic_static_cast<ValueContainerTime *>(configitems.Values[Index].val); vci->Set(&time, sizeof(time_t)); break; } case DT_BOOLEAN: { bool val = vi.GetBool(); - ValueContainerBool *vcb = debug_cast<ValueContainerBool *>(configitems.Values[Index].val); + ValueContainerBool *vcb = anope_dynamic_static_cast<ValueContainerBool *>(configitems.Values[Index].val); vcb->Set(&val, sizeof(bool)); break; } diff --git a/src/memoserv.cpp b/src/memoserv.cpp index 92c027702..c2e1de939 100644 --- a/src/memoserv.cpp +++ b/src/memoserv.cpp @@ -50,7 +50,7 @@ Serializable* Memo::unserialize(Serializable *obj, Serialize::Data &data) Memo *m; if (obj) - m = debug_cast<Memo *>(obj); + m = anope_dynamic_static_cast<Memo *>(obj); else m = new Memo(); data["owner"] >> m->owner; diff --git a/src/modes.cpp b/src/modes.cpp index dd5897087..b9960f38f 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -112,7 +112,7 @@ Anope::string ChannelStatus::BuildModePrefixList() const if (this->HasFlag(cm->Name)) { - ChannelModeStatus *cms = debug_cast<ChannelModeStatus *>(cm); + ChannelModeStatus *cms = anope_dynamic_static_cast<ChannelModeStatus *>(cm); ret += cms->Symbol; } } @@ -302,13 +302,13 @@ void StackerInfo::AddMode(Mode *mode, bool Set, const Anope::string &Param) if (Type == ST_CHANNEL) { - cm = debug_cast<ChannelMode *>(mode); + cm = anope_dynamic_static_cast<ChannelMode *>(mode); if (cm->Type == MODE_PARAM) IsParam = true; } else if (Type == ST_USER) { - um = debug_cast<UserMode *>(mode); + um = anope_dynamic_static_cast<UserMode *>(mode); if (um->Type == MODE_PARAM) IsParam = true; } @@ -411,12 +411,12 @@ std::list<Anope::string> ModeManager::BuildModeStrings(StackerInfo *info) if (info->Type == ST_CHANNEL) { - cm = debug_cast<ChannelMode *>(it->first); + cm = anope_dynamic_static_cast<ChannelMode *>(it->first); buf += cm->ModeChar; } else if (info->Type == ST_USER) { - um = debug_cast<UserMode *>(it->first); + um = anope_dynamic_static_cast<UserMode *>(it->first); buf += um->ModeChar; } @@ -440,12 +440,12 @@ std::list<Anope::string> ModeManager::BuildModeStrings(StackerInfo *info) if (info->Type == ST_CHANNEL) { - cm = debug_cast<ChannelMode *>(it->first); + cm = anope_dynamic_static_cast<ChannelMode *>(it->first); buf += cm->ModeChar; } else if (info->Type == ST_USER) { - um = debug_cast<UserMode *>(it->first); + um = anope_dynamic_static_cast<UserMode *>(it->first); buf += um->ModeChar; } @@ -478,7 +478,7 @@ void ModeManager::StackerAddInternal(const BotInfo *bi, Base *Object, Mode *mode if (bi) s->bi = bi; else if (Type == ST_CHANNEL) - s->bi = debug_cast<Channel *>(Object)->ci->WhoSends(); + s->bi = anope_dynamic_reinterpret_cast<Channel *>(Object)->ci->WhoSends(); else if (Type == ST_USER) s->bi = NULL; @@ -638,7 +638,7 @@ char ModeManager::GetStatusChar(char Value) ChannelMode *cm = ModeManager::ChannelModes[i]; if (cm->Type == MODE_STATUS) { - ChannelModeStatus *cms = debug_cast<ChannelModeStatus *>(cm); + ChannelModeStatus *cms = anope_dynamic_static_cast<ChannelModeStatus *>(cm); if (Value == cms->Symbol) return cms->ModeChar; @@ -685,9 +685,9 @@ void ModeManager::ProcessModes() Channel *c = NULL; if (s->Type == ST_USER) - u = debug_cast<User *>(it->first); + u = anope_dynamic_reinterpret_cast<User *>(it->first); else if (s->Type == ST_CHANNEL) - c = debug_cast<Channel *>(it->first); + c = anope_dynamic_reinterpret_cast<Channel *>(it->first); else throw CoreException("ModeManager::ProcessModes got invalid Stacker Info type"); diff --git a/src/nickalias.cpp b/src/nickalias.cpp index 18e581714..bdd010e23 100644 --- a/src/nickalias.cpp +++ b/src/nickalias.cpp @@ -281,7 +281,7 @@ Serializable* NickAlias::unserialize(Serializable *obj, Serialize::Data &data) NickAlias *na; if (obj) - na = debug_cast<NickAlias *>(obj); + na = anope_dynamic_static_cast<NickAlias *>(obj); else na = new NickAlias(data["nick"].astr(), core); diff --git a/src/nickcore.cpp b/src/nickcore.cpp index e68e7444d..de64a7e9e 100644 --- a/src/nickcore.cpp +++ b/src/nickcore.cpp @@ -91,7 +91,7 @@ Serializable* NickCore::unserialize(Serializable *obj, Serialize::Data &data) NickCore *nc; if (obj) - nc = debug_cast<NickCore *>(obj); + nc = anope_dynamic_static_cast<NickCore *>(obj); else nc = new NickCore(data["display"].astr()); diff --git a/src/operserv.cpp b/src/operserv.cpp index 59a91aa09..9d006a7c1 100644 --- a/src/operserv.cpp +++ b/src/operserv.cpp @@ -168,7 +168,7 @@ Serializable* XLine::unserialize(Serializable *obj, Serialize::Data &data) XLine *xl; if (obj) { - xl = debug_cast<XLine *>(obj); + xl = anope_dynamic_static_cast<XLine *>(obj); data["mask"] >> xl->Mask; data["by"] >> xl->By; data["reason"] >> xl->Reason; diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 2ee66805a..b113dfb2e 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -51,7 +51,7 @@ Serializable* BadWord::unserialize(Serializable *obj, Serialize::Data &data) BadWord *bw; if (obj) { - bw = debug_cast<BadWord *>(obj); + bw = anope_dynamic_static_cast<BadWord *>(obj); data["word"] >> bw->word; bw->type = static_cast<BadWordType>(n); } @@ -98,7 +98,7 @@ Serializable* AutoKick::unserialize(Serializable *obj, Serialize::Data &data) NickCore *nc = findcore(data["nc"].astr()); if (obj) { - ak = debug_cast<AutoKick *>(obj); + ak = anope_dynamic_static_cast<AutoKick *>(obj); data["creator"] >> ak->creator; data["reason"] >> ak->reason; ak->nc = findcore(data["nc"].astr()); @@ -167,7 +167,7 @@ Serializable* ModeLock::unserialize(Serializable *obj, Serialize::Data &data) ModeLock *ml; if (obj) { - ml = debug_cast<ModeLock *>(obj); + ml = anope_dynamic_static_cast<ModeLock *>(obj); data["set"] >> ml->set; ml->name = name; @@ -224,7 +224,7 @@ Serializable* LogSetting::unserialize(Serializable *obj, Serialize::Data &data) LogSetting *ls; if (obj) - ls = debug_cast<LogSetting *>(obj); + ls = anope_dynamic_static_cast<LogSetting *>(obj); else { ls = new LogSetting(); @@ -433,7 +433,7 @@ Serializable* ChannelInfo::unserialize(Serializable *obj, Serialize::Data &data) { ChannelInfo *ci; if (obj) - ci = debug_cast<ChannelInfo *>(obj); + ci = anope_dynamic_static_cast<ChannelInfo *>(obj); else ci = new ChannelInfo(data["name"].astr()); |