aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-17 01:49:26 -0800
committerChris Robinson <[email protected]>2018-11-17 01:49:26 -0800
commita7d3c24b511be49d8d0917d5030a0f378af8da87 (patch)
tree1c6fb58bd9dea9dcc273d29f3694020079704b9a
parent557048afa2d06d68c5a5f7f0584dbace67d02ef6 (diff)
Convert null.c to C++
-rw-r--r--Alc/effects/null.cpp (renamed from Alc/effects/null.c)21
-rw-r--r--CMakeLists.txt2
2 files changed, 15 insertions, 8 deletions
diff --git a/Alc/effects/null.c b/Alc/effects/null.cpp
index 82ea5d26..377593ab 100644
--- a/Alc/effects/null.c
+++ b/Alc/effects/null.cpp
@@ -9,9 +9,8 @@
#include "alError.h"
-typedef struct ALnullState {
- DERIVE_FROM_TYPE(ALeffectState);
-} ALnullState;
+struct ALnullState final : public ALeffectState {
+};
/* Forward-declare "virtual" functions to define the vtable with. */
static ALvoid ALnullState_Destruct(ALnullState *state);
@@ -31,6 +30,7 @@ DEFINE_ALEFFECTSTATE_VTABLE(ALnullState);
*/
static void ALnullState_Construct(ALnullState *state)
{
+ new (state) ALnullState{};
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
SET_VTABLE2(ALnullState, ALeffectState, state);
}
@@ -42,6 +42,7 @@ static void ALnullState_Construct(ALnullState *state)
static ALvoid ALnullState_Destruct(ALnullState *state)
{
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
+ state->~ALnullState();
}
/* This updates the device-dependant effect state. This is called on
@@ -85,9 +86,9 @@ static void ALnullState_Delete(void *ptr)
}
-typedef struct NullStateFactory {
- DERIVE_FROM_TYPE(EffectStateFactory);
-} NullStateFactory;
+struct NullStateFactory final : public EffectStateFactory {
+ NullStateFactory() noexcept;
+};
/* Creates ALeffectState objects of the appropriate type. */
ALeffectState *NullStateFactory_create(NullStateFactory *UNUSED(factory))
@@ -103,9 +104,15 @@ ALeffectState *NullStateFactory_create(NullStateFactory *UNUSED(factory))
/* Define the EffectStateFactory vtable for this type. */
DEFINE_EFFECTSTATEFACTORY_VTABLE(NullStateFactory);
+NullStateFactory::NullStateFactory() noexcept
+ : EffectStateFactory{GET_VTABLE2(NullStateFactory, EffectStateFactory)}
+{
+}
+
+
EffectStateFactory *NullStateFactory_getFactory(void)
{
- static NullStateFactory NullFactory = { { GET_VTABLE2(NullStateFactory, EffectStateFactory) } };
+ static NullStateFactory NullFactory{};
return STATIC_CAST(EffectStateFactory, &NullFactory);
}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2da22d3a..d5b1d005 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -820,7 +820,7 @@ SET(ALC_OBJS
Alc/effects/equalizer.c
Alc/effects/fshifter.c
Alc/effects/modulator.c
- Alc/effects/null.c
+ Alc/effects/null.cpp
Alc/effects/pshifter.cpp
Alc/effects/reverb.cpp
Alc/filters/defs.h