Skip to content

Commit

Permalink
ObjC Helpers: Automatically derive appropriate signature for function
Browse files Browse the repository at this point in the history
  • Loading branch information
reuk committed Nov 24, 2021
1 parent b4bc2c8 commit 81fa777
Show file tree
Hide file tree
Showing 27 changed files with 405 additions and 408 deletions.
14 changes: 7 additions & 7 deletions modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1622,10 +1622,10 @@ void deleteActiveEditors()
addIvar<JuceAU*> ("au");
addIvar<EditorCompHolder*> ("editor");

addMethod (@selector (dealloc), dealloc, "v@:");
addMethod (@selector (applicationWillTerminate:), applicationWillTerminate, "v@:@");
addMethod (@selector (viewDidMoveToWindow), viewDidMoveToWindow, "v@:");
addMethod (@selector (mouseDownCanMoveWindow), mouseDownCanMoveWindow, "c@:");
addMethod (@selector (dealloc), dealloc);
addMethod (@selector (applicationWillTerminate:), applicationWillTerminate);
addMethod (@selector (viewDidMoveToWindow), viewDidMoveToWindow);
addMethod (@selector (mouseDownCanMoveWindow), mouseDownCanMoveWindow);

registerClass();
}
Expand Down Expand Up @@ -1709,9 +1709,9 @@ static BOOL mouseDownCanMoveWindow (id, SEL)
{
JuceUICreationClass() : ObjCClass<NSObject> ("JUCE_AUCocoaViewClass_")
{
addMethod (@selector (interfaceVersion), interfaceVersion, @encode (unsigned int), "@:");
addMethod (@selector (description), description, @encode (NSString*), "@:");
addMethod (@selector (uiViewForAudioUnit:withSize:), uiViewForAudioUnit, @encode (NSView*), "@:", @encode (AudioUnit), @encode (NSSize));
addMethod (@selector (interfaceVersion), interfaceVersion);
addMethod (@selector (description), description);
addMethod (@selector (uiViewForAudioUnit:withSize:), uiViewForAudioUnit);

addProtocol (@protocol (AUCocoaUIBase));

Expand Down
70 changes: 32 additions & 38 deletions modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -216,73 +216,67 @@ virtual void deallocateRenderResources()
addIvar<JuceAudioUnitv3Base*> ("cppObject");

JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wundeclared-selector")
addMethod (@selector (initWithComponentDescription:options:error:juceClass:),
initWithComponentDescriptionAndJuceClass, "@@:",
@encode (AudioComponentDescription),
@encode (AudioComponentInstantiationOptions), "^@@");
addMethod (@selector (initWithComponentDescription:options:error:juceClass:), initWithComponentDescriptionAndJuceClass);
JUCE_END_IGNORE_WARNINGS_GCC_LIKE

addMethod (@selector (initWithComponentDescription:options:error:),
initWithComponentDescription, "@@:",
@encode (AudioComponentDescription),
@encode (AudioComponentInstantiationOptions), "^@");
addMethod (@selector (initWithComponentDescription:options:error:), initWithComponentDescription);

addMethod (@selector (dealloc), dealloc, "v@:");
addMethod (@selector (dealloc), dealloc);

//==============================================================================
addMethod (@selector (reset), reset, "v@:");
addMethod (@selector (reset), reset);

//==============================================================================
addMethod (@selector (currentPreset), getCurrentPreset, "@@:");
addMethod (@selector (setCurrentPreset:), setCurrentPreset, "v@:@");
addMethod (@selector (factoryPresets), getFactoryPresets, "@@:");
addMethod (@selector (fullState), getFullState, "@@:");
addMethod (@selector (setFullState:), setFullState, "v@:@");
addMethod (@selector (parameterTree), getParameterTree, "@@:");
addMethod (@selector (parametersForOverviewWithCount:), parametersForOverviewWithCount, "@@:", @encode (NSInteger));
addMethod (@selector (currentPreset), getCurrentPreset);
addMethod (@selector (setCurrentPreset:), setCurrentPreset);
addMethod (@selector (factoryPresets), getFactoryPresets);
addMethod (@selector (fullState), getFullState);
addMethod (@selector (setFullState:), setFullState);
addMethod (@selector (parameterTree), getParameterTree);
addMethod (@selector (parametersForOverviewWithCount:), parametersForOverviewWithCount);

//==============================================================================
addMethod (@selector (latency), getLatency, @encode (NSTimeInterval), "@:");
addMethod (@selector (tailTime), getTailTime, @encode (NSTimeInterval), "@:");
addMethod (@selector (latency), getLatency);
addMethod (@selector (tailTime), getTailTime);

//==============================================================================
addMethod (@selector (inputBusses), getInputBusses, "@@:");
addMethod (@selector (outputBusses), getOutputBusses, "@@:");
addMethod (@selector (channelCapabilities), getChannelCapabilities, "@@:");
addMethod (@selector (shouldChangeToFormat:forBus:), shouldChangeToFormat, "c@:@@");
addMethod (@selector (inputBusses), getInputBusses);
addMethod (@selector (outputBusses), getOutputBusses);
addMethod (@selector (channelCapabilities), getChannelCapabilities);
addMethod (@selector (shouldChangeToFormat:forBus:), shouldChangeToFormat);

//==============================================================================
addMethod (@selector (virtualMIDICableCount), getVirtualMIDICableCount, @encode (NSInteger), "@:");
addMethod (@selector (virtualMIDICableCount), getVirtualMIDICableCount);

JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wundeclared-selector")
addMethod (@selector (supportsMPE), getSupportsMPE, @encode (BOOL), "@:");
addMethod (@selector (supportsMPE), getSupportsMPE);
JUCE_END_IGNORE_WARNINGS_GCC_LIKE

#if JUCE_AUV3_MIDI_OUTPUT_SUPPORTED
if (@available (macOS 10.13, iOS 11.0, *))
addMethod (@selector (MIDIOutputNames), getMIDIOutputNames, "@@:");
addMethod (@selector (MIDIOutputNames), getMIDIOutputNames);
#endif

//==============================================================================
addMethod (@selector (internalRenderBlock), getInternalRenderBlock, @encode (AUInternalRenderBlock), "@:");
addMethod (@selector (canProcessInPlace), getCanProcessInPlace, @encode (BOOL), "@:");
addMethod (@selector (isRenderingOffline), getRenderingOffline, @encode (BOOL), "@:");
addMethod (@selector (setRenderingOffline:), setRenderingOffline, "v@:", @encode (BOOL));
addMethod (@selector (shouldBypassEffect), getShouldBypassEffect, @encode (BOOL), "@:");
addMethod (@selector (setShouldBypassEffect:), setShouldBypassEffect, "v@:", @encode (BOOL));
addMethod (@selector (allocateRenderResourcesAndReturnError:), allocateRenderResourcesAndReturnError, "c@:^@");
addMethod (@selector (deallocateRenderResources), deallocateRenderResources, "v@:");
addMethod (@selector (internalRenderBlock), getInternalRenderBlock);
addMethod (@selector (canProcessInPlace), getCanProcessInPlace);
addMethod (@selector (isRenderingOffline), getRenderingOffline);
addMethod (@selector (setRenderingOffline:), setRenderingOffline);
addMethod (@selector (shouldBypassEffect), getShouldBypassEffect);
addMethod (@selector (setShouldBypassEffect:), setShouldBypassEffect);
addMethod (@selector (allocateRenderResourcesAndReturnError:), allocateRenderResourcesAndReturnError);
addMethod (@selector (deallocateRenderResources), deallocateRenderResources);

//==============================================================================
addMethod (@selector (contextName), getContextName, "@@:");
addMethod (@selector (setContextName:), setContextName, "v@:@");
addMethod (@selector (contextName), getContextName);
addMethod (@selector (setContextName:), setContextName);

//==============================================================================
#if JUCE_AUV3_VIEW_CONFIG_SUPPORTED
if (@available (macOS 10.13, iOS 11.0, *))
{
addMethod (@selector (supportedViewConfigurations:), getSupportedViewConfigurations, "@@:@");
addMethod (@selector (selectViewConfiguration:), selectViewConfiguration, "v@:@");
addMethod (@selector (supportedViewConfigurations:), getSupportedViewConfigurations);
addMethod (@selector (selectViewConfiguration:), selectViewConfiguration);
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions modules/juce_audio_processors/juce_audio_processors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ struct NSViewComponentWithParent : public NSViewComponent,
{
addIvar<NSViewComponentWithParent*> ("owner");

addMethod (@selector (isFlipped), isFlipped, "c@:");
addMethod (@selector (isOpaque), isOpaque, "c@:");
addMethod (@selector (didAddSubview:), didAddSubview, "v@:@");
addMethod (@selector (isFlipped), isFlipped);
addMethod (@selector (isOpaque), isOpaque);
addMethod (@selector (didAddSubview:), didAddSubview);

registerClass();
}
Expand Down
19 changes: 9 additions & 10 deletions modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,19 @@ Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
addIvar<AudioSourceHolder*> ("source");

JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wundeclared-selector")
addMethod (@selector (initWithAudioSourceHolder:), initWithAudioSourceHolder, "@@:^v");
addMethod (@selector (verifyDataForTrack:intoBuffer:length:atAddress:blockSize:ioFlags:),
produceDataForTrack, "I@:@^cIQI^I");
addMethod (@selector (initWithAudioSourceHolder:), initWithAudioSourceHolder);
addMethod (@selector (verifyDataForTrack:intoBuffer:length:atAddress:blockSize:ioFlags:), produceDataForTrack);
JUCE_END_IGNORE_WARNINGS_GCC_LIKE

addMethod (@selector (cleanupTrackAfterBurn:), cleanupTrackAfterBurn, "v@:@");
addMethod (@selector (cleanupTrackAfterVerification:), cleanupTrackAfterVerification, "c@:@");
addMethod (@selector (estimateLengthOfTrack:), estimateLengthOfTrack, "Q@:@");
addMethod (@selector (prepareTrack:forBurn:toMedia:), prepareTrack, "c@:@@@");
addMethod (@selector (prepareTrackForVerification:), prepareTrackForVerification, "c@:@");
addMethod (@selector (cleanupTrackAfterBurn:), cleanupTrackAfterBurn);
addMethod (@selector (cleanupTrackAfterVerification:), cleanupTrackAfterVerification);
addMethod (@selector (estimateLengthOfTrack:), estimateLengthOfTrack);
addMethod (@selector (prepareTrack:forBurn:toMedia:), prepareTrack);
addMethod (@selector (prepareTrackForVerification:), prepareTrackForVerification);
addMethod (@selector (produceDataForTrack:intoBuffer:length:atAddress:blockSize:ioFlags:),
produceDataForTrack, "I@:@^cIQI^I");
produceDataForTrack);
addMethod (@selector (producePreGapForTrack:intoBuffer:length:atAddress:blockSize:ioFlags:),
produceDataForTrack, "I@:@^cIQI^I");
produceDataForTrack);

registerClass();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
addIvar<CABTLEMIDIWindowController*> ("controller");

JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wundeclared-selector")
addMethod (@selector (initWithCallbacks:), initWithCallbacks, "@@:^v");
addMethod (@selector (show:), show, "v@:^v");
addMethod (@selector (receivedWindowWillClose:), receivedWindowWillClose, "v@:^v");
addMethod (@selector (initWithCallbacks:), initWithCallbacks);
addMethod (@selector (show:), show);
addMethod (@selector (receivedWindowWillClose:), receivedWindowWillClose);
JUCE_END_IGNORE_WARNINGS_GCC_LIKE

addMethod (@selector (dealloc), dealloc, "v@:");
addMethod (@selector (dealloc), dealloc);

registerClass();
}
Expand Down
33 changes: 16 additions & 17 deletions modules/juce_core/native/juce_mac_Network.mm
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,13 @@ void run() override
{
addIvar<URLConnectionStatePreYosemite*> ("state");

addMethod (@selector (connection:didReceiveResponse:), didReceiveResponse, "v@:@@");
addMethod (@selector (connection:didFailWithError:), didFailWithError, "v@:@@");
addMethod (@selector (connection:didReceiveData:), didReceiveData, "v@:@@");
addMethod (@selector (connection:didReceiveResponse:), didReceiveResponse);
addMethod (@selector (connection:didFailWithError:), didFailWithError);
addMethod (@selector (connection:didReceiveData:), didReceiveData);
addMethod (@selector (connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:),
connectionDidSendBodyData, "v@:@iii");
addMethod (@selector (connectionDidFinishLoading:), connectionDidFinishLoading, "v@:@");
addMethod (@selector (connection:willSendRequest:redirectResponse:), willSendRequest, "@@:@@@");
connectionDidSendBodyData);
addMethod (@selector (connectionDidFinishLoading:), connectionDidFinishLoading);
addMethod (@selector (connection:willSendRequest:redirectResponse:), willSendRequest);

registerClass();
}
Expand Down Expand Up @@ -608,14 +608,14 @@ void run() override
addIvar<URLConnectionState*> ("state");

addMethod (@selector (URLSession:dataTask:didReceiveResponse:completionHandler:),
didReceiveResponse, "v@:@@@@");
addMethod (@selector (URLSession:didBecomeInvalidWithError:), didBecomeInvalidWithError, "v@:@@");
addMethod (@selector (URLSession:dataTask:didReceiveData:), didReceiveData, "v@:@@@");
didReceiveResponse);
addMethod (@selector (URLSession:didBecomeInvalidWithError:), didBecomeInvalidWithError);
addMethod (@selector (URLSession:dataTask:didReceiveData:), didReceiveData);
addMethod (@selector (URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:),
didSendBodyData, "v@:@@qqq");
didSendBodyData);
addMethod (@selector (URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:),
willPerformHTTPRedirection, "v@:@@@@@");
addMethod (@selector (URLSession:task:didCompleteWithError:), didCompleteWithError, "v@:@@@");
willPerformHTTPRedirection);
addMethod (@selector (URLSession:task:didCompleteWithError:), didCompleteWithError);

registerClass();
}
Expand Down Expand Up @@ -872,11 +872,10 @@ static void invokeNotify (const String& identifier)
{
addIvar<BackgroundDownloadTask*> ("state");

addMethod (@selector (URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:),
didWriteData, "v@:@@qqq");
addMethod (@selector (URLSession:downloadTask:didFinishDownloadingToURL:), didFinishDownloadingToURL, "v@:@@@");
addMethod (@selector (URLSession:task:didCompleteWithError:), didCompleteWithError, "v@:@@@");
addMethod (@selector (URLSession:didBecomeInvalidWithError:), didBecomeInvalidWithError, "v@:@@@");
addMethod (@selector (URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:), didWriteData);
addMethod (@selector (URLSession:downloadTask:didFinishDownloadingToURL:), didFinishDownloadingToURL);
addMethod (@selector (URLSession:task:didCompleteWithError:), didCompleteWithError);
addMethod (@selector (URLSession:didBecomeInvalidWithError:), didBecomeInvalidWithError);

registerClass();
}
Expand Down
Loading

0 comments on commit 81fa777

Please sign in to comment.