Skip to content

Commit

Permalink
Remove support for custom class names as per Syphon#88
Browse files Browse the repository at this point in the history
Closes Syphon#88
  • Loading branch information
bangnoise committed Apr 11, 2023
1 parent fc4f4a2 commit 8262732
Show file tree
Hide file tree
Showing 28 changed files with 70 additions and 309 deletions.
6 changes: 1 addition & 5 deletions Building Syphon.md
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
We support custom framework builds with unique class names to allow the framework to be embedded in a plugin without conflict with any other loaded instances.

To create a custom build, set ````SYPHON_UNIQUE_CLASS_NAME_PREFIX=MyPrefix```` in the Preprocessor Macros (````GCC_PREPROCESSOR_DEFINITIONS````) build setting.

To build the documentation you must have [Doxygen](http://www.doxygen.org/) installed. Use the ````DOXYGEN_PATH```` build setting to set the path (the default is the Applications folder).
To build the documentation you must have [Doxygen](http://www.doxygen.org/) installed. Use the ````DOXYGEN_PATH```` build setting to set the path (the default is the Applications folder).
55 changes: 11 additions & 44 deletions Exported_Symbols.exp
Original file line number Diff line number Diff line change
@@ -1,47 +1,14 @@
//
// Exported Symbols.exp
// Syphon
//
// Copyright 2010-2011 bangnoise (Tom Butterworth) & vade (Anton Marini).
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//
// This file gets passed through the C preprocessor before it is used


SYPHON_UNIQUE_CLASS_SYMBOL(SyphonOpenGLClient)
SYPHON_UNIQUE_CLASS_SYMBOL(SyphonClientBase)
SYPHON_UNIQUE_CLASS_SYMBOL(SyphonClient)
SYPHON_UNIQUE_CLASS_SYMBOL(SyphonOpenGLServer)
SYPHON_UNIQUE_CLASS_SYMBOL(SyphonServerBase)
SYPHON_UNIQUE_CLASS_SYMBOL(SyphonServer)
SYPHON_UNIQUE_CLASS_SYMBOL(SyphonServerDirectory)
SYPHON_UNIQUE_CLASS_SYMBOL(SyphonOpenGLImage)
SYPHON_UNIQUE_CLASS_SYMBOL(SyphonImage)
SYPHON_UNIQUE_CLASS_SYMBOL(SyphonMetalServer)
SYPHON_UNIQUE_CLASS_SYMBOL(SyphonMetalClient)

.objc_class_name_SyphonOpenGLClient
.objc_class_name_SyphonClientBase
.objc_class_name_SyphonClient
.objc_class_name_SyphonOpenGLServer
.objc_class_name_SyphonServerBase
.objc_class_name_SyphonServer
.objc_class_name_SyphonServerDirectory
.objc_class_name_SyphonOpenGLImage
.objc_class_name_SyphonImage
.objc_class_name_SyphonMetalServer
.objc_class_name_SyphonMetalClient
_SyphonServerAnnounceNotification
_SyphonServerDescriptionAppNameKey
_SyphonServerDescriptionIconKey
Expand Down
19 changes: 0 additions & 19 deletions Syphon.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,25 +154,6 @@
[myClient stop];
@endcode
@section plugins Syphon.framework in a Plugin
If you are using Syphon in any sort of plugin, please download the framework source and compile a version of the framework with unique class names. This avoids class-name conflicts if another plugin or the host application also embeds the Syphon framework. The framework source is set up to make this easy for you: you just need to change one build setting.
<ol>
<li><h4>Open the framework's Xcode project.</h4>
<p></p>
</li>
<li><h4>Define SYPHON_UNIQUE_CLASS_NAME_PREFIX using the Preprocessor Macros build setting.</h4>
<p>Select the Syphon target in the project window.<br/>
Click the Build Settings tab to display the build settings.<br/>
Scroll down (or use the search field) to find the Preprocessor Macros (GCC_PREPROCESSOR_DEFINITIONS) setting.<br/>
Double click the setting to add SYPHON_UNIQUE_CLASS_NAME_PREFIX=MyPluginName as a macro.
</p></li>
<li><h4>Build the framework.</h4>
<p>The built framework will have custom class names. The headers alias the custom names, so you can use SyphonOpenGLServer, SyphonOpenGLClient, SyphonOpenGLImage and SyphonServerDirectory as normal in your code.<br/>
</p></li>
</ol>
@section help More examples and help
Example projects implementing a server and client are included with the Syphon SDK. You can also examine the source to some Syphon implementations on <a href="https://github.com/Syphon">GitHub</a>.
Expand Down
115 changes: 28 additions & 87 deletions Syphon.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions SyphonBuildMacros.h

This file was deleted.

8 changes: 1 addition & 7 deletions SyphonCFMessageReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@
#import <Foundation/Foundation.h>
#import "SyphonMessageReceiver.h"

#define SYPHON_CFMESSAGE_RECEIVER_UNIQUE_CLASS_NAME SYPHON_UNIQUE_CLASS_NAME(SyphonCFMessageReceiver)

@interface SYPHON_CFMESSAGE_RECEIVER_UNIQUE_CLASS_NAME : SyphonMessageReceiver
@interface SyphonCFMessageReceiver : SyphonMessageReceiver

@end

#if defined(SYPHON_USE_CLASS_ALIAS)
@compatibility_alias SyphonCFMessageReceiver SYPHON_CFMESSAGE_RECEIVER_UNIQUE_CLASS_NAME;
#endif
8 changes: 1 addition & 7 deletions SyphonCFMessageSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,5 @@
#import "SyphonMessageQueue.h"
#import "SyphonDispatch.h"

#define SYPHON_CFMESSAGE_SENDER_UNIQUE_CLASS_NAME SYPHON_UNIQUE_CLASS_NAME(SyphonCFMessageSender)

@interface SYPHON_CFMESSAGE_SENDER_UNIQUE_CLASS_NAME : SyphonMessageSender
@interface SyphonCFMessageSender : SyphonMessageSender
@end

#if defined(SYPHON_USE_CLASS_ALIAS)
@compatibility_alias SyphonCFMessageSender SYPHON_CFMESSAGE_SENDER_UNIQUE_CLASS_NAME;
#endif
10 changes: 2 additions & 8 deletions SyphonClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,9 @@

NS_ASSUME_NONNULL_BEGIN

#define SYPHON_CLIENT_UNIQUE_CLASS_NAME SYPHON_UNIQUE_CLASS_NAME(SyphonClient)

DEPRECATED_MSG_ATTRIBUTE("Use SyphonOpenGLClient")
@interface SYPHON_CLIENT_UNIQUE_CLASS_NAME : SyphonOpenGLClient
- (id)initWithServerDescription:(NSDictionary *)description context:(CGLContextObj)context options:(nullable NSDictionary *)options newFrameHandler:(nullable void (^)(SYPHON_CLIENT_UNIQUE_CLASS_NAME *client))handler;
@interface SyphonClient : SyphonOpenGLClient
- (id)initWithServerDescription:(NSDictionary *)description context:(CGLContextObj)context options:(nullable NSDictionary *)options newFrameHandler:(nullable void (^)(SyphonClient *client))handler;
@end

#if defined(SYPHON_USE_CLASS_ALIAS)
@compatibility_alias SyphonClient SYPHON_CLIENT_UNIQUE_CLASS_NAME;
#endif

NS_ASSUME_NONNULL_END
8 changes: 1 addition & 7 deletions SyphonClientBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@

NS_ASSUME_NONNULL_BEGIN

#define SYPHON_CLIENT_BASE_UNIQUE_CLASS_NAME SYPHON_UNIQUE_CLASS_NAME(SyphonClientBase)

@interface SYPHON_CLIENT_BASE_UNIQUE_CLASS_NAME : NSObject
@interface SyphonClientBase : NSObject
/*!
Returns a new client instance for the described server. You should check the isValid property after initialization to ensure a connection was made to the server.
@param description Typically acquired from the shared SyphonServerDirectory, or one of Syphon's notifications.
Expand Down Expand Up @@ -66,8 +64,4 @@ NS_ASSUME_NONNULL_BEGIN
@property (readonly) BOOL hasNewFrame;
@end

#if defined(SYPHON_USE_CLASS_ALIAS)
@compatibility_alias SyphonClientBase SYPHON_CLIENT_BASE_UNIQUE_CLASS_NAME;
#endif

NS_ASSUME_NONNULL_END
8 changes: 1 addition & 7 deletions SyphonClientConnectionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,11 @@
- (void)invalidateFrame;
@end

#define SYPHON_CLIENT_CONNECTION_MANAGER_UNIQUE_CLASS_NAME SYPHON_UNIQUE_CLASS_NAME(SyphonClientConnectionManager)

@interface SYPHON_CLIENT_CONNECTION_MANAGER_UNIQUE_CLASS_NAME : NSObject
@interface SyphonClientConnectionManager : NSObject
- (id)initWithServerDescription:(NSDictionary *)description;
@property (readonly) BOOL isValid;
- (void)addInfoClient:(id <SyphonInfoReceiving>)client isFrameClient:(BOOL)frameClient; // Must be
- (void)removeInfoClient:(id <SyphonInfoReceiving>)client isFrameClient:(BOOL)frameClient; // paired
- (IOSurfaceRef)newSurface;
@property (readonly) NSUInteger frameID;
@end

#if defined(SYPHON_USE_CLASS_ALIAS)
@compatibility_alias SyphonClientConnectionManager SYPHON_CLIENT_CONNECTION_MANAGER_UNIQUE_CLASS_NAME;
#endif
8 changes: 1 addition & 7 deletions SyphonImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,9 @@

NS_ASSUME_NONNULL_BEGIN

#define SYPHON_IMAGE_UNIQUE_CLASS_NAME SYPHON_UNIQUE_CLASS_NAME(SyphonImage)

DEPRECATED_MSG_ATTRIBUTE("Use SyphonOpenGLImage")
@interface SYPHON_IMAGE_UNIQUE_CLASS_NAME : SyphonOpenGLImage
@interface SyphonImage : SyphonOpenGLImage

@end

#if defined(SYPHON_USE_CLASS_ALIAS)
@compatibility_alias SyphonImage SYPHON_IMAGE_UNIQUE_CLASS_NAME;
#endif

NS_ASSUME_NONNULL_END
8 changes: 1 addition & 7 deletions SyphonImageBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
#import <Foundation/Foundation.h>
#import <IOSurface/IOSurface.h>

#define SYPHON_IMAGE_BASE_UNIQUE_CLASS_NAME SYPHON_UNIQUE_CLASS_NAME(SyphonImageBase)

@interface SYPHON_IMAGE_BASE_UNIQUE_CLASS_NAME : NSObject
@interface SyphonImageBase : NSObject
/*!
If you implement your own subclass of SyphonImageBase, you must call this designated initializer from your own initializer.
Expand All @@ -43,7 +41,3 @@
*/
- (id)initWithSurface:(IOSurfaceRef)surfaceRef NS_DESIGNATED_INITIALIZER;
@end

#if defined(SYPHON_USE_CLASS_ALIAS)
@compatibility_alias SyphonImageBase SYPHON_IMAGE_BASE_UNIQUE_CLASS_NAME;
#endif
8 changes: 1 addition & 7 deletions SyphonMessageQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
*/

#define SYPHON_MESSAGE_QUEUE_UNIQUE_CLASS_NAME SYPHON_UNIQUE_CLASS_NAME(SyphonMessageQueue)

@interface SYPHON_MESSAGE_QUEUE_UNIQUE_CLASS_NAME : NSObject
@interface SyphonMessageQueue : NSObject

- (void)queue:(NSData *)content ofType:(uint32_t)type;
/*
Expand All @@ -58,7 +56,3 @@
@property (readwrite, assign) void *userInfo;

@end

#if defined(SYPHON_USE_CLASS_ALIAS)
@compatibility_alias SyphonMessageQueue SYPHON_MESSAGE_QUEUE_UNIQUE_CLASS_NAME;
#endif
10 changes: 2 additions & 8 deletions SyphonMessageReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@

#import <Foundation/Foundation.h>

#define SYPHON_MESSAGE_RECEIVER_UNIQUE_CLASS_NAME SYPHON_UNIQUE_CLASS_NAME(SyphonMessageReceiver)

@interface SYPHON_MESSAGE_RECEIVER_UNIQUE_CLASS_NAME : NSObject
@interface SyphonMessageReceiver : NSObject
- (id)initForName:(NSString *)name
protocol:(NSString *)protocolName
allowedClasses:(NSSet<Class> *)classes
Expand All @@ -41,10 +39,6 @@
// Always invalidate before release
- (void)invalidate;
@end
@interface SYPHON_MESSAGE_RECEIVER_UNIQUE_CLASS_NAME (Subclassing)
@interface SyphonMessageReceiver (Subclassing)
- (void)receiveMessageWithPayload:(id)payload ofType:(uint32_t)type;
@end

#if defined(SYPHON_USE_CLASS_ALIAS)
@compatibility_alias SyphonMessageReceiver SYPHON_MESSAGE_RECEIVER_UNIQUE_CLASS_NAME;
#endif
10 changes: 2 additions & 8 deletions SyphonMessageSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,12 @@

#import <Foundation/Foundation.h>

#define SYPHON_MESSAGE_SENDER_UNIQUE_CLASS_NAME SYPHON_UNIQUE_CLASS_NAME(SyphonMessageSender)

@interface SYPHON_MESSAGE_SENDER_UNIQUE_CLASS_NAME : NSObject
@interface SyphonMessageSender : NSObject
- (id)initForName:(NSString *)name protocol:(NSString *)protocolName invalidationHandler:(void (^)(void))handler;
@property (readonly) NSString *name;
@property (readonly) BOOL isValid;
- (void)send:(id <NSCoding>)payload ofType:(uint32_t)type;
@end
@interface SYPHON_MESSAGE_SENDER_UNIQUE_CLASS_NAME (Subclassing)
@interface SyphonMessageSender (Subclassing)
- (void)invalidate;
@end

#if defined(SYPHON_USE_CLASS_ALIAS)
@compatibility_alias SyphonMessageSender SYPHON_MESSAGE_SENDER_UNIQUE_CLASS_NAME;
#endif
11 changes: 2 additions & 9 deletions SyphonMetalClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@
#import <Metal/Metal.h>
#import <Syphon/SyphonClientBase.h>

#define SYPHON_METAL_CLIENT_UNIQUE_CLASS_NAME SYPHON_UNIQUE_CLASS_NAME(SyphonMetalClient)

NS_ASSUME_NONNULL_BEGIN

@interface SYPHON_METAL_CLIENT_UNIQUE_CLASS_NAME : SyphonClientBase
@interface SyphonMetalClient : SyphonClientBase

/*!
Returns a new client instance for the described server. You should check the isValid property after initialization to ensure a connection was made to the server.
Expand All @@ -48,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
- (id)initWithServerDescription:(NSDictionary *)description
device:(id<MTLDevice>)device
options:(nullable NSDictionary *)options
newFrameHandler:(nullable void (^)(SYPHON_METAL_CLIENT_UNIQUE_CLASS_NAME *client))handler;
newFrameHandler:(nullable void (^)(SyphonMetalClient *client))handler;

/*!
Returns a MTLTexture representing the current output from the server. The texture associated with the image may continue to update when you draw with it, but you should not depend on that behaviour: call this method every time you wish to access the current server frame.
Expand All @@ -64,9 +62,4 @@ Stops the client from receiving any further frames from the server. Use of this

@end


#if defined(SYPHON_USE_CLASS_ALIAS)
@compatibility_alias SyphonMetalClient SYPHON_METAL_CLIENT_UNIQUE_CLASS_NAME;
#endif

NS_ASSUME_NONNULL_END
4 changes: 2 additions & 2 deletions SyphonMetalClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#import "SyphonSubclassing.h"
#import <os/lock.h>

@implementation SYPHON_METAL_CLIENT_UNIQUE_CLASS_NAME
@implementation SyphonMetalClient
{
os_unfair_lock _threadLock;
id<MTLTexture> _frame;
Expand All @@ -43,7 +43,7 @@ @implementation SYPHON_METAL_CLIENT_UNIQUE_CLASS_NAME
- (id)initWithServerDescription:(NSDictionary *)description
device:(id<MTLDevice>)theDevice
options:(NSDictionary *)options
newFrameHandler:(void (^)(SYPHON_METAL_CLIENT_UNIQUE_CLASS_NAME *client))handler
newFrameHandler:(void (^)(SyphonMetalClient *client))handler
{
self = [super initWithServerDescription:description options:options newFrameHandler:handler];
if( self )
Expand Down
3 changes: 1 addition & 2 deletions SyphonMetalServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ extern NSString * const SyphonServerOptionIsPrivate;
It is safe to access instances of this class across threads.
*/

#define SYPHON_METAL_SERVER_UNIQUE_CLASS_NAME SYPHON_UNIQUE_CLASS_NAME(SyphonMetalServer)
@interface SYPHON_METAL_SERVER_UNIQUE_CLASS_NAME : SyphonServerBase
@interface SyphonMetalServer : SyphonServerBase

/** @name Instantiation */
/** @{ */
Expand Down
2 changes: 1 addition & 1 deletion SyphonMetalServer.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#import "SyphonPrivate.h"
#import "SyphonSubclassing.h"

@implementation SYPHON_METAL_SERVER_UNIQUE_CLASS_NAME
@implementation SyphonMetalServer
{
id<MTLTexture> _surfaceTexture;
id<MTLDevice> _device;
Expand Down
10 changes: 2 additions & 8 deletions SyphonOpenGLClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
#import <OpenGL/OpenGL.h>
#import <Syphon/SyphonClientBase.h>

#define SYPHON_OPENGL_CLIENT_UNIQUE_CLASS_NAME SYPHON_UNIQUE_CLASS_NAME(SyphonOpenGLClient)

@class SyphonOpenGLImage;

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -45,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
It is safe to access instances of this class across threads, with the usual limitatiions related to OpenGL. The calls to SyphonOpenGLClient which may cause work to be done in a GL context are: -newFrameImage, -stop and -release.
*/

@interface SYPHON_OPENGL_CLIENT_UNIQUE_CLASS_NAME : SyphonClientBase
@interface SyphonOpenGLClient : SyphonClientBase

/*!
Returns a new client instance for the described server. You should check the isValid property after initialization to ensure a connection was made to the server.
Expand All @@ -55,7 +53,7 @@ NS_ASSUME_NONNULL_BEGIN
@param handler A block which is invoked when a new frame becomes available. handler may be nil. This block may be invoked on a thread other than that on which the client was created.
@returns A newly initialized SyphonOpenGLClient object, or nil if a client could not be created.
*/
- (id)initWithServerDescription:(NSDictionary *)description context:(CGLContextObj)context options:(nullable NSDictionary *)options newFrameHandler:(nullable void (^)(SYPHON_OPENGL_CLIENT_UNIQUE_CLASS_NAME *client))handler;
- (id)initWithServerDescription:(NSDictionary *)description context:(CGLContextObj)context options:(nullable NSDictionary *)options newFrameHandler:(nullable void (^)(SyphonOpenGLClient *client))handler;

/*!
Returns the CGLContextObj associated with the client.
Expand Down Expand Up @@ -97,8 +95,4 @@ NS_ASSUME_NONNULL_BEGIN

@end

#if defined(SYPHON_USE_CLASS_ALIAS)
@compatibility_alias SyphonOpenGLClient SYPHON_OPENGL_CLIENT_UNIQUE_CLASS_NAME;
#endif

NS_ASSUME_NONNULL_END
Loading

0 comments on commit 8262732

Please sign in to comment.