diff options
author | Chris Robinson <[email protected]> | 2018-11-17 01:49:26 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-17 01:49:26 -0800 |
commit | a7d3c24b511be49d8d0917d5030a0f378af8da87 (patch) | |
tree | 1c6fb58bd9dea9dcc273d29f3694020079704b9a /Alc | |
parent | 557048afa2d06d68c5a5f7f0584dbace67d02ef6 (diff) |
Convert null.c to C++
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/effects/null.cpp (renamed from Alc/effects/null.c) | 21 |
1 files changed, 14 insertions, 7 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); } |