Rename macro RequireNotNull to REQUIRE_NOT_NULL

This commit is contained in:
Jean Flach 2018-02-21 13:42:58 +01:00
parent 71c420d501
commit 9de36c0999
21 changed files with 61 additions and 61 deletions

View File

@ -30,7 +30,7 @@ static double ArrayLen(void)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
return self->GetLength();
}
@ -38,7 +38,7 @@ static void ArraySet(int index, const Value& value)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
self->Set(index, value);
}
@ -46,7 +46,7 @@ static Value ArrayGet(int index)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
return self->Get(index);
}
@ -54,7 +54,7 @@ static void ArrayAdd(const Value& value)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
self->Add(value);
}
@ -62,7 +62,7 @@ static void ArrayRemove(int index)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
self->Remove(index);
}
@ -70,7 +70,7 @@ static bool ArrayContains(const Value& value)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
return self->Contains(value);
}
@ -78,7 +78,7 @@ static void ArrayClear(void)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
self->Clear();
}
@ -94,7 +94,7 @@ static Array::Ptr ArraySort(const std::vector<Value>& args)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
Array::Ptr arr = self->ShallowClone();
@ -118,7 +118,7 @@ static Array::Ptr ArrayShallowClone(void)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
return self->ShallowClone();
}
@ -126,7 +126,7 @@ static Value ArrayJoin(const Value& separator)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
Value result;
bool first = true;
@ -149,7 +149,7 @@ static Array::Ptr ArrayReverse(void)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
return self->Reverse();
}
@ -157,7 +157,7 @@ static Array::Ptr ArrayMap(const Function::Ptr& function)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
if (vframe->Sandboxed && !function->IsSideEffectFree())
BOOST_THROW_EXCEPTION(ScriptError("Map function must be side-effect free."));
@ -178,7 +178,7 @@ static Value ArrayReduce(const Function::Ptr& function)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
if (vframe->Sandboxed && !function->IsSideEffectFree())
BOOST_THROW_EXCEPTION(ScriptError("Reduce function must be side-effect free."));
@ -203,7 +203,7 @@ static Array::Ptr ArrayFilter(const Function::Ptr& function)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
if (vframe->Sandboxed && !function->IsSideEffectFree())
BOOST_THROW_EXCEPTION(ScriptError("Filter function must be side-effect free."));
@ -225,7 +225,7 @@ static bool ArrayAny(const Function::Ptr& function)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
if (vframe->Sandboxed && !function->IsSideEffectFree())
BOOST_THROW_EXCEPTION(ScriptError("Filter function must be side-effect free."));
@ -245,7 +245,7 @@ static bool ArrayAll(const Function::Ptr& function)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
if (vframe->Sandboxed && !function->IsSideEffectFree())
BOOST_THROW_EXCEPTION(ScriptError("Filter function must be side-effect free."));
@ -264,7 +264,7 @@ static Array::Ptr ArrayUnique(void)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
std::set<Value> result;

View File

@ -29,7 +29,7 @@ static void ConfigObjectModifyAttribute(const String& attr, const Value& value)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
ConfigObject::Ptr self = vframe->Self;
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
return self->ModifyAttribute(attr, value);
}
@ -37,7 +37,7 @@ static void ConfigObjectRestoreAttribute(const String& attr)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
ConfigObject::Ptr self = vframe->Self;
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
return self->RestoreAttribute(attr);
}

View File

@ -29,7 +29,7 @@ static String DateTimeFormat(const String& format)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
DateTime::Ptr self = static_cast<DateTime::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
return self->Format(format);
}

View File

@ -29,7 +29,7 @@ static double DictionaryLen(void)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
return self->GetLength();
}
@ -37,7 +37,7 @@ static void DictionarySet(const String& key, const Value& value)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
self->Set(key, value);
}
@ -45,7 +45,7 @@ static Value DictionaryGet(const String& key)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
return self->Get(key);
}
@ -53,7 +53,7 @@ static void DictionaryRemove(const String& key)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
self->Remove(key);
}
@ -61,7 +61,7 @@ static bool DictionaryContains(const String& key)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
return self->Contains(key);
}
@ -69,7 +69,7 @@ static Dictionary::Ptr DictionaryShallowClone(void)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
return self->ShallowClone();
}
@ -78,7 +78,7 @@ static Array::Ptr DictionaryKeys(void)
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
Array::Ptr keys = new Array();
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
ObjectLock olock(self);
for (const Dictionary::Pair& kv : self) {
@ -92,7 +92,7 @@ static Array::Ptr DictionaryValues(void)
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
Array::Ptr keys = new Array();
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
ObjectLock olock(self);
for (const Dictionary::Pair& kv : self) {

View File

@ -32,7 +32,7 @@ static Value FunctionCall(const std::vector<Value>& args)
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Function::Ptr self = static_cast<Function::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
std::vector<Value> uargs(args.begin() + 1, args.end());
return self->Invoke(args[0], uargs);
@ -42,7 +42,7 @@ static Value FunctionCallV(const Value& thisArg, const Array::Ptr& args)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Function::Ptr self = static_cast<Function::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
std::vector<Value> uargs;

View File

@ -29,7 +29,7 @@ static String ObjectToString(void)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Object::Ptr self = static_cast<Object::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
return self->ToString();
}
@ -37,7 +37,7 @@ static void ObjectNotifyAttribute(const String& attribute)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Object::Ptr self = static_cast<Object::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
self->NotifyField(self->GetReflectionType()->GetFieldId(attribute));
}
@ -45,7 +45,7 @@ static Object::Ptr ObjectClone(void)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Object::Ptr self = static_cast<Object::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
return self->Clone();
}

View File

@ -62,7 +62,7 @@ extern I2_BASE_API Value Empty;
DECLARE_PTR_TYPEDEFS(klass); \
IMPL_TYPE_LOOKUP();
#define RequireNotNull(ptr) RequireNotNullInternal(ptr, #ptr)
#define REQUIRE_NOT_NULL(ptr) RequireNotNullInternal(ptr, #ptr)
I2_BASE_API void RequireNotNullInternal(const intrusive_ptr<Object>& object, const char *description);

View File

@ -37,7 +37,7 @@ static void TypeRegisterAttributeHandler(const String& fieldName, const Function
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Type::Ptr self = static_cast<Type::Ptr>(vframe->Self);
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
int fid = self->GetFieldId(fieldName);
self->RegisterAttributeHandler(fid, boost::bind(&InvokeAttributeHandlerHelper, callback, _1, _2));

View File

@ -30,7 +30,7 @@ static void CheckableProcessCheckResult(const CheckResult::Ptr& cr)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Checkable::Ptr self = vframe->Self;
RequireNotNull(self);
REQUIRE_NOT_NULL(self);
self->ProcessCheckResult(cr);
}

View File

@ -41,7 +41,7 @@ Value MacroProcessor::ResolveMacros(const Value& str, const ResolverList& resolv
bool useResolvedMacros, int recursionLevel)
{
if (useResolvedMacros)
RequireNotNull(resolvedMacros);
REQUIRE_NOT_NULL(resolvedMacros);
Value result;
@ -458,7 +458,7 @@ Value MacroProcessor::ResolveArguments(const Value& command, const Dictionary::P
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros, int recursionLevel)
{
if (useResolvedMacros)
RequireNotNull(resolvedMacros);
REQUIRE_NOT_NULL(resolvedMacros);
Value resolvedCommand;
if (!arguments || command.IsObjectType<Array>() || command.IsObjectType<Function>())

View File

@ -38,8 +38,8 @@ REGISTER_SCRIPTFUNCTION_NS(Internal, ClusterCheck, &ClusterCheckTask::ScriptFunc
void ClusterCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{
RequireNotNull(checkable);
RequireNotNull(cr);
REQUIRE_NOT_NULL(checkable);
REQUIRE_NOT_NULL(cr);
if (resolvedMacros && !useResolvedMacros)
return;

View File

@ -34,8 +34,8 @@ REGISTER_SCRIPTFUNCTION_NS(Internal, ClusterZoneCheck, &ClusterZoneCheckTask::Sc
void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{
RequireNotNull(checkable);
RequireNotNull(cr);
REQUIRE_NOT_NULL(checkable);
REQUIRE_NOT_NULL(cr);
ApiListener::Ptr listener = ApiListener::GetInstance();

View File

@ -31,11 +31,11 @@ using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, ExceptionCheck, &ExceptionCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
void ExceptionCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
void ExceptionCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{
RequireNotNull(service);
RequireNotNull(cr);
REQUIRE_NOT_NULL(checkable);
REQUIRE_NOT_NULL(cr);
if (resolvedMacros && !useResolvedMacros)
return;

View File

@ -32,11 +32,11 @@ using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, IcingaCheck, &IcingaCheckTask::ScriptFunc, "checkable:cr:resolvedMacros:useResolvedMacros");
void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{
RequireNotNull(service);
RequireNotNull(cr);
REQUIRE_NOT_NULL(checkable);
REQUIRE_NOT_NULL(cr);
if (resolvedMacros && !useResolvedMacros)
return;
@ -115,5 +115,5 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResul
} else
cr->SetState(ServiceOK);
service->ProcessCheckResult(cr);
checkable->ProcessCheckResult(cr);
}

View File

@ -35,8 +35,8 @@ REGISTER_SCRIPTFUNCTION_NS(Internal, NullCheck, &NullCheckTask::ScriptFunc, "che
void NullCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{
RequireNotNull(checkable);
RequireNotNull(cr);
REQUIRE_NOT_NULL(checkable);
REQUIRE_NOT_NULL(cr);
if (resolvedMacros && !useResolvedMacros)
return;

View File

@ -27,5 +27,5 @@ REGISTER_SCRIPTFUNCTION_NS(Internal, NullEvent, &NullEventTask::ScriptFunc, "che
void NullEventTask::ScriptFunc(const Checkable::Ptr& checkable, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{
RequireNotNull(checkable);
REQUIRE_NOT_NULL(checkable);
}

View File

@ -38,8 +38,8 @@ REGISTER_SCRIPTFUNCTION_NS(Internal, PluginCheck, &PluginCheckTask::ScriptFunc,
void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{
RequireNotNull(checkable);
RequireNotNull(cr);
REQUIRE_NOT_NULL(checkable);
REQUIRE_NOT_NULL(cr);
CheckCommand::Ptr commandObj = checkable->GetCheckCommand();

View File

@ -36,7 +36,7 @@ REGISTER_SCRIPTFUNCTION_NS(Internal, PluginEvent, &PluginEventTask::ScriptFunc,
void PluginEventTask::ScriptFunc(const Checkable::Ptr& checkable,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{
RequireNotNull(checkable);
REQUIRE_NOT_NULL(checkable);
EventCommand::Ptr commandObj = checkable->GetEventCommand();

View File

@ -39,8 +39,8 @@ void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification,
const String& author, const String& comment, const Dictionary::Ptr& resolvedMacros,
bool useResolvedMacros)
{
RequireNotNull(notification);
RequireNotNull(user);
REQUIRE_NOT_NULL(notification);
REQUIRE_NOT_NULL(user);
NotificationCommand::Ptr commandObj = notification->GetCommand();

View File

@ -35,8 +35,8 @@ REGISTER_SCRIPTFUNCTION_NS(Internal, RandomCheck, &RandomCheckTask::ScriptFunc,
void RandomCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{
RequireNotNull(checkable);
RequireNotNull(cr);
REQUIRE_NOT_NULL(checkable);
REQUIRE_NOT_NULL(cr);
if (resolvedMacros && !useResolvedMacros)
return;

View File

@ -27,7 +27,7 @@ REGISTER_SCRIPTFUNCTION_NS(Internal, EvenMinutesTimePeriod, &TimePeriodTask::Eve
Array::Ptr TimePeriodTask::EmptyTimePeriodUpdate(const TimePeriod::Ptr& tp, double, double)
{
RequireNotNull(tp);
REQUIRE_NOT_NULL(tp);
Array::Ptr segments = new Array();
return segments;
@ -36,7 +36,7 @@ Array::Ptr TimePeriodTask::EmptyTimePeriodUpdate(const TimePeriod::Ptr& tp, doub
Array::Ptr TimePeriodTask::EvenMinutesTimePeriodUpdate(const TimePeriod::Ptr& tp, double begin, double end)
{
Array::Ptr segments = new Array();
RequireNotNull(tp);
REQUIRE_NOT_NULL(tp);
for (long t = begin / 60 - 1; t * 60 < end; t++) {
if ((t % 2) == 0) {