Skip to content

Commit

Permalink
Fix for Windows VS 2017
Browse files Browse the repository at this point in the history
  • Loading branch information
cesaref committed Sep 3, 2020
1 parent 30a9c27 commit 8728ae4
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions include/soul/patch/helper_classes/soul_patch_Blueprint.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,28 @@ struct BlueprintEditorComponent : public juce::AudioProcessorEditor,
startTimerHz (30);
}

template <int numParams, typename MethodType>
juce::var call (MethodType method, const juce::var::NativeFunctionArgs& args)
{
if (args.numArguments != numParams)
return juce::var::undefined();

if constexpr (numParams == 0) return (this->*method)();
if constexpr (numParams == 1) return (this->*method) (args.arguments[0]);
if constexpr (numParams == 2) return (this->*method) (args.arguments[0], args.arguments[1]);
if constexpr (numParams == 3) return (this->*method) (args.arguments[0], args.arguments[1], args.arguments[2]);
if constexpr (numParams == 4) return (this->*method) (args.arguments[0], args.arguments[1], args.arguments[2], args.arguments[3]);
static_assert (numParams <= 4);
return {};
}

template <int numParams, typename MethodType>
void addMethodBinding (const char* name, MethodType method)
{
reactRootComponent.engine.registerNativeMethod (name,
[this, method] (const juce::var::NativeFunctionArgs& args) -> juce::var
{
if (args.numArguments != numParams)
return juce::var::undefined();

if constexpr (numParams == 0) return (this->*method)();
if constexpr (numParams == 1) return (this->*method) (args.arguments[0]);
if constexpr (numParams == 2) return (this->*method) (args.arguments[0], args.arguments[1]);
if constexpr (numParams == 3) return (this->*method) (args.arguments[0], args.arguments[1], args.arguments[2]);
if constexpr (numParams == 4) return (this->*method) (args.arguments[0], args.arguments[1], args.arguments[2], args.arguments[3]);
static_assert (numParams <= 4);
return {};
return call<numParams> (method, args);
});
}

Expand Down

0 comments on commit 8728ae4

Please sign in to comment.