From 1fad95b246e5910648b9924ca37b6e6fef409db3 Mon Sep 17 00:00:00 2001 From: monsieurgustav Date: Sun, 23 Nov 2014 15:55:24 +0100 Subject: [PATCH] replace (useless) assert() by check() --- OSC/Source/OSC/Private/Common/OscDataElemStruct.h | 15 +++++++++------ .../OSC/Private/Common/OscFunctionLibrary.cpp | 2 +- OSC/Source/OSC/Private/Receive/OscDispatcher.cpp | 4 ---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/OSC/Source/OSC/Private/Common/OscDataElemStruct.h b/OSC/Source/OSC/Private/Common/OscDataElemStruct.h index e5af3b5..bbcc4e0 100644 --- a/OSC/Source/OSC/Private/Common/OscDataElemStruct.h +++ b/OSC/Source/OSC/Private/Common/OscDataElemStruct.h @@ -1,6 +1,5 @@ #pragma once -#include #include "OscDataElemStruct.generated.h" @@ -33,11 +32,12 @@ struct FOscDataElemStruct static_assert(sizeof(value) <= sizeof(Data), "Too short to hold the float value."); Type = FLOAT; Data = *reinterpret_cast(&value); - assert(value == AsFloatValue()); + check(value == AsFloatValue()); } double AsFloatValue() const { + check(IsFloat()); return *reinterpret_cast(&Data); } @@ -53,11 +53,12 @@ struct FOscDataElemStruct static_assert(sizeof(value) <= sizeof(Data), "Too short to hold the integer value."); Type = INT; Data = value; - assert(value == AsIntValue()); + check(value == AsIntValue()); } int64 AsIntValue() const { + check(IsInt()); return Data; } @@ -73,11 +74,12 @@ struct FOscDataElemStruct static_assert(sizeof(value) <= sizeof(Data), "Too short to hold the bool value."); Type = BOOL; Data = value; - assert(value == AsBoolValue()); + check(value == AsBoolValue()); } bool AsBoolValue() const { + check(IsBool()); return Data != 0; } @@ -99,11 +101,12 @@ struct FOscDataElemStruct Data = *reinterpret_cast(&mininal); #endif Type = STRING; - assert(value == AsStringValue()); + check(value == AsStringValue()); } FName AsStringValue() const { + check(IsString()); #if OSC_ENGINE_VERSION < 40500 return *reinterpret_cast(&Data); #else @@ -142,7 +145,7 @@ struct FOscDataElemStruct { if(isNumber) { - const auto value = AsIntValue(); + const auto value = AsBoolValue(); return Cast::eval(value); } } diff --git a/OSC/Source/OSC/Private/Common/OscFunctionLibrary.cpp b/OSC/Source/OSC/Private/Common/OscFunctionLibrary.cpp index 0790467..87f5c20 100644 --- a/OSC/Source/OSC/Private/Common/OscFunctionLibrary.cpp +++ b/OSC/Source/OSC/Private/Common/OscFunctionLibrary.cpp @@ -112,6 +112,6 @@ void UOscFunctionLibrary::SendOsc(FName Address, const FOscDataStruct & Data, in } output << osc::EndMessage; - assert(buffer = output.Data()); + check(reinterpret_cast(buffer) == reinterpret_cast(output.Data())); GetMutableDefault()->Send(buffer, output.Size(), TargetIndex); } diff --git a/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp b/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp index 01a6e7f..0007f33 100644 --- a/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp +++ b/OSC/Source/OSC/Private/Receive/OscDispatcher.cpp @@ -1,13 +1,9 @@ - - #include "OscPrivatePCH.h" #include "OscDispatcher.h" #include "OscReceiverInterface.h" #include "oscpack/osc/OscReceivedElements.h" -#include - UOscDispatcher::UOscDispatcher(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP),