replace (useless) assert() by check()

This commit is contained in:
monsieurgustav
2014-11-23 15:55:24 +01:00
parent f3474cb760
commit 1fad95b246
3 changed files with 10 additions and 11 deletions
@@ -1,6 +1,5 @@
#pragma once #pragma once
#include <assert.h>
#include "OscDataElemStruct.generated.h" #include "OscDataElemStruct.generated.h"
@@ -33,11 +32,12 @@ struct FOscDataElemStruct
static_assert(sizeof(value) <= sizeof(Data), "Too short to hold the float value."); static_assert(sizeof(value) <= sizeof(Data), "Too short to hold the float value.");
Type = FLOAT; Type = FLOAT;
Data = *reinterpret_cast<int64 *>(&value); Data = *reinterpret_cast<int64 *>(&value);
assert(value == AsFloatValue()); check(value == AsFloatValue());
} }
double AsFloatValue() const double AsFloatValue() const
{ {
check(IsFloat());
return *reinterpret_cast<const double *>(&Data); return *reinterpret_cast<const double *>(&Data);
} }
@@ -53,11 +53,12 @@ struct FOscDataElemStruct
static_assert(sizeof(value) <= sizeof(Data), "Too short to hold the integer value."); static_assert(sizeof(value) <= sizeof(Data), "Too short to hold the integer value.");
Type = INT; Type = INT;
Data = value; Data = value;
assert(value == AsIntValue()); check(value == AsIntValue());
} }
int64 AsIntValue() const int64 AsIntValue() const
{ {
check(IsInt());
return Data; return Data;
} }
@@ -73,11 +74,12 @@ struct FOscDataElemStruct
static_assert(sizeof(value) <= sizeof(Data), "Too short to hold the bool value."); static_assert(sizeof(value) <= sizeof(Data), "Too short to hold the bool value.");
Type = BOOL; Type = BOOL;
Data = value; Data = value;
assert(value == AsBoolValue()); check(value == AsBoolValue());
} }
bool AsBoolValue() const bool AsBoolValue() const
{ {
check(IsBool());
return Data != 0; return Data != 0;
} }
@@ -99,11 +101,12 @@ struct FOscDataElemStruct
Data = *reinterpret_cast<const int64*>(&mininal); Data = *reinterpret_cast<const int64*>(&mininal);
#endif #endif
Type = STRING; Type = STRING;
assert(value == AsStringValue()); check(value == AsStringValue());
} }
FName AsStringValue() const FName AsStringValue() const
{ {
check(IsString());
#if OSC_ENGINE_VERSION < 40500 #if OSC_ENGINE_VERSION < 40500
return *reinterpret_cast<const FName *>(&Data); return *reinterpret_cast<const FName *>(&Data);
#else #else
@@ -142,7 +145,7 @@ struct FOscDataElemStruct
{ {
if(isNumber) if(isNumber)
{ {
const auto value = AsIntValue(); const auto value = AsBoolValue();
return Cast<T, isNumber>::eval(value); return Cast<T, isNumber>::eval(value);
} }
} }
@@ -112,6 +112,6 @@ void UOscFunctionLibrary::SendOsc(FName Address, const FOscDataStruct & Data, in
} }
output << osc::EndMessage; output << osc::EndMessage;
assert(buffer = output.Data()); check(reinterpret_cast<const void *>(buffer) == reinterpret_cast<const void *>(output.Data()));
GetMutableDefault<UOscSettings>()->Send(buffer, output.Size(), TargetIndex); GetMutableDefault<UOscSettings>()->Send(buffer, output.Size(), TargetIndex);
} }
@@ -1,13 +1,9 @@
#include "OscPrivatePCH.h" #include "OscPrivatePCH.h"
#include "OscDispatcher.h" #include "OscDispatcher.h"
#include "OscReceiverInterface.h" #include "OscReceiverInterface.h"
#include "oscpack/osc/OscReceivedElements.h" #include "oscpack/osc/OscReceivedElements.h"
#include <assert.h>
UOscDispatcher::UOscDispatcher(const class FPostConstructInitializeProperties& PCIP) UOscDispatcher::UOscDispatcher(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP), : Super(PCIP),