Skip to content

Commit

Permalink
F-Script 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
pmougin committed Oct 26, 2009
1 parent 6da6483 commit bb1724a
Show file tree
Hide file tree
Showing 61 changed files with 854 additions and 15,422 deletions.
22 changes: 22 additions & 0 deletions F-Script/FSNewlyAllocatedObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* FSNewlyAllocatedObject.h Copyright (c) 2009 Philippe Mougin. */
/* This software is open source. See the license. */

#import <Cocoa/Cocoa.h>


@interface FSNewlyAllocatedObject : NSProxy
{
NSUInteger retainCount;
id target;
}

+ (id)newlyAllocatedObjectWithTarget:(id)theTarget;

- (NSString *)description;
- (void)forwardInvocation:(NSInvocation *)anInvocation;
- (id)initWithTarget:(id)theTarget;
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector;
- (void)release;
- (id)retain;

@end
73 changes: 73 additions & 0 deletions F-Script/FSNewlyAllocatedObject.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/* FSNewlyAllocatedObject.m Copyright (c) 2009 Philippe Mougin. */
/* This software is open source. See the license. */

#import "FSNewlyAllocatedObject.h"


@implementation FSNewlyAllocatedObject

+ (id)newlyAllocatedObjectWithTarget:(id)theTarget
{
return [[[self alloc] initWithTarget:theTarget] autorelease];
}

- (NSString *)description
{
return [[@"Proxy for a newly allocated " stringByAppendingString:NSStringFromClass(target->isa)] stringByAppendingString:@". Don't forget to initialize it and to use the object returned by the init... method instead of this proxy." ];
}

- (void)forwardInvocation:(NSInvocation *)anInvocation
{
[anInvocation setTarget:target];
[anInvocation invoke];
return;
}

/*
NSProxy (10.6) unfortunately does not support fast forwarding (i.e., forwardingTargetForSelector:)
If it does in a future version, we will be able to replace forwardInvocation: and methodSignatureForSelector: by the method below
- (id)forwardingTargetForSelector:(SEL)aSelector
{
return target;
}
*/

- (id)initWithTarget:(id)theTarget
{
retainCount = 1;

// We do not retain the target, as we stand for an object that has just been allocated but not yet initialized
// Retaining an uninitialized object is not a good idea, in particular because its retain count is not yet initialized
target = theTarget;

return self;
}

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

- (NSString *)printString
{
return [self description];
}

- (id)retain
{
retainCount++;
return self;
}

- (NSUInteger)retainCount
{
return retainCount;
}

- (void)release
{
if (--retainCount == 0) [self dealloc];
}

@end
33 changes: 26 additions & 7 deletions F-Script/FScriptAppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ void RestartWithCorrectGarbageCollectionSettingIfNecessary()


NSString *findPathToFileInLibraryWithinUserDomain(NSString *fileName)
/*" Retuns the path to the first occurrence of fileName in a Library
directory within the User domain. "*/
/*" Returns the path to the first occurrence of fileName in a Library directory within the User domain. "*/
{
NSString *result = nil; // the returned path
NSString *candidate; // candidate paths
Expand All @@ -113,15 +112,14 @@ void RestartWithCorrectGarbageCollectionSettingIfNecessary()
result = [candidate stringByAppendingPathComponent:fileName];
if(![[NSFileManager defaultManager] fileExistsAtPath:result])
{
result = nil;
result = nil;
}
}
return result;
}

NSString *findPathToFileInLibraryWithinSystemDomain(NSString *fileName)
/*" Retuns the path to the first occurrence of fileName in a Library
directory within the System domain. "*/
/*" Returns the path to the first occurrence of fileName in a Library directory within the System domain. "*/
{
NSString *result = nil; // the returned path
NSString *candidate; // candidate paths
Expand All @@ -136,7 +134,7 @@ void RestartWithCorrectGarbageCollectionSettingIfNecessary()
result = [candidate stringByAppendingPathComponent:fileName];
if(![[NSFileManager defaultManager] fileExistsAtPath:result])
{
result = nil;
result = nil;
}
}
return result;
Expand Down Expand Up @@ -201,6 +199,27 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"FScriptLoadSystemFrameworks"])
[self loadSystemFrameworks];

if (floor(NSAppKitVersionNumber) > 949)
{
// 10.6 or later system
NSString *systemFrameworksDirectoryPath;
NSString *path;

systemFrameworksDirectoryPath = findPathToFileInLibraryWithinSystemDomain(@"Frameworks");
if (systemFrameworksDirectoryPath)
{
path = [systemFrameworksDirectoryPath stringByAppendingPathComponent:@"PreferencePanes.framework"]; [[NSBundle bundleWithPath:path] load];
path = [systemFrameworksDirectoryPath stringByAppendingPathComponent:@"ScreenSaver.framework"]; [[NSBundle bundleWithPath:path] load];

path = [systemFrameworksDirectoryPath stringByAppendingPathComponent:@"CoreLocation.framework"]; [[NSBundle bundleWithPath:path] load];
path = [systemFrameworksDirectoryPath stringByAppendingPathComponent:@"CoreWLAN.framework"]; [[NSBundle bundleWithPath:path] load];
path = [systemFrameworksDirectoryPath stringByAppendingPathComponent:@"ImageCaptureCore.framework"]; [[NSBundle bundleWithPath:path] load];
path = [systemFrameworksDirectoryPath stringByAppendingPathComponent:@"OpenDirectory.framework"]; [[NSBundle bundleWithPath:path] load];
path = [systemFrameworksDirectoryPath stringByAppendingPathComponent:@"ServerNotification.framework"]; [[NSBundle bundleWithPath:path] load];

}
}

if (!repositoryPath || ![fileManager fileExistsAtPath:repositoryPath isDirectory:&b])
{
NSString *applicationSupportDirectoryPath = findPathToFileInLibraryWithinUserDomain(@"Application Support");
Expand Down Expand Up @@ -457,7 +476,7 @@ - (void)updatePreference:(id)sender // action
//NSLog(@"** updatePreference");
if (sender == fontSizeUI)
{
[[NSUserDefaults standardUserDefaults] setFloat:[fontSizeUI doubleValue] forKey:@"FScriptFontSize"];
[[NSUserDefaults standardUserDefaults] setDouble:[fontSizeUI doubleValue] forKey:@"FScriptFontSize"];
[interpreterView setFontSize:[fontSizeUI doubleValue]];
}
else if (sender == shouldJournalUI)
Expand Down
Loading

0 comments on commit bb1724a

Please sign in to comment.