Skip to content

Commit

Permalink
updated code formatting (to standard C style), and updated xcode project
Browse files Browse the repository at this point in the history
  • Loading branch information
stevedekorte committed Jan 2, 2022
1 parent 43955cb commit 5c330e0
Show file tree
Hide file tree
Showing 19 changed files with 142 additions and 150 deletions.
Binary file modified .DS_Store
Binary file not shown.
62 changes: 58 additions & 4 deletions ActorKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,15 @@
AABB5D8B140E0C220020BA06 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0440;
LastUpgradeCheck = 1320;
};
buildConfigurationList = AABB5D8E140E0C220020BA06 /* Build configuration list for PBXProject "ActorKit" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = AABB5D89140E0C220020BA06;
productRefGroup = AABB5D96140E0C220020BA06 /* Products */;
Expand Down Expand Up @@ -269,11 +270,32 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand All @@ -284,6 +306,9 @@
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
ONLY_ACTIVE_ARCH = YES;
Expand All @@ -295,15 +320,38 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
SDKROOT = macosx;
Expand All @@ -313,13 +361,16 @@
AABB5DAB140E0C220020BA06 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ActorKit/ActorKit-Prefix.pch";
INFOPLIST_FILE = "ActorKit/ActorKit-Info.plist";
MACOSX_DEPLOYMENT_TARGET = 12.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.dekorte.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = framework;
};
Expand All @@ -328,13 +379,16 @@
AABB5DAC140E0C220020BA06 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
FRAMEWORK_VERSION = A;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ActorKit/ActorKit-Prefix.pch";
INFOPLIST_FILE = "ActorKit/ActorKit-Info.plist";
MACOSX_DEPLOYMENT_TARGET = 12.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.dekorte.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = framework;
};
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0440"
LastUpgradeVersion = "1320"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -23,30 +23,29 @@
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
Expand Down
2 changes: 1 addition & 1 deletion ActorKit/ActorKit-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.dekorte.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
3 changes: 1 addition & 2 deletions ActorKit/ActorProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
#import "Mutex.h"
#import "NSThread+Actor.h"

@interface ActorProxy : NSProxy
{
@interface ActorProxy : NSProxy {
// using the "actor" prefix to avoid name conflict with proxied object
id actorTarget;
Mutex *actorMutex;
Expand Down
39 changes: 13 additions & 26 deletions ActorKit/ActorProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,16 @@ @implementation ActorProxy
@synthesize actorQueueSize;
@synthesize actorQueueLimit;

- init
{
- init {
//self = [super init]; // NSProxy doesn't implement init
return self;
}

- (void)setProxyTarget:anObject
{
- (void)setProxyTarget:anObject {
[self setActorTarget:anObject];
}

- (NSThread *)actorThreadCreateOrResumeIfNeeded
{
- (NSThread *)actorThreadCreateOrResumeIfNeeded {
NSThread *thread = [self actorThread];

if (!thread) {
Expand All @@ -48,8 +45,7 @@ - (NSThread *)actorThreadCreateOrResumeIfNeeded
return thread;
}

- (void)dealloc
{
- (void)dealloc {
// threads retain the Future's they are waiting on, which retains the actor
// so dealloc should only occur when it's safe of dependencies

Expand All @@ -60,8 +56,7 @@ - (void)dealloc
[super dealloc];
}

- (FutureProxy *)futurePerformInvocation:(NSInvocation *)anInvocation
{
- (FutureProxy *)futurePerformInvocation:(NSInvocation *)anInvocation {
BOOL willPauseCaller = NO;
NSLock *lock = [[self actorThread] lock];

Expand Down Expand Up @@ -93,8 +88,7 @@ - (FutureProxy *)futurePerformInvocation:(NSInvocation *)anInvocation
return future;
}

- (void)actorRunLoop:sender
{
- (void)actorRunLoop:sender {
NSLock *lock = [[self actorThread] lock];

if ([NSThread currentThread] != [self actorThread]) {
Expand Down Expand Up @@ -124,13 +118,11 @@ - (void)actorRunLoop:sender
[self setActorMutex:nil];
}

- (BOOL)respondsToSelector:(SEL)aSelector
{
- (BOOL)respondsToSelector:(SEL)aSelector {
return YES;
}

- (void)forwardInvocation:(NSInvocation *)anInvocation
{
- (void)forwardInvocation:(NSInvocation *)anInvocation {
if ([[anInvocation methodSignature] methodReturnType][0] != '@') {
NSString *msg = [NSString stringWithFormat:@"sent '%@' but only methods that return objects are supported",
NSStringFromSelector([anInvocation selector])];
Expand All @@ -142,8 +134,7 @@ - (void)forwardInvocation:(NSInvocation *)anInvocation
[anInvocation setReturnValue:(void *)&f];
}

- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
{
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
return [actorTarget methodSignatureForSelector:aSelector];
}

Expand All @@ -152,26 +143,22 @@ - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
// for use from within an actor method executing in order to
// pause actor thread while waiting on async ops or other callbacks

+ (ActorProxy *)currentActorProxy
{
+ (ActorProxy *)currentActorProxy {
return [[[NSThread currentThread] threadDictionary] objectForKey:@"actorProxy"];
}

- (id)pauseThread
{
- (id)pauseThread {
[actorMutex pauseThread];
id returnValue = [[[NSThread currentThread] threadDictionary] objectForKey:@"returnValue"];
[[[NSThread currentThread] threadDictionary] removeObjectForKey:@"returnValue"];
return returnValue;
}

- (void)resumeThread
{
- (void)resumeThread {
[actorMutex resumeAnyWaitingThreads];
}

- (void)resumeThreadWithReturnObject:(id)returnValue
{
- (void)resumeThreadWithReturnObject:(id)returnValue {
// might move returnValue to ivar
[[[NSThread currentThread] threadDictionary] setObject:returnValue forKey:@"returnValue"];
[self resumeThread];
Expand Down
3 changes: 1 addition & 2 deletions ActorKit/BatchProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
// Copyright 2011 Steve Dekorte. BSD licensed.
//

@interface BatchProxy : NSProxy
{
@interface BatchProxy : NSProxy {
// using the "batch" prefix to avoid name conflict with proxied object
id batchTarget;
}
Expand Down
28 changes: 9 additions & 19 deletions ActorKit/BatchProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,32 @@ @implementation BatchProxy

@synthesize batchTarget;

- init
{
- init {
//self = [super init]; // NSProxy doesn't implement init
return self;
}

- (void)dealloc
{
- (void)dealloc {
[self setBatchTarget:nil];
[super dealloc];
}

- (void)setProxyTarget:anObject
{
- (void)setProxyTarget:anObject {
[self setBatchTarget:anObject];
}

- (BOOL)respondsToSelector:(SEL)aSelector
{
- (BOOL)respondsToSelector:(SEL)aSelector {
return YES;
}

- (dispatch_queue_t)batchDispatchQueue
{
- (dispatch_queue_t)batchDispatchQueue {
return dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
}

- (void)forwardInvocation:(NSInvocation *)theInvocation
{
- (void)forwardInvocation:(NSInvocation *)theInvocation {
__block NSInvocation *anInvocation = theInvocation;

if ([[anInvocation methodSignature] methodReturnType][0] != '@')
{
if ([[anInvocation methodSignature] methodReturnType][0] != '@') {
NSString *msg = [NSString stringWithFormat:@"sent '%@' but only methods that return objects are supported",
NSStringFromSelector([anInvocation selector])];
NSLog(@"BatchProxy ERROR: %@", msg);
Expand All @@ -59,9 +52,7 @@ - (void)forwardInvocation:(NSInvocation *)theInvocation

// use an invocation pool?

dispatch_apply(length, [self batchDispatchQueue],
^(size_t i)
{
dispatch_apply(length, [self batchDispatchQueue], ^(size_t i) {
//printf("start %i\n", (int)i);
id item = [batchTarget objectAtIndex:i];
NSInvocation *copyInvocation = [anInvocation copy];
Expand All @@ -84,8 +75,7 @@ - (void)forwardInvocation:(NSInvocation *)theInvocation
[anInvocation setReturnValue:(void *)&resultsArray];
}

- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
{
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
if ([batchTarget count]) {
id firstObject = [batchTarget objectAtIndex:0];
NSMethodSignature *sig = [firstObject methodSignatureForSelector:aSelector];
Expand Down
3 changes: 1 addition & 2 deletions ActorKit/FutureProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

#import "Mutex.h"

@interface FutureProxy : NSProxy
{
@interface FutureProxy : NSProxy {
// these use the "future" prefix/suffix to avoid name collision with proxy target

id futureActor;
Expand Down
Loading

0 comments on commit 5c330e0

Please sign in to comment.