From cf487ba4de52952e681ba412d3a1d874f1515edb Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Tue, 12 Apr 2011 09:49:14 -0700 Subject: [PATCH 01/19] Change NibApplication template's slider to be continuous since it makes for a better first experience. Reviewed by me. --- .../NibApplication/Resources/MainMenu.xib | 294 ++++++++++-------- 1 file changed, 162 insertions(+), 132 deletions(-) diff --git a/Tools/capp/Resources/Templates/NibApplication/Resources/MainMenu.xib b/Tools/capp/Resources/Templates/NibApplication/Resources/MainMenu.xib index e9ae190c4..0c98cf0b6 100644 --- a/Tools/capp/Resources/Templates/NibApplication/Resources/MainMenu.xib +++ b/Tools/capp/Resources/Templates/NibApplication/Resources/MainMenu.xib @@ -1,28 +1,37 @@ - + 1050 - 9G55 - 677 - 949.43 - 353.00 - + 10J869 + 1306 + 1038.35 + 461.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 1306 + + YES - + NSView + NSMenu + NSWindowTemplate + NSMenuItem + NSSliderCell + NSTextField + NSTextFieldCell + NSSlider + NSCustomObject YES - com.apple.InterfaceBuilderKit com.apple.InterfaceBuilder.CocoaPlugin YES - - YES - - + YES + YES @@ -79,7 +88,7 @@ - UHJlZmVyZW5jZXPigKY + Preferences… , 1048576 2147483647 @@ -200,7 +209,7 @@ - T3BlbuKApg + Open… o 1048576 2147483647 @@ -264,7 +273,7 @@ - U2F2ZSBBc+KApg + Save As… S 1179648 2147483647 @@ -302,7 +311,7 @@ - UHJpbnTigKY + Print… p 1048576 2147483647 @@ -425,7 +434,7 @@ YES - RmluZOKApg + Find… f 1048576 2147483647 @@ -490,7 +499,7 @@ YES - U2hvdyBTcGVsbGluZ+KApg + Show Spelling… : 1048576 2147483647 @@ -1017,7 +1026,7 @@ - Q3VzdG9taXplIFRvb2xiYXLigKY + Customize Toolbar… 1048576 2147483647 @@ -1118,7 +1127,6 @@ Window NSWindow - {3.40282e+38, 3.40282e+38} 256 @@ -1129,21 +1137,22 @@ 301 {{192, 143}, {96, 21}} + YES - -2080244224 + -2079981824 0 Helvetica - 1.200000e+01 + 12 16 - 1.000000e+02 - 0.000000e+00 - 5.000000e+01 - 0.000000e+00 + 100 + 0.0 + 50 + 0.0 0 1 NO @@ -1155,6 +1164,7 @@ 301 {{192, 191}, {96, 22}} + YES -1804468671 @@ -1162,7 +1172,7 @@ LucidaGrande - 1.300000e+01 + 13 1044 @@ -1188,11 +1198,12 @@ - {480, 360} + {{7, 11}, {480, 360}} + {{0, 0}, {1440, 878}} - {3.40282e+38, 3.40282e+38} + {1e+13, 1e+13} AppController @@ -1719,28 +1730,26 @@ YES 0 - - YES - + -2 - - RmlsZSdzIE93bmVyA + + File's Owner -1 - + First Responder -3 - + Application @@ -1756,7 +1765,7 @@ - + MainMenu @@ -2292,7 +2301,7 @@ YES - + 372 @@ -2612,7 +2621,7 @@ 450 - + 452 @@ -2646,7 +2655,7 @@ YES - + YES -1.IBPluginDependency -2.IBPluginDependency @@ -2781,10 +2790,10 @@ 354.IBPluginDependency 354.ImportedFromIB2 371.IBEditorWindowLastContentRect + 371.IBPluginDependency 371.IBWindowTemplateEditedContentRect 371.NSWindowTemplate.visibleAtLaunch 371.editorWindowContentRectSynchronizationRect - 371.windowTemplate.maxSize 372.IBPluginDependency 375.IBPluginDependency 376.IBEditorWindowLastContentRect @@ -2877,117 +2886,117 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilderKit - com.apple.InterfaceBuilderKit com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + {{596, 852}, {216, 23}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{522, 812}, {146, 23}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{436, 809}, {64, 6}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{608, 612}, {275, 83}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{187, 434}, {243, 243}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{608, 612}, {167, 43}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{608, 612}, {241, 103}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{525, 802}, {197, 73}} {{143, 285}, {478, 20}} com.apple.InterfaceBuilder.CocoaPlugin - + {74, 862} {{6, 978}, {478, 20}} com.apple.InterfaceBuilder.CocoaPlugin @@ -2996,23 +3005,23 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{608, 612}, {215, 63}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{303, 221}, {480, 360}} + com.apple.InterfaceBuilder.CocoaPlugin {{303, 221}, {480, 360}} - + {{33, 99}, {480, 360}} - {3.40282e+38, 3.40282e+38} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin {{437, 242}, {86, 43}} @@ -3067,60 +3076,52 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{155, 102}, {245, 183}} com.apple.InterfaceBuilder.CocoaPlugin - + {{23, 794}, {245, 183}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{145, 474}, {199, 203}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + YES - - YES - - - YES - + + YES - - YES - - - YES - + + 459 @@ -3134,15 +3135,44 @@ theWindow NSWindow + + theWindow + + theWindow + NSWindow + + - IBUserSource - + IBProjectSource + ./Classes/AppController.h 0 - ../adsfsdf.xcodeproj + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES 3 + + YES + + YES + NSMenuCheckmark + NSMenuMixedState + + + YES + {9, 8} + {7, 2} + + From 1ecbe997df7184d32064966e6afee9f2dc0fd358 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Tue, 12 Apr 2011 09:49:14 -0700 Subject: [PATCH 02/19] Change NibApplication template's slider to be continuous since it makes for a better first experience. Reviewed by me. --- .../NibApplication/Resources/MainMenu.xib | 294 ++++++++++-------- 1 file changed, 162 insertions(+), 132 deletions(-) diff --git a/Tools/capp/Resources/Templates/NibApplication/Resources/MainMenu.xib b/Tools/capp/Resources/Templates/NibApplication/Resources/MainMenu.xib index e9ae190c4..0c98cf0b6 100644 --- a/Tools/capp/Resources/Templates/NibApplication/Resources/MainMenu.xib +++ b/Tools/capp/Resources/Templates/NibApplication/Resources/MainMenu.xib @@ -1,28 +1,37 @@ - + 1050 - 9G55 - 677 - 949.43 - 353.00 - + 10J869 + 1306 + 1038.35 + 461.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 1306 + + YES - + NSView + NSMenu + NSWindowTemplate + NSMenuItem + NSSliderCell + NSTextField + NSTextFieldCell + NSSlider + NSCustomObject YES - com.apple.InterfaceBuilderKit com.apple.InterfaceBuilder.CocoaPlugin YES - - YES - - + YES + YES @@ -79,7 +88,7 @@ - UHJlZmVyZW5jZXPigKY + Preferences… , 1048576 2147483647 @@ -200,7 +209,7 @@ - T3BlbuKApg + Open… o 1048576 2147483647 @@ -264,7 +273,7 @@ - U2F2ZSBBc+KApg + Save As… S 1179648 2147483647 @@ -302,7 +311,7 @@ - UHJpbnTigKY + Print… p 1048576 2147483647 @@ -425,7 +434,7 @@ YES - RmluZOKApg + Find… f 1048576 2147483647 @@ -490,7 +499,7 @@ YES - U2hvdyBTcGVsbGluZ+KApg + Show Spelling… : 1048576 2147483647 @@ -1017,7 +1026,7 @@ - Q3VzdG9taXplIFRvb2xiYXLigKY + Customize Toolbar… 1048576 2147483647 @@ -1118,7 +1127,6 @@ Window NSWindow - {3.40282e+38, 3.40282e+38} 256 @@ -1129,21 +1137,22 @@ 301 {{192, 143}, {96, 21}} + YES - -2080244224 + -2079981824 0 Helvetica - 1.200000e+01 + 12 16 - 1.000000e+02 - 0.000000e+00 - 5.000000e+01 - 0.000000e+00 + 100 + 0.0 + 50 + 0.0 0 1 NO @@ -1155,6 +1164,7 @@ 301 {{192, 191}, {96, 22}} + YES -1804468671 @@ -1162,7 +1172,7 @@ LucidaGrande - 1.300000e+01 + 13 1044 @@ -1188,11 +1198,12 @@ - {480, 360} + {{7, 11}, {480, 360}} + {{0, 0}, {1440, 878}} - {3.40282e+38, 3.40282e+38} + {1e+13, 1e+13} AppController @@ -1719,28 +1730,26 @@ YES 0 - - YES - + -2 - - RmlsZSdzIE93bmVyA + + File's Owner -1 - + First Responder -3 - + Application @@ -1756,7 +1765,7 @@ - + MainMenu @@ -2292,7 +2301,7 @@ YES - + 372 @@ -2612,7 +2621,7 @@ 450 - + 452 @@ -2646,7 +2655,7 @@ YES - + YES -1.IBPluginDependency -2.IBPluginDependency @@ -2781,10 +2790,10 @@ 354.IBPluginDependency 354.ImportedFromIB2 371.IBEditorWindowLastContentRect + 371.IBPluginDependency 371.IBWindowTemplateEditedContentRect 371.NSWindowTemplate.visibleAtLaunch 371.editorWindowContentRectSynchronizationRect - 371.windowTemplate.maxSize 372.IBPluginDependency 375.IBPluginDependency 376.IBEditorWindowLastContentRect @@ -2877,117 +2886,117 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilderKit - com.apple.InterfaceBuilderKit com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin + {{596, 852}, {216, 23}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{522, 812}, {146, 23}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{436, 809}, {64, 6}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{608, 612}, {275, 83}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{187, 434}, {243, 243}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{608, 612}, {167, 43}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{608, 612}, {241, 103}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{525, 802}, {197, 73}} {{143, 285}, {478, 20}} com.apple.InterfaceBuilder.CocoaPlugin - + {74, 862} {{6, 978}, {478, 20}} com.apple.InterfaceBuilder.CocoaPlugin @@ -2996,23 +3005,23 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{608, 612}, {215, 63}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{303, 221}, {480, 360}} + com.apple.InterfaceBuilder.CocoaPlugin {{303, 221}, {480, 360}} - + {{33, 99}, {480, 360}} - {3.40282e+38, 3.40282e+38} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin {{437, 242}, {86, 43}} @@ -3067,60 +3076,52 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{155, 102}, {245, 183}} com.apple.InterfaceBuilder.CocoaPlugin - + {{23, 794}, {245, 183}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + {{145, 474}, {199, 203}} com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin - + YES - - YES - - - YES - + + YES - - YES - - - YES - + + 459 @@ -3134,15 +3135,44 @@ theWindow NSWindow + + theWindow + + theWindow + NSWindow + + - IBUserSource - + IBProjectSource + ./Classes/AppController.h 0 - ../adsfsdf.xcodeproj + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES 3 + + YES + + YES + NSMenuCheckmark + NSMenuMixedState + + + YES + {9, 8} + {7, 2} + + From 025e761929e3449dece612018430106bed9d24a8 Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Wed, 13 Apr 2011 18:02:08 -0400 Subject: [PATCH 03/19] If $CAPP_BUILD is not set or entity is not found in it, look in the narwhal cappuccino package. --- Tools/nib2cib/main.j | 84 +++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 29 deletions(-) diff --git a/Tools/nib2cib/main.j b/Tools/nib2cib/main.j index 4102d29ae..7ab91ef33 100644 --- a/Tools/nib2cib/main.j +++ b/Tools/nib2cib/main.j @@ -439,7 +439,7 @@ function logFormatter(aString, aLevel, aTitle) function getThemeList(defaultTheme, options) { - var themes = [defaultTheme || getDefaultThemeName()]; + var themes = [defaultTheme || getAppKitDefaultThemeName()]; if (options.extraThemes) for (var i = 0; i < options.extraThemes.length; ++i) @@ -449,23 +449,62 @@ function getThemeList(defaultTheme, options) return themes; } -function getDefaultThemeName() +// Returns undefined if $CAPP_BUILD is not defined, false if path cannot be found in $CAPP_BUILD +function findInCappBuild(path, isDirectory, callback) { - var themeName = nil, - cappBuild = SYS.env["CAPP_BUILD"]; + var cappBuild = SYS.env["CAPP_BUILD"]; - if (cappBuild) + if (!cappBuild) + return undefined; + + cappBuild = FILE.canonical(cappBuild); + + if (FILE.isDirectory(cappBuild)) { - for (var i = 0; i < BuildTypes.length; ++i) + var result = null; + + for (var i = 0; i < BuildTypes.length && !result; ++i) { - var path = FILE.join(cappBuild, BuildTypes[i], "AppKit", "Info.plist"); + var findPath = FILE.join(cappBuild, BuildTypes[i], path); - themeName = themeNameFromPropertyList(path); - - if (themeName) - break; + if ((isDirectory && FILE.isDirectory(findPath)) || (!isDirectory && FILE.exists(findPath))) + result = callback(findPath); } + + return result; } + else + return false; +} + +function findInInstalledFrameworks(path, isDirectory, callback) +{ + // NOTE: It's safe to use '/' directly in the path, we're guaranteed to be on a Mac + var frameworks = FILE.canonical(FILE.join(SYS.prefix, "packages/cappuccino/Frameworks")), + result = null, + findPath = FILE.join(frameworks, "Debug", path); + + if ((isDirectory && FILE.isDirectory(findPath)) || (!isDirectory && FILE.exists(findPath))) + result = callback(findPath); + + if (!result) + { + findPath = FILE.join(frameworks, path); + + if ((isDirectory && FILE.isDirectory(findPath)) || (!isDirectory && FILE.exists(findPath))) + result = callback(findPath); + } + + return result; +} + +function getAppKitDefaultThemeName() +{ + var callback = function(path) { return themeNameFromPropertyList(path); }, + themeName = findInCappBuild("AppKit/Info.plist", false, callback); + + if (!themeName) + themeName = findInInstalledFrameworks("AppKit/Info.plist", false, callback); return themeName || DefaultTheme; } @@ -512,25 +551,12 @@ function loadTheme(themeName, themeDir) if (!themeDir) { - // Try in $CAPP_BUILD - cappBuild = FILE.canonical(SYS.env["CAPP_BUILD"]); + var returnPath = function(path) { return path; }; - if (!cappBuild) - fail("$CAPP_BUILD is not set, exiting."); + themePath = findInCappBuild(blendName, true, returnPath); - if (!FILE.isDirectory(cappBuild)) - fail("$CAPP_BUILD does not exist: " + cappBuild) - - for (var i = 0; i < BuildTypes.length; ++i) - { - var path = FILE.join(cappBuild, BuildTypes[i], blendName); - - if (FILE.isDirectory(path)) - { - themePath = path; - break; - } - } + if (!themePath) + themePath = findInInstalledFrameworks("AppKit/Resources/" + blendName, true, returnPath); // Last resort, try the cwd if (!themePath) @@ -543,7 +569,7 @@ function loadTheme(themeName, themeDir) } if (!themePath) - fail("Cannot find the theme \"" + themeName + "\""); + fail('Cannot find the theme "' + themeName + '"'); return readTheme(themeName, themePath); } From 96e3c4db68948b7f70dc22f9a1c614d978781505 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Thu, 14 Apr 2011 08:26:16 -0700 Subject: [PATCH 04/19] Store type info for ivars when proper flags are set. Reviewed by me. --- Objective-J/Preprocessor.js | 15 +++++++++++++-- Tools/Jakefile | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Objective-J/Preprocessor.js b/Objective-J/Preprocessor.js index 75ee38697..88dfda08e 100644 --- a/Objective-J/Preprocessor.js +++ b/Objective-J/Preprocessor.js @@ -448,7 +448,8 @@ Preprocessor.prototype.implementation = function(tokens, /*StringBuffer*/ aStrin ivar_count = 0, declaration = [], attributes, - accessors = {}; + accessors = {}, + types = []; while((token = tokens.skip_whitespace()) && token != TOKEN_CLOSE_BRACE) { @@ -457,8 +458,11 @@ Preprocessor.prototype.implementation = function(tokens, /*StringBuffer*/ aStrin token = tokens.next(); if (token === TOKEN_ACCESSORS) attributes = this.accessors(tokens); + else if (token !== TOKEN_OUTLET) throw new SyntaxError(this.error_message("*** Unexpected '@' token in ivar declaration ('@"+token+"').")); + else + types.push("@" + token); } else if (token == TOKEN_SEMICOLON) { @@ -469,10 +473,14 @@ Preprocessor.prototype.implementation = function(tokens, /*StringBuffer*/ aStrin var name = declaration[declaration.length - 1]; - CONCAT(buffer, "new objj_ivar(\"" + name + "\")"); + if (this._flags & Preprocessor.Flags.IncludeTypeSignatures) + CONCAT(buffer, "new objj_ivar(\"" + name + "\", \"" + types.slice(0, types.length - 1). join(" ") + "\")"); + else + CONCAT(buffer, "new objj_ivar(\"" + name + "\")"); ivar_names[name] = 1; declaration = []; + types = []; if (attributes) { @@ -481,7 +489,10 @@ Preprocessor.prototype.implementation = function(tokens, /*StringBuffer*/ aStrin } } else + { declaration.push(token); + types.push(token); + } } // If we have objects in our declaration, the user forgot a ';'. diff --git a/Tools/Jakefile b/Tools/Jakefile index e468d8c69..e5f10f1c4 100644 --- a/Tools/Jakefile +++ b/Tools/Jakefile @@ -2,6 +2,6 @@ require("../common.jake"); // nib2cib uses fontinfo and capp uses nib2cib -subtasks(["fontinfo", "nib2cib", "capp", "NativeHost"], ["build"/*, "clean", "clobber"*/]); +subtasks(["fontinfo", "nib2cib", "capp", "NativeHost", "xcodecapp"], ["build"/*, "clean", "clobber"*/]); subtasks(["fontinfo"], ["clean", "clobber"]); From 7099acde2ffd84807b3010d7ea5be3dd7483795c Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Thu, 14 Apr 2011 09:47:54 -0700 Subject: [PATCH 05/19] First pass at Xcode 4 support. Reviewed by me. --- Tools/xcodecapp/Jakefile | 42 ++ Tools/xcodecapp/Resources/FIXME_parser.j | 456 ++++++++++++++++++ .../xCodeSupport.xcodeproj/project.pbxproj | 354 ++++++++++++++ Tools/xcodecapp/XCProject.j | 151 ++++++ Tools/xcodecapp/XCResourceMonitor.j | 61 +++ Tools/xcodecapp/main.j | 15 + 6 files changed, 1079 insertions(+) create mode 100644 Tools/xcodecapp/Jakefile create mode 100644 Tools/xcodecapp/Resources/FIXME_parser.j create mode 100644 Tools/xcodecapp/Resources/xCodeSupport.xcodeproj/project.pbxproj create mode 100644 Tools/xcodecapp/XCProject.j create mode 100644 Tools/xcodecapp/XCResourceMonitor.j create mode 100644 Tools/xcodecapp/main.j diff --git a/Tools/xcodecapp/Jakefile b/Tools/xcodecapp/Jakefile new file mode 100644 index 000000000..b58c82065 --- /dev/null +++ b/Tools/xcodecapp/Jakefile @@ -0,0 +1,42 @@ + +require ("../../common.jake"); + +var app = require("objective-j/jake").app, + BundleTask = require("objective-j/jake").BundleTask, + FILE = require("file"), + OS = require("os"), + stream = require("narwhal/term").stream; + +app ("xcodecapp", function(xcodecappTask) +{ + xcodecappTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "xcodecapp.build", $CONFIGURATION)) + xcodecappTask.setBuildPath($BUILD_CJS_CAPPUCCINO_LIB); + + xcodecappTask.setSummary("xCode 4 Integration for Cappuccino projects"); + xcodecappTask.setIdentifier("org.cappuccino.xcodecapp"); + xcodecappTask.setLicense(BundleTask.License.LGPL_v2_1); + xcodecappTask.setVersion(getCappuccinoVersion()); + xcodecappTask.setSources(new FileList("*.j")); + xcodecappTask.setResources(new FileList("Resources/*")); + xcodecappTask.setIncludesNibsAndXibs(true); + xcodecappTask.setEnvironments(require("objective-j/jake/environment").CommonJS); + xcodecappTask.setFlattensSources(true); + xcodecappTask.setSpritesResources(false); + + if ($CONFIGURATION === "Release") + xcodecappTask.setCompilerFlags("-O"); + else + xcodecappTask.setCompilerFlags("-DDEBUG -g"); +}); + +$BUILD_CJS_XCODECAPP = FILE.join($BUILD_CJS_CAPPUCCINO_BIN, "xcodecapp"); + +// executable in environment directory +filedir($BUILD_CJS_XCODECAPP, ["xcodecapp"], function() +{ + make_objj_executable($BUILD_CJS_XCODECAPP); +}); + +task ("build", ["xcodecapp", $BUILD_CJS_XCODECAPP]); + +CLOBBER.include($BUILD_CJS_CAPPUCCINO_BIN); diff --git a/Tools/xcodecapp/Resources/FIXME_parser.j b/Tools/xcodecapp/Resources/FIXME_parser.j new file mode 100644 index 000000000..a5f5e6eb6 --- /dev/null +++ b/Tools/xcodecapp/Resources/FIXME_parser.j @@ -0,0 +1,456 @@ + +@import + +var FILE = require("file"); + +function main(args) +{ + var fileURL = new CFURL(args[1]), + sourcesURL = new CFURL(args[2]), + classes = [], + registerClassPair = objj_registerClassPair; + + + var source = FILE.read(fileURL, { charset: "UTF-8" }), + flags = ObjectiveJ.Preprocessor.Flags.IncludeDebugSymbols | + ObjectiveJ.Preprocessor.Flags.IncludeTypeSignatures; + + source = ObjectiveJ.preprocess(source, fileURL, flags).code(); + + source = source.replace(/objj_allocateClassPair\([a-zA-Z_$](\w|$)*/g, function() + { + return "objj_allocateClassPair(CPObject"; + }); + + objj_registerClassPair = function(aClass) + { + registerClassPair(aClass); + classes.push(aClass); + } + + objj_executeFile = function() + { + } + + eval(source); + + var ObjectiveCSource = ""; + + classes.forEach(function(aClass) + { + var outlets = []; + + class_copyIvarList(aClass).forEach(function(anIvar) + { + var types = ivar_getTypeEncoding(anIvar).split(" "); + + if (types.indexOf("IBOutlet") !== CPNotFound || types.indexOf("@outlet") !== CPNotFound) + { + types.forEach(function(aType, anIndex) + { + if (aType === "@outlet") + types[anIndex] = "IBOutlet"; + else + types[anIndex] = NSCompatibleClassName(aType, YES); + }); + + outlets.push(" " + types.join(" ") + " " + ivar_getName(anIvar) + ";"); + } + }); + + var actions = []; + + class_copyMethodList(aClass).forEach(function(aMethod) + { + var types = aMethod.types, + type = types[0]; + + if (type === "IBAction" || type === "@action") + actions.push("- (IBAction)" + method_getName(aMethod) + "(" + NSCompatibleClassName(types[1] || "id", YES)+ ")aSender;"); + }); + + ObjectiveCSource += + "@interface " + class_getName(aClass) + " : " + + NSCompatibleClassName(class_getName(class_getSuperclass(aClass))) + + "\n{\n" + + outlets.join("\n") + + "\n}\n" + + actions.join("\n") + + "\n@end"; + }); + + if (ObjectiveCSource.length) + FILE.write(FILE.join(sourcesURL, xCodeSupportShadowURL(fileURL)), ObjectiveCSource, { charset:"UTF-8" }); +} + +function xCodeSupportShadowURL(aURL) +{ + var flattenedPath = (aURL + "").replace(/\//g, "_"), + extension = FILE.extension(flattenedPath); + + return new CFURL(flattenedPath.substr(0, flattenedPath.length - extension.length) + ".h"); +} + +function NSCompatibleClassName(aClassName, asPointer) +{ + if (aClassName === "var") + return "id"; + + var suffix = aClassName.substr(0, 2); + + if (suffix !== "CP") + return aClassName; + + var NSClassName = "NS" + aClassName.substr(2); + + if (NSClasses[NSClassName]) + return NSClassName + (asPointer ? "*" : ""); + + return aClassName + (asPointer ? "*" : ""); +} + +var NSClasses = { + "NSAffineTransform" : YES, + "NSAppleEventDescriptor" : YES, + "NSAppleEventManager" : YES, + "NSAppleScript" : YES, + "NSArchiver" : YES, + "NSArray" : YES, + "NSAssertionHandler" : YES, + "NSAttributedString" : YES, + "NSAutoreleasePool" : YES, + "NSBlockOperation" : YES, + "NSBundle" : YES, + "NSCache" : YES, + "NSCachedURLResponse" : YES, + "NSCalendar" : YES, + "NSCharacterSet" : YES, + "NSClassDescription" : YES, + "NSCloneCommand" : YES, + "NSCloseCommand" : YES, + "NSCoder" : YES, + "NSComparisonPredicate" : YES, + "NSCompoundPredicate" : YES, + "NSCondition" : YES, + "NSConditionLock" : YES, + "NSConnection" : YES, + "NSCountCommand" : YES, + "NSCountedSet" : YES, + "NSCreateCommand" : YES, + "NSData" : YES, + "NSDate" : YES, + "NSDateComponents" : YES, + "NSDateFormatter" : YES, + "NSDecimalNumber" : YES, + "NSDecimalNumberHandler" : YES, + "NSDeleteCommand" : YES, + "NSDeserializer" : YES, + "NSDictionary" : YES, + "NSDirectoryEnumerator" : YES, + "NSDistantObject" : YES, + "NSDistantObjectRequest" : YES, + "NSDistributedLock" : YES, + "NSDistributedNotificationCenter" : YES, + "NSEnumerator" : YES, + "NSError" : YES, + "NSException" : YES, + "NSExistsCommand" : YES, + "NSExpression" : YES, + "NSFileHandle" : YES, + "NSFileManager" : YES, + "NSFileWrapper" : YES, + "NSFormatter" : YES, + "NSGarbageCollector" : YES, + "NSGetCommand" : YES, + "NSHashTable" : YES, + "NSHost" : YES, + "NSHTTPCookie" : YES, + "NSHTTPCookieStorage" : YES, + "NSHTTPURLResponse" : YES, + "NSIndexPath" : YES, + "NSIndexSet" : YES, + "NSIndexSpecifier" : YES, + "NSInputStream" : YES, + "NSInvocation" : YES, + "NSInvocationOperation" : YES, + "NSKeyedArchiver" : YES, + "NSKeyedUnarchiver" : YES, + "NSLocale" : YES, + "NSLock" : YES, + "NSLogicalTest" : YES, + "NSMachBootstrapServer" : YES, + "NSMachPort" : YES, + "NSMapTable" : YES, + "NSMessagePort" : YES, + "NSMessagePortNameServer" : YES, + "NSMetadataItem" : YES, + "NSMetadataQuery" : YES, + "NSMetadataQueryAttributeValueTuple" : YES, + "NSMetadataQueryResultGroup" : YES, + "NSMethodSignature" : YES, + "NSMiddleSpecifier" : YES, + "NSMoveCommand" : YES, + "NSMutableArray" : YES, + "NSMutableAttributedString" : YES, + "NSMutableCharacterSet" : YES, + "NSMutableData" : YES, + "NSMutableDictionary" : YES, + "NSMutableIndexSet" : YES, + "NSMutableSet" : YES, + "NSMutableString" : YES, + "NSMutableURLRequest" : YES, + "NSNameSpecifier" : YES, + "NSNetService" : YES, + "NSNetServiceBrowser" : YES, + "NSNotification" : YES, + "NSNotificationCenter" : YES, + "NSNotificationQueue" : YES, + "NSNull" : YES, + "NSNumber" : YES, + "NSNumberFormatter" : YES, + "NSObject" : YES, + "NSOperation" : YES, + "NSOperationQueue" : YES, + "NSOrthography" : YES, + "NSOutputStream" : YES, + "NSPipe" : YES, + "NSPointerArray" : YES, + "NSPointerFunctions" : YES, + "NSPort" : YES, + "NSPortCoder" : YES, + "NSPortMessage" : YES, + "NSPortNameServer" : YES, + "NSPositionalSpecifier" : YES, + "NSPredicate" : YES, + "NSProcessInfo" : YES, + "NSPropertyListSerialization" : YES, + "NSPropertySpecifier" : YES, + "NSProtocolChecker" : YES, + "NSProxy" : YES, + "NSPurgeableData" : YES, + "NSQuitCommand" : YES, + "NSRandomSpecifier" : YES, + "NSRangeSpecifier" : YES, + "NSRecursiveLock" : YES, + "NSRelativeSpecifier" : YES, + "NSRunLoop" : YES, + "NSScanner" : YES, + "NSScriptClassDescription" : YES, + "NSScriptCoercionHandler" : YES, + "NSScriptCommand" : YES, + "NSScriptCommandDescription" : YES, + "NSScriptExecutionContext" : YES, + "NSScriptObjectSpecifier" : YES, + "NSScriptSuiteRegistry" : YES, + "NSScriptWhoseTest" : YES, + "NSSerializer" : YES, + "NSSet" : YES, + "NSSetCommand" : YES, + "NSSocketPort" : YES, + "NSSocketPortNameServer" : YES, + "NSSortDescriptor" : YES, + "NSSpecifierTest" : YES, + "NSSpellServer" : YES, + "NSStream" : YES, + "NSString" : YES, + "NSTask" : YES, + "NSTextCheckingResult" : YES, + "NSThread" : YES, + "NSTimer" : YES, + "NSTimeZone" : YES, + "NSUnarchiver" : YES, + "NSUndoManager" : YES, + "NSUniqueIDSpecifier" : YES, + "NSURL" : YES, + "NSURLAuthenticationChallenge" : YES, + "NSURLCache" : YES, + "NSURLConnection" : YES, + "NSURLCredential" : YES, + "NSURLCredentialStorage" : YES, + "NSURLDownload" : YES, + "NSURLHandle" : YES, + "NSURLProtectionSpace" : YES, + "NSURLProtocol" : YES, + "NSURLRequest" : YES, + "NSURLResponse" : YES, + "NSUserDefaults" : YES, + "NSValue" : YES, + "NSValueTransformer" : YES, + "NSWhoseSpecifier" : YES, + "NSXMLDocument" : YES, + "NSXMLDTD" : YES, + "NSXMLDTDNode" : YES, + "NSXMLElement" : YES, + "NSXMLNode" : YES, + "NSXMLParser" : YES, + "NSActionCell" : YES, + "NSAffineTransform Additions" : YES, + "NSAlert" : YES, + "NSAnimation" : YES, + "NSAnimationContext" : YES, + "NSAppleScript Additions" : YES, + "NSApplication" : YES, + "NSArrayController" : YES, + "NSATSTypesetter" : YES, + "NSAttributedString Application Kit Additions" : YES, + "NSBezierPath" : YES, + "NSBitmapImageRep" : YES, + "NSBox" : YES, + "NSBrowser" : YES, + "NSBrowserCell" : YES, + "NSBundle Additions" : YES, + "NSButton" : YES, + "NSButtonCell" : YES, + "NSCachedImageRep" : YES, + "NSCell" : YES, + "NSCIImageRep" : YES, + "NSClipView" : YES, + "NSCoder Application Kit Additions" : YES, + "NSCollectionView" : YES, + "NSCollectionViewItem" : YES, + "NSColor" : YES, + "NSColorList" : YES, + "NSColorPanel" : YES, + "NSColorPicker" : YES, + "NSColorSpace" : YES, + "NSColorWell" : YES, + "NSComboBox" : YES, + "NSComboBoxCell" : YES, + "NSControl" : YES, + "NSController" : YES, + "NSCursor" : YES, + "NSCustomImageRep" : YES, + "NSDatePicker" : YES, + "NSDatePickerCell" : YES, + "NSDictionaryController" : YES, + "NSDockTile" : YES, + "NSDocument" : YES, + "NSDocumentController" : YES, + "NSDrawer" : YES, + "NSEPSImageRep" : YES, + "NSEvent" : YES, + "NSFileWrapper" : YES, + "NSFont" : YES, + "NSFontDescriptor" : YES, + "NSFontManager" : YES, + "NSFontPanel" : YES, + "NSForm" : YES, + "NSFormCell" : YES, + "NSGlyphGenerator" : YES, + "NSGlyphInfo" : YES, + "NSGradient" : YES, + "NSGraphicsContext" : YES, + "NSHelpManager" : YES, + "NSImage" : YES, + "NSImageCell" : YES, + "NSImageRep" : YES, + "NSImageView" : YES, + "NSLayoutManager" : YES, + "NSLevelIndicator" : YES, + "NSLevelIndicatorCell" : YES, + "NSMatrix" : YES, + "NSMenu" : YES, + "NSMenuItem" : YES, + "NSMenuItemCell" : YES, + "NSMenuView" : YES, + "NSMutableAttributedString Additions" : YES, + "NSMutableParagraphStyle" : YES, + "NSNib" : YES, + "NSNibConnector" : YES, + "NSNibControlConnector" : YES, + "NSNibOutletConnector" : YES, + "NSObjectController" : YES, + "NSOpenGLContext" : YES, + "NSOpenGLLayer" : YES, + "NSOpenGLPixelBuffer" : YES, + "NSOpenGLPixelFormat" : YES, + "NSOpenGLView" : YES, + "NSOpenPanel" : YES, + "NSOutlineView" : YES, + "NSPageLayout" : YES, + "NSPanel" : YES, + "NSParagraphStyle" : YES, + "NSPasteboard" : YES, + "NSPasteboardItem" : YES, + "NSPathCell" : YES, + "NSPathComponentCell" : YES, + "NSPathControl" : YES, + "NSPDFImageRep" : YES, + "NSPersistentDocument" : YES, + "NSPICTImageRep" : YES, + "NSPopUpButton" : YES, + "NSPopUpButtonCell" : YES, + "NSPredicateEditor" : YES, + "NSPredicateEditorRowTemplate" : YES, + "NSPrinter" : YES, + "NSPrintInfo" : YES, + "NSPrintOperation" : YES, + "NSPrintPanel" : YES, + "NSProgressIndicator" : YES, + "NSResponder" : YES, + "NSRuleEditor" : YES, + "NSRulerMarker" : YES, + "NSRulerView" : YES, + "NSRunningApplication" : YES, + "NSSavePanel" : YES, + "NSScreen" : YES, + "NSScroller" : YES, + "NSScrollView" : YES, + "NSSearchField" : YES, + "NSSearchFieldCell" : YES, + "NSSecureTextField" : YES, + "NSSecureTextFieldCell" : YES, + "NSSegmentedCell" : YES, + "NSSegmentedControl" : YES, + "NSShadow" : YES, + "NSSlider" : YES, + "NSSliderCell" : YES, + "NSSound" : YES, + "NSSpeechRecognizer" : YES, + "NSSpeechSynthesizer" : YES, + "NSSpellChecker" : YES, + "NSSplitView" : YES, + "NSStatusBar" : YES, + "NSStatusItem" : YES, + "NSStepper" : YES, + "NSStepperCell" : YES, + "NSString Application Kit Additions" : YES, + "NSTableColumn" : YES, + "NSTableHeaderCell" : YES, + "NSTableHeaderView" : YES, + "NSTableView" : YES, + "NSTabView" : YES, + "NSTabViewItem" : YES, + "NSText" : YES, + "NSTextAttachment" : YES, + "NSTextAttachmentCell" : YES, + "NSTextBlock" : YES, + "NSTextContainer" : YES, + "NSTextField" : YES, + "NSTextFieldCell" : YES, + "NSTextInputContext" : YES, + "NSTextList" : YES, + "NSTextStorage" : YES, + "NSTextTab" : YES, + "NSTextTable" : YES, + "NSTextTableBlock" : YES, + "NSTextView" : YES, + "NSTokenField" : YES, + "NSTokenFieldCell" : YES, + "NSToolbar" : YES, + "NSToolbarItem" : YES, + "NSToolbarItemGroup" : YES, + "NSTouch" : YES, + "NSTrackingArea" : YES, + "NSTreeController" : YES, + "NSTreeNode" : YES, + "NSTypesetter" : YES, + "NSURL Additions" : YES, + "NSUserDefaultsController" : YES, + "NSView" : YES, + "NSViewAnimation" : YES, + "NSViewController" : YES, + "NSWindow" : YES, + "NSWindowController" : YES, + "NSWorkspace" : YES + }; \ No newline at end of file diff --git a/Tools/xcodecapp/Resources/xCodeSupport.xcodeproj/project.pbxproj b/Tools/xcodecapp/Resources/xCodeSupport.xcodeproj/project.pbxproj new file mode 100644 index 000000000..991add479 --- /dev/null +++ b/Tools/xcodecapp/Resources/xCodeSupport.xcodeproj/project.pbxproj @@ -0,0 +1,354 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 9EEC4498135749D200615446 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9EEC4497135749D200615446 /* Cocoa.framework */; }; + 9EEC44B5135749D300615446 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9EEC4497135749D200615446 /* Cocoa.framework */; }; + 9EEC44CC13574A0B00615446 /* ${CappuccinoProjectName} in Resources */ = {isa = PBXBuildFile; fileRef = 9EEC44CB13574A0B00615446 /* ${CappuccinoProjectName} */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 9EEC44B6135749D300615446 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 9EEC448A135749D200615446 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 9EEC4492135749D200615446; + remoteInfo = Another; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 9EEC4493135749D200615446 /* Another.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Another.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 9EEC4497135749D200615446 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + 9EEC449A135749D300615446 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; + 9EEC449B135749D300615446 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; + 9EEC449C135749D300615446 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 9EEC44B4135749D300615446 /* AnotherTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AnotherTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; + 9EEC44CB13574A0B00615446 /* ${CappuccinoProjectName} */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ${CappuccinoProjectName}; path = ${CappuccinoProjectRelativePath}; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 9EEC4490135749D200615446 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9EEC4498135749D200615446 /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 9EEC44B0135749D300615446 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9EEC44B5135749D300615446 /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9EEC4488135749D200615446 = { + isa = PBXGroup; + children = ( + 9EEC44CB13574A0B00615446 /* ${CappuccinoProjectName} */, + 9EEC4496135749D200615446 /* Frameworks */, + 9EEC4494135749D200615446 /* Products */, + ); + sourceTree = ""; + }; + 9EEC4494135749D200615446 /* Products */ = { + isa = PBXGroup; + children = ( + 9EEC4493135749D200615446 /* Another.app */, + 9EEC44B4135749D300615446 /* AnotherTests.octest */, + ); + name = Products; + sourceTree = ""; + }; + 9EEC4496135749D200615446 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 9EEC4497135749D200615446 /* Cocoa.framework */, + 9EEC4499135749D300615446 /* Other Frameworks */, + ); + name = Frameworks; + sourceTree = ""; + }; + 9EEC4499135749D300615446 /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 9EEC449A135749D300615446 /* AppKit.framework */, + 9EEC449B135749D300615446 /* CoreData.framework */, + 9EEC449C135749D300615446 /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 9EEC4492135749D200615446 /* Another */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9EEC44C5135749D300615446 /* Build configuration list for PBXNativeTarget "Another" */; + buildPhases = ( + 9EEC448F135749D200615446 /* Sources */, + 9EEC4490135749D200615446 /* Frameworks */, + 9EEC4491135749D200615446 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Another; + productName = Another; + productReference = 9EEC4493135749D200615446 /* Another.app */; + productType = "com.apple.product-type.application"; + }; + 9EEC44B3135749D300615446 /* AnotherTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9EEC44C8135749D300615446 /* Build configuration list for PBXNativeTarget "AnotherTests" */; + buildPhases = ( + 9EEC44AF135749D300615446 /* Sources */, + 9EEC44B0135749D300615446 /* Frameworks */, + 9EEC44B1135749D300615446 /* Resources */, + 9EEC44B2135749D300615446 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 9EEC44B7135749D300615446 /* PBXTargetDependency */, + ); + name = AnotherTests; + productName = AnotherTests; + productReference = 9EEC44B4135749D300615446 /* AnotherTests.octest */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 9EEC448A135749D200615446 /* Project object */ = { + isa = PBXProject; + attributes = { + ORGANIZATIONNAME = "280 North, Inc."; + }; + buildConfigurationList = 9EEC448D135749D200615446 /* Build configuration list for PBXProject "Another" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 9EEC4488135749D200615446; + productRefGroup = 9EEC4494135749D200615446 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 9EEC4492135749D200615446 /* Another */, + 9EEC44B3135749D300615446 /* AnotherTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 9EEC4491135749D200615446 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9EEC44CC13574A0B00615446 /* ${CappuccinoProjectName} in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 9EEC44B1135749D300615446 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 9EEC44B2135749D300615446 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 9EEC448F135749D200615446 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 9EEC44AF135749D300615446 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 9EEC44B7135749D300615446 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 9EEC4492135749D200615446 /* Another */; + targetProxy = 9EEC44B6135749D300615446 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 9EEC44C3135749D300615446 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = DEBUG; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.6; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 9EEC44C4135749D300615446 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.6; + SDKROOT = macosx; + }; + name = Release; + }; + 9EEC44C6135749D300615446 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Another/Another-Prefix.pch"; + INFOPLIST_FILE = "Another/Another-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 9EEC44C7135749D300615446 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Another/Another-Prefix.pch"; + INFOPLIST_FILE = "Another/Another-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + 9EEC44C9135749D300615446 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/Another.app/Contents/MacOS/Another"; + COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "AnotherTests/AnotherTests-Prefix.pch"; + INFOPLIST_FILE = "AnotherTests/AnotherTests-Info.plist"; + OTHER_LDFLAGS = ( + "-framework", + SenTestingKit, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = octest; + }; + name = Debug; + }; + 9EEC44CA135749D300615446 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/Another.app/Contents/MacOS/Another"; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "AnotherTests/AnotherTests-Prefix.pch"; + INFOPLIST_FILE = "AnotherTests/AnotherTests-Info.plist"; + OTHER_LDFLAGS = ( + "-framework", + SenTestingKit, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = octest; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 9EEC448D135749D200615446 /* Build configuration list for PBXProject "Another" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9EEC44C3135749D300615446 /* Debug */, + 9EEC44C4135749D300615446 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9EEC44C5135749D300615446 /* Build configuration list for PBXNativeTarget "Another" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9EEC44C6135749D300615446 /* Debug */, + 9EEC44C7135749D300615446 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; + 9EEC44C8135749D300615446 /* Build configuration list for PBXNativeTarget "AnotherTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9EEC44C9135749D300615446 /* Debug */, + 9EEC44CA135749D300615446 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 9EEC448A135749D200615446 /* Project object */; +} diff --git a/Tools/xcodecapp/XCProject.j b/Tools/xcodecapp/XCProject.j new file mode 100644 index 000000000..521139074 --- /dev/null +++ b/Tools/xcodecapp/XCProject.j @@ -0,0 +1,151 @@ + +@import +@import +@import + +@import "XCResourceMonitor.j" + +var FILE = require("file"), + OS = require("os"); + + +@implementation XCProject : CPObject +{ + CFURL m_URL; + + XCResourceMonitor m_sourceResourceMonitor; + XCResourceMonitor m_nibResourceMonitor; + + CFURL m_xCodeProjectURL; + CFURL m_xCodeProjectFileURL; + CFURL m_xCodeSupportSourcesURL; +} + +- (id)initWithPath:(CPString)aPath +{ + self = [super init]; + + if (self) + { + m_URL = new CFURL(aPath); + + [self prepare_xCodeProject]; + + m_sourceResourceMonitor = [[XCResourceCollection alloc] initWithPattern:FILE.join(m_URL, "/**/*.j")]; + m_nibResourceMonitor = [[XCResourceCollection alloc] initWithPattern:FILE.join(m_URL, "/**/*.[nx]ib")]; + + [self launch]; + } + + return self; +} + +- (CPString)projectName +{ + return m_URL.lastPathComponent(); +} + +- (CFURL)xCodeProjectTemplateURL +{ + var CAPP_HOME = require("narwhal/packages").catalog["cappuccino"].directory; + + return new CFURL(FILE.join(CAPP_HOME, "lib", "xcodecapp", "Resources", "xCodeSupport.xcodeproj")); +} + +- (CFURL)xCodeProjectParserURL +{ + var CAPP_HOME = require("narwhal/packages").catalog["cappuccino"].directory; + + return new CFURL(FILE.join(CAPP_HOME, "lib", "xcodecapp", "Resources", "FIXME_parser.j")); +} + +- (void)launch +{ + OS.system("open " + m_xCodeProjectFileURL); +} + +- (void)prepare_xCodeProject +{ + m_xCodeProjectURL = new CFURL(".xCodeSupport", m_URL.asDirectoryPathURL()); + + if (FILE.exists(m_xCodeProjectURL)) + FILE.rmtree(m_xCodeProjectURL); + + FILE.mkdir(m_xCodeProjectURL); + + var projectName = [self projectName], + xCodeProjectTemplateURL = [self xCodeProjectTemplateURL]; + + m_xCodeProjectFileURL = new CFURL(projectName + ".xcodeproj", m_xCodeProjectURL.asDirectoryPathURL()); + + FILE.copyTree(xCodeProjectTemplateURL, m_xCodeProjectFileURL.absoluteURL()); + + var pbxprojURL = new CFURL("project.pbxproj", m_xCodeProjectFileURL.asDirectoryPathURL()), + pbxproj = FILE.read(pbxprojURL, { charset:"UTF-8" }); + + pbxproj = pbxproj.replace(/\$\{CappuccinoProjectName\}/g, projectName); + pbxproj = pbxproj.replace(/\$\{CappuccinoProjectRelativePath\}/g, FILE.join("..", "..", projectName)); + + FILE.write(pbxprojURL, pbxproj, { charset:"UTF-8" }); + + m_xCodeSupportSourcesURL = new CFURL("Sources", m_xCodeProjectURL.asDirectoryPathURL()); + + FILE.mkdir(m_xCodeSupportSourcesURL); +} + +- (void)update +{ + [self updateSourceFiles]; + [self updateNibFiles]; +} + +- (void)updateSourceFiles +{ + // Require the new parser for this. + [m_sourceResourceMonitor update]; + + [m_sourceResourceMonitor addedFilePaths].forEach(function(aFilePath) + { + print("Added " + aFilePath); + OS.system("objj " + [self xCodeProjectParserURL] + " " + aFilePath + " " + m_xCodeSupportSourcesURL); + }); + + [m_sourceResourceMonitor editedFilePaths].forEach(function(aFilePath) + { + print("Edited " + aFilePath); + OS.system("objj " + [self xCodeProjectParserURL] + " " + aFilePath + " " + m_xCodeSupportSourcesURL); + }); + + [m_sourceResourceMonitor removedFilePaths].forEach(function(aFilePath) + { + // delete? + print("Removed " + aFilePath); + // OS.system("nib2cib " + aFilePath); + }); +} + +- (void)updateNibFiles +{ + [m_nibResourceMonitor update]; + + [m_nibResourceMonitor addedFilePaths].forEach(function(aFilePath) + { + print("Added " + aFilePath); + OS.system("nib2cib " + aFilePath); + }); + + [m_nibResourceMonitor editedFilePaths].forEach(function(aFilePath) + { + print("Edited " + aFilePath); + OS.system("nib2cib " + aFilePath); + }); + + [m_nibResourceMonitor removedFilePaths].forEach(function(aFilePath) + { + // delete? + print("Removed " + aFilePath); + // OS.system("nib2cib " + aFilePath); + }); +} + +@end diff --git a/Tools/xcodecapp/XCResourceMonitor.j b/Tools/xcodecapp/XCResourceMonitor.j new file mode 100644 index 000000000..58ec88188 --- /dev/null +++ b/Tools/xcodecapp/XCResourceMonitor.j @@ -0,0 +1,61 @@ + +@import + +var FILE = require("file"), + FileList = require("jake").FileList; + + +@implementation XCResourceCollection : CPObject +{ + CPString m_pattern; + CPDictionary m_mtimesForFilePaths; + + CPMutableArray m_addedFilePaths @accessors(readonly, getter=addedFilePaths); + CPMutableArray m_removedFilePaths @accessors(readonly, getter=removedFilePaths); + CPMutableArray m_editedFilePaths @accessors(readonly, getter=editedFilePaths); +} + +- (id)initWithPattern:(CPString)aPattern +{ + self = [super init]; + + if (self) + m_pattern = aPattern; + + return self; +} + +- (void)update +{ + m_addedFilePaths = []; + m_removedFilePaths = []; + m_editedFilePaths = []; + + var paths = new FileList(m_pattern), + mtimesForFilePaths = [CPMutableDictionary new]; + + paths.forEach(function(aPath) + { + var time = [m_mtimesForFilePaths objectForKey:aPath], + current = FILE.mtime(aPath); + + if (time === nil) + [m_addedFilePaths addObject:aPath]; + + else if (current > time) + [m_editedFilePaths addObject:aPath]; + + [mtimesForFilePaths setObject:current forKey:aPath]; + }); + + var filePath = nil, + filePaths = [m_mtimesForFilePaths keyEnumerator]; + + while (filePath = [filePath nextObject]) + if (![mtimesForFilePaths objectForKey:filePath] === nil) + [m_removedFilePaths addObject:filePath]; + + m_mtimesForFilePaths = mtimesForFilePaths; +} + +@end diff --git a/Tools/xcodecapp/main.j b/Tools/xcodecapp/main.j new file mode 100644 index 000000000..37afc6017 --- /dev/null +++ b/Tools/xcodecapp/main.j @@ -0,0 +1,15 @@ + +@import "XCProject.j" + +var FILE = require("file"), + OS = require("os"); + +var project = [[XCProject alloc] initWithPath:FILE.cwd()]; + +while (YES) +{ + [project update]; + + OS.sleep(1); +} + From e6acc7a7d8aaa7d88ba524edb493359c02cf6623 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Thu, 14 Apr 2011 10:27:24 -0700 Subject: [PATCH 06/19] Minor fix. Reviewed by me. --- Tools/xcodecapp/Resources/FIXME_parser.j | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tools/xcodecapp/Resources/FIXME_parser.j b/Tools/xcodecapp/Resources/FIXME_parser.j index a5f5e6eb6..abc04f409 100644 --- a/Tools/xcodecapp/Resources/FIXME_parser.j +++ b/Tools/xcodecapp/Resources/FIXME_parser.j @@ -39,7 +39,7 @@ function main(args) classes.forEach(function(aClass) { var outlets = []; - + class_copyIvarList(aClass).forEach(function(anIvar) { var types = ivar_getTypeEncoding(anIvar).split(" "); @@ -69,10 +69,10 @@ function main(args) actions.push("- (IBAction)" + method_getName(aMethod) + "(" + NSCompatibleClassName(types[1] || "id", YES)+ ")aSender;"); }); - ObjectiveCSource += - "@interface " + class_getName(aClass) + " : " + - NSCompatibleClassName(class_getName(class_getSuperclass(aClass))) + - "\n{\n" + + ObjectiveCSource += + "\n@interface " + class_getName(aClass) + " : " + + NSCompatibleClassName(class_getName(class_getSuperclass(aClass))) + + "\n{\n" + outlets.join("\n") + "\n}\n" + actions.join("\n") + From 7d3768e13dd5d57f4a8cfd399af38043054ca67a Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Thu, 14 Apr 2011 13:57:24 -0700 Subject: [PATCH 07/19] Fix superclasses in class generation. Reviewed by me. --- Tools/xcodecapp/Resources/FIXME_parser.j | 34 +++++++++++++++++------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/Tools/xcodecapp/Resources/FIXME_parser.j b/Tools/xcodecapp/Resources/FIXME_parser.j index abc04f409..bc0180f04 100644 --- a/Tools/xcodecapp/Resources/FIXME_parser.j +++ b/Tools/xcodecapp/Resources/FIXME_parser.j @@ -7,23 +7,34 @@ function main(args) { var fileURL = new CFURL(args[1]), sourcesURL = new CFURL(args[2]), - classes = [], - registerClassPair = objj_registerClassPair; - - - var source = FILE.read(fileURL, { charset: "UTF-8" }), + source = FILE.read(fileURL, { charset: "UTF-8" }), flags = ObjectiveJ.Preprocessor.Flags.IncludeDebugSymbols | - ObjectiveJ.Preprocessor.Flags.IncludeTypeSignatures; + ObjectiveJ.Preprocessor.Flags.IncludeTypeSignatures, + superClasses = { }; source = ObjectiveJ.preprocess(source, fileURL, flags).code(); - source = source.replace(/objj_allocateClassPair\([a-zA-Z_$](\w|$)*/g, function() + source = source.replace(/objj_allocateClassPair\([a-zA-Z_$](\w|$)*/g, function(aString) { - return "objj_allocateClassPair(CPObject"; + var superClassName = aString.substr("objj_allocateClassPair(".length); + + return "objj_allocateClassPair(\"" + superClassName + "\", CPObject"; }); + var allocateClassPair = objj_allocateClassPair; + + objj_allocateClassPair = function(superClassName) + { + superClasses[arguments[2]] = superClassName; + return allocateClassPair(arguments[1], arguments[2]); + } + + var classes = [], + registerClassPair = objj_registerClassPair; + objj_registerClassPair = function(aClass) { + aClass.actual_super_class; registerClassPair(aClass); classes.push(aClass); } @@ -69,9 +80,12 @@ function main(args) actions.push("- (IBAction)" + method_getName(aMethod) + "(" + NSCompatibleClassName(types[1] || "id", YES)+ ")aSender;"); }); + var className = class_getName(aClass), + superClassName = superClasses[className]; + ObjectiveCSource += - "\n@interface " + class_getName(aClass) + " : " + - NSCompatibleClassName(class_getName(class_getSuperclass(aClass))) + + "\n@interface " + class_getName(aClass) + + (superClassName === "Nil" ? "" : (" : " + NSCompatibleClassName(superClassName))) + "\n{\n" + outlets.join("\n") + "\n}\n" + From 1c5d311ec22fe654718e8e8928be1f8b8e5c0a61 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Thu, 14 Apr 2011 14:35:29 -0700 Subject: [PATCH 08/19] Handle source files being deleted. Reviewed by me. --- Tools/xcodecapp/Resources/FIXME_parser.j | 12 ++---------- Tools/xcodecapp/XCProject.j | 16 ++++++++++++---- Tools/xcodecapp/XCResourceMonitor.j | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Tools/xcodecapp/Resources/FIXME_parser.j b/Tools/xcodecapp/Resources/FIXME_parser.j index bc0180f04..3b586b316 100644 --- a/Tools/xcodecapp/Resources/FIXME_parser.j +++ b/Tools/xcodecapp/Resources/FIXME_parser.j @@ -6,7 +6,7 @@ var FILE = require("file"); function main(args) { var fileURL = new CFURL(args[1]), - sourcesURL = new CFURL(args[2]), + outputURL = new CFURL(args[2]), source = FILE.read(fileURL, { charset: "UTF-8" }), flags = ObjectiveJ.Preprocessor.Flags.IncludeDebugSymbols | ObjectiveJ.Preprocessor.Flags.IncludeTypeSignatures, @@ -94,15 +94,7 @@ function main(args) }); if (ObjectiveCSource.length) - FILE.write(FILE.join(sourcesURL, xCodeSupportShadowURL(fileURL)), ObjectiveCSource, { charset:"UTF-8" }); -} - -function xCodeSupportShadowURL(aURL) -{ - var flattenedPath = (aURL + "").replace(/\//g, "_"), - extension = FILE.extension(flattenedPath); - - return new CFURL(flattenedPath.substr(0, flattenedPath.length - extension.length) + ".h"); + FILE.write(outputURL, ObjectiveCSource, { charset:"UTF-8" }); } function NSCompatibleClassName(aClassName, asPointer) diff --git a/Tools/xcodecapp/XCProject.j b/Tools/xcodecapp/XCProject.j index 521139074..316332de5 100644 --- a/Tools/xcodecapp/XCProject.j +++ b/Tools/xcodecapp/XCProject.j @@ -99,6 +99,15 @@ var FILE = require("file"), [self updateNibFiles]; } +- (CPURL)shadowURLForSourceURL:(CPURL)aSourceURL +{ + var flattenedPath = (aSourceURL + "").replace(new RegExp("\/", "g"), "_"), + extension = FILE.extension(flattenedPath), + basename = flattenedPath.substr(0, flattenedPath.length - extension.length) + ".h"; + + return new CFURL(basename, m_xCodeSupportSourcesURL.asDirectoryPathURL()); +} + - (void)updateSourceFiles { // Require the new parser for this. @@ -107,20 +116,19 @@ var FILE = require("file"), [m_sourceResourceMonitor addedFilePaths].forEach(function(aFilePath) { print("Added " + aFilePath); - OS.system("objj " + [self xCodeProjectParserURL] + " " + aFilePath + " " + m_xCodeSupportSourcesURL); + OS.system("objj " + [self xCodeProjectParserURL] + " " + aFilePath + " " + [self shadowURLForSourceURL:aFilePath]); }); [m_sourceResourceMonitor editedFilePaths].forEach(function(aFilePath) { print("Edited " + aFilePath); - OS.system("objj " + [self xCodeProjectParserURL] + " " + aFilePath + " " + m_xCodeSupportSourcesURL); + OS.system("objj " + [self xCodeProjectParserURL] + " " + aFilePath + " " + [self shadowURLForSourceURL:aFilePath]); }); [m_sourceResourceMonitor removedFilePaths].forEach(function(aFilePath) { - // delete? print("Removed " + aFilePath); - // OS.system("nib2cib " + aFilePath); + FILE.remove([self shadowURLForSourceURL:aFilePath]); }); } diff --git a/Tools/xcodecapp/XCResourceMonitor.j b/Tools/xcodecapp/XCResourceMonitor.j index 58ec88188..5de8af011 100644 --- a/Tools/xcodecapp/XCResourceMonitor.j +++ b/Tools/xcodecapp/XCResourceMonitor.j @@ -51,8 +51,8 @@ var FILE = require("file"), var filePath = nil, filePaths = [m_mtimesForFilePaths keyEnumerator]; - while (filePath = [filePath nextObject]) - if (![mtimesForFilePaths objectForKey:filePath] === nil) + while (filePath = [filePaths nextObject]) + if ([mtimesForFilePaths objectForKey:filePath] === nil) [m_removedFilePaths addObject:filePath]; m_mtimesForFilePaths = mtimesForFilePaths; From 77b5f0475d45e6b53cc43b82c6ac898637ac0d58 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Thu, 14 Apr 2011 14:47:14 -0700 Subject: [PATCH 09/19] Always convert to pointers, not just with NS classes. Reviewed by me. --- Tools/xcodecapp/Resources/FIXME_parser.j | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Tools/xcodecapp/Resources/FIXME_parser.j b/Tools/xcodecapp/Resources/FIXME_parser.j index 3b586b316..05f01f14e 100644 --- a/Tools/xcodecapp/Resources/FIXME_parser.j +++ b/Tools/xcodecapp/Resources/FIXME_parser.j @@ -99,20 +99,21 @@ function main(args) function NSCompatibleClassName(aClassName, asPointer) { - if (aClassName === "var") + if (aClassName === "var" || aClassName === "id") return "id"; - var suffix = aClassName.substr(0, 2); + var suffix = aClassName.substr(0, 2), + asterisk = asPointer ? "*" : ""; if (suffix !== "CP") - return aClassName; + return aClassName + asterisk; var NSClassName = "NS" + aClassName.substr(2); if (NSClasses[NSClassName]) - return NSClassName + (asPointer ? "*" : ""); + return NSClassName + asterisk; - return aClassName + (asPointer ? "*" : ""); + return aClassName + asterisk; } var NSClasses = { From 3b9ed4c1b57e8eb3c2131c03af8233009fd5d96f Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Thu, 14 Apr 2011 14:52:36 -0700 Subject: [PATCH 10/19] Don't make IBOutlet a pointer. Reviewed by me. --- Tools/xcodecapp/Resources/FIXME_parser.j | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tools/xcodecapp/Resources/FIXME_parser.j b/Tools/xcodecapp/Resources/FIXME_parser.j index 05f01f14e..bebe887b0 100644 --- a/Tools/xcodecapp/Resources/FIXME_parser.j +++ b/Tools/xcodecapp/Resources/FIXME_parser.j @@ -61,7 +61,8 @@ function main(args) { if (aType === "@outlet") types[anIndex] = "IBOutlet"; - else + + else if (aType !== "IBOutlet") types[anIndex] = NSCompatibleClassName(aType, YES); }); From 722ffeda8872c8287e797e42a582a78435039d56 Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Fri, 15 Apr 2011 15:59:59 +0200 Subject: [PATCH 11/19] add CPIndexPath to Foundation.j --- Foundation/Foundation.j | 1 + 1 file changed, 1 insertion(+) diff --git a/Foundation/Foundation.j b/Foundation/Foundation.j index d7cf97162..b1145b0cb 100755 --- a/Foundation/Foundation.j +++ b/Foundation/Foundation.j @@ -36,6 +36,7 @@ @import "CPExpression.j" @import "CPFormatter.j" @import "CPIndexSet.j" +@import "CPIndexPath.j" @import "CPInvocation.j" @import "CPJSONPConnection.j" @import "CPKeyedArchiver.j" From 38db22db06cc7e7dc4d98941b1c0f067cc6af466 Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Fri, 15 Apr 2011 16:00:18 +0200 Subject: [PATCH 12/19] fix a decoding bug with CPBox and it's contentView --- AppKit/CPView.j | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 2a5bdc2be..bd2a5be03 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -2629,7 +2629,11 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", _registeredDraggedTypes = [CPSet set]; _registeredDraggedTypesArray = []; - _autoresizingMask = [aCoder decodeIntForKey:CPViewAutoresizingMaskKey] || CPViewNotSizable; + // Other views (CPBox) might set an autoresizes mask on their subviews before it is actually decoded. + // We make sure we don't override the value by checking if it was already set. + if (_autoresizingMask === nil) + _autoresizingMask = [aCoder decodeIntForKey:CPViewAutoresizingMaskKey] || CPViewNotSizable; + _autoresizesSubviews = ![aCoder containsValueForKey:CPViewAutoresizesSubviewsKey] || [aCoder decodeBoolForKey:CPViewAutoresizesSubviewsKey]; _hitTests = ![aCoder containsValueForKey:CPViewHitTestsKey] || [aCoder decodeObjectForKey:CPViewHitTestsKey]; From 8661625dac7484514fd84c05101eac598f589eac Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Fri, 15 Apr 2011 09:16:25 -0700 Subject: [PATCH 13/19] Don't traverse subprojects (folders with Jakefiles). Reviewed by me. --- Tools/xcodecapp/XCResourceMonitor.j | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Tools/xcodecapp/XCResourceMonitor.j b/Tools/xcodecapp/XCResourceMonitor.j index 5de8af011..d0fb64191 100644 --- a/Tools/xcodecapp/XCResourceMonitor.j +++ b/Tools/xcodecapp/XCResourceMonitor.j @@ -31,8 +31,16 @@ var FILE = require("file"), m_removedFilePaths = []; m_editedFilePaths = []; - var paths = new FileList(m_pattern), - mtimesForFilePaths = [CPMutableDictionary new]; + // FIXME: There must be a better way to do this. + var subProjects = new FileList(FILE.join(FILE.dirname(FILE.dirname(m_pattern)), "*/**/Jakefile")), + paths = new FileList(m_pattern); + + subProjects.forEach(function(aPath) + { + paths.exclude(FILE.join(FILE.dirname(aPath), "**", "*")); + }); + + var mtimesForFilePaths = [CPMutableDictionary new]; paths.forEach(function(aPath) { From 39459c9a449097f7f671d2d8e8681d383f01d27c Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Fri, 15 Apr 2011 18:34:53 +0200 Subject: [PATCH 14/19] take min and max size from item prototype --- AppKit/CPCollectionView.j | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/AppKit/CPCollectionView.j b/AppKit/CPCollectionView.j index 2ac7d0b86..61e68082d 100644 --- a/AppKit/CPCollectionView.j +++ b/AppKit/CPCollectionView.j @@ -898,6 +898,21 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeK @implementation CPCollectionView (CPCoding) +- (void)awakeFromCib +{ + [super awakeFromCib]; + + if (CGSizeEqualToSize(_minItemSize, CGSizeMakeZero()) || CGSizeEqualToSize(_maxItemSize, CGSizeMakeZero())) + { + var item = _itemPrototype; + + if (CGSizeEqualToSize(_minItemSize, CGSizeMakeZero())) + _minItemSize = [[item view] frameSize]; + else if (CGSizeEqualToSize(_maxItemSize, CGSizeMakeZero())) + _maxItemSize = [[item view] frameSize]; + } +} + - (id)initWithCoder:(CPCoder)aCoder { self = [super initWithCoder:aCoder]; From 86e3717222b1d951928af5655300b7d1c108b6d5 Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Tue, 19 Apr 2011 01:46:41 -0400 Subject: [PATCH 15/19] Fixes for splitview documentation --- AppKit/CPSplitView.j | 70 ++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/AppKit/CPSplitView.j b/AppKit/CPSplitView.j index 16e58d422..f47f1e4b7 100644 --- a/AppKit/CPSplitView.j +++ b/AppKit/CPSplitView.j @@ -739,41 +739,59 @@ var CPSplitViewHorizontalImage = nil, Sets the delegate of the receiver. Possible delegate methods to implement are listed below. -
-        - (void)splitViewDidResizeSubviews:(CPSplitView)aSplitView;
-            Notifies the delegate when the subviews have resized.
+Notifies the delegate when the subviews have resized.
+@code
+- (void)splitViewDidResizeSubviews:(CPNotification)aNotification;
+@endcode
 
-        - (void)splitViewWillResizeSubviews:(CPSplitView)aSplitView;
-            Notifies the delegate when the subviews will be resized.
+Notifies the delegate when the subviews will be resized.
+@code
+- (void)splitViewWillResizeSubviews:(CPNotification)aNotification;
+@endcode
 
-        - (CGRect)splitView:(CPSplitView)aSplitView effectiveRect:(CGRect)aRect forDrawnRect:(CGRect)aDrawnRect ofDividerAtIndex:(int)aDividerIndex;
-            Lets the delegate specify a different rect for which the user can drag the splitView divider.
+Lets the delegate specify a different rect for which the user can drag the splitView divider.
+@code
+- (CGRect)splitView:(CPSplitView)aSplitView effectiveRect:(CGRect)aRect forDrawnRect:(CGRect)aDrawnRect ofDividerAtIndex:(int)aDividerIndex;
+@endcode
 
-        - (CGRect)splitView:(CPSplitView)aSplitView additionalEffectiveRectOfDividerAtIndex:(int)indexOfDivider;
-            Lets the delegate specify an additional rect for which the user can drag the splitview divider.
+Lets the delegate specify an additional rect for which the user can drag the splitview divider.
+@code
+- (CGRect)splitView:(CPSplitView)aSplitView additionalEffectiveRectOfDividerAtIndex:(int)indexOfDivider;
+@endcode
 
-        - (BOOL)splitView:(CPSplitView)aSplitView canCollapseSubview:(CPView)aSubview;
-            Notifies the delegate that the splitview is about to be collapsed. This usually happens when the user
-            Double clicks on the divider. Return YES if the subview can be collapsed, otherwise NO.
+Notifies the delegate that the splitview is about to be collapsed. This usually happens when the user
+Double clicks on the divider. Return YES if the subview can be collapsed, otherwise NO.
+@code
+- (BOOL)splitView:(CPSplitView)aSplitView canCollapseSubview:(CPView)aSubview;
+@endcode
 
-         - (BOOL)splitView:(CPSplitView)aSplitView shouldCollapseSubview:(CPView)aSubview forDoubleClickOnDividerAtIndex:(int)indexOfDivider;
-            Notifies the delegate that the subview at indexOfDivider is about to be collapsed. This usually happens when the user
-            Double clicks on the divider. Return YES if the subview should be collapsed, otherwise NO.
+Notifies the delegate that the subview at indexOfDivider is about to be collapsed. This usually happens when the user
+Double clicks on the divider. Return YES if the subview should be collapsed, otherwise NO.
+@code
+ - (BOOL)splitView:(CPSplitView)aSplitView shouldCollapseSubview:(CPView)aSubview forDoubleClickOnDividerAtIndex:(int)indexOfDivider;
+@endcode
 
-        - (float)splitView:(CPSplitView)aSpiltView constrainSplitPosition:(float)proposedPosition ofSubviewAt:(int)subviewIndex;
-            Allows the delegate to constrain the subview beings resized. This method is called continuously as the user resizes the divider.
-            For example if the subview needs to have a width which is a multiple of a certain number you could return that multiple with this method.
+Allows the delegate to constrain the subview beings resized. This method is called continuously as the user resizes the divider.
+For example if the subview needs to have a width which is a multiple of a certain number you could return that multiple with this method.
+@code
+- (float)splitView:(CPSplitView)aSpiltView constrainSplitPosition:(float)proposedPosition ofSubviewAt:(int)subviewIndex;
+@endcode
 
-        - (float)splitView:(CPSplitView)aSplitView constrainMinCoordinate:(float)proposedMin ofSubviewAt:(int)subviewIndex;
-            Allows the delegate to constrain the minimum position of a subview.
+Allows the delegate to constrain the minimum position of a subview.
+@code
+- (float)splitView:(CPSplitView)aSplitView constrainMinCoordinate:(float)proposedMin ofSubviewAt:(int)subviewIndex;
+@endcode
 
-        - (float)splitView:(CPSplitView)aSplitView constrainMaxCoordinate:(float)proposedMax ofSubviewAt:(int)subviewIndex;
-            Allows the delegate to constrain the maximum position of a subview.
+Allows the delegate to constrain the maximum position of a subview.
+@code
+- (float)splitView:(CPSplitView)aSplitView constrainMaxCoordinate:(float)proposedMax ofSubviewAt:(int)subviewIndex;
+@endcode
 
-        - (void)splitView:(CPSplitView)aSplitView resizeSubviewsWithOldSize:(CGSize)oldSize;
-            Allows the splitview to specify a custom resizing behavior. This is called when the splitview is resized.
-            The sum of the views and the sum of the dividers should be equal to the size of the splitview.
-    
+Allows the splitview to specify a custom resizing behavior. This is called when the splitview is resized. +The sum of the views and the sum of the dividers should be equal to the size of the splitview. +@code +- (void)splitView:(CPSplitView)aSplitView resizeSubviewsWithOldSize:(CGSize)oldSize; +@endcode @param delegate - The delegate of the splitview. */ From dc264231c825d46354f50a692cf5a8ffeef3bd05 Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Wed, 20 Apr 2011 08:58:30 +0200 Subject: [PATCH 16/19] open menu bar menus directly --- AppKit/CPMenu/_CPMenuManager.j | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/AppKit/CPMenu/_CPMenuManager.j b/AppKit/CPMenu/_CPMenuManager.j index a95bc5fba..15af786fb 100644 --- a/AppKit/CPMenu/_CPMenuManager.j +++ b/AppKit/CPMenu/_CPMenuManager.j @@ -243,9 +243,15 @@ var STICKY_TIME_INTERVAL = 500, // Close the current menu item because we are going to select a new one after a short delay [self showMenu:nil fromMenu:activeMenu atPoint:CGPointMakeZero()]; - _showTimerID = setTimeout(function() { + + if (![activeMenuContainer isMenuBar]) + { + _showTimerID = setTimeout(function() { + [self showMenu:[activeItem submenu] fromMenu:[activeItem menu] atPoint:newMenuOrigin]; + }, 250); + } + else [self showMenu:[activeItem submenu] fromMenu:[activeItem menu] atPoint:newMenuOrigin]; - }, 250); } } From 71d8582f94dfff3b82a9d8600f2e54284ef7c56c Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Wed, 20 Apr 2011 16:21:28 +0200 Subject: [PATCH 17/19] make unhandled keyboard events travel past the window --- AppKit/CPWindow/CPWindow.j | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index dcdc9e727..8a2f6e43f 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -193,24 +193,24 @@ var SHADOW_MARGIN_LEFT = 20.0, _CPWindowShadowColor = nil; var CPWindowSaveImage = nil, - CPWindowSavingImage = nil; + CPWindowSavingImage = nil, -var CPWindowResizeTime = 0.2; + CPWindowResizeTime = 0.2; /* Keys for which action messages will be sent by default when unhandled, e.g. complete:. */ var CPWindowActionMessageKeys = [ - CPLeftArrowFunctionKey, - CPRightArrowFunctionKey, - CPUpArrowFunctionKey, - CPDownArrowFunctionKey, - CPPageUpFunctionKey, - CPPageDownFunctionKey, - CPHomeFunctionKey, - CPEndFunctionKey, - CPEscapeFunctionKey -]; + CPLeftArrowFunctionKey, + CPRightArrowFunctionKey, + CPUpArrowFunctionKey, + CPDownArrowFunctionKey, + CPPageUpFunctionKey, + CPPageDownFunctionKey, + CPHomeFunctionKey, + CPEndFunctionKey, + CPEscapeFunctionKey + ]; /*! @ingroup appkit @@ -2377,7 +2377,9 @@ CPTexturedBackgroundWindowMask // an event going of the responder chain is passed to the input system as a last resort. // However, the only methods I could get Cocoa to call automatically are // moveUp: moveDown: moveLeft: moveRight: pageUp: pageDown: and complete: - [self _processKeyboardUIKey:anEvent]; + // Unhandled events just travel further up the responder chain _past_ the window. + if (![self _processKeyboardUIKey:anEvent]) + [super keyDown:anEvent]; } /* @@ -2412,6 +2414,8 @@ CPTexturedBackgroundWindowMask // The difference is that doCommandBySelector: will also send the action to the window and application delegates. [[self firstResponder] doCommandBySelector:@selector(complete:)]; } + + return NO; } - (void)_dirtyKeyViewLoop From 561d22168a0fa0ea65b7ef97c6176195cb8b0272 Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Wed, 20 Apr 2011 12:19:29 -0400 Subject: [PATCH 18/19] Stop references function arguments with arguments["name"] in CG. --- AppKit/CoreGraphics/CGContext.j | 2 +- AppKit/CoreGraphics/CGContextCanvas.j | 6 +++--- AppKit/CoreGraphics/CGGradient.j | 6 +++--- AppKit/CoreGraphics/CGPath.j | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/AppKit/CoreGraphics/CGContext.j b/AppKit/CoreGraphics/CGContext.j index 34eb0c603..88de992c1 100644 --- a/AppKit/CoreGraphics/CGContext.j +++ b/AppKit/CoreGraphics/CGContext.j @@ -606,7 +606,7 @@ function CGContextStrokeLineSegments(aContext, points, count) { var i = 0; - if (arguments["count"] == NULL) + if (count === NULL) var count = points.length; CGContextBeginPath(aContext); diff --git a/AppKit/CoreGraphics/CGContextCanvas.j b/AppKit/CoreGraphics/CGContextCanvas.j index 5a12aae01..288ab147f 100644 --- a/AppKit/CoreGraphics/CGContextCanvas.j +++ b/AppKit/CoreGraphics/CGContextCanvas.j @@ -144,7 +144,7 @@ function CGContextAddRects(aContext, rects, count) { var i = 0; - if (arguments["count"] == NULL) + if (count === NULL) var count = rects.length; for (; i < count; ++i) @@ -194,7 +194,7 @@ function CGContextFillRects(aContext, rects, count) { var i = 0; - if (arguments["count"] == NULL) + if (count === NULL) var count = rects.length; for (; i < count; ++i) @@ -225,7 +225,7 @@ function CGContextClipToRect(aContext, aRect) function CGContextClipToRects(aContext, rects, count) { - if (arguments["count"] == NULL) + if (count === NULL) var count = rects.length; _CGContextBeginPathCanvas(aContext); diff --git a/AppKit/CoreGraphics/CGGradient.j b/AppKit/CoreGraphics/CGGradient.j index 29b5d149f..e8396aa3d 100644 --- a/AppKit/CoreGraphics/CGGradient.j +++ b/AppKit/CoreGraphics/CGGradient.j @@ -29,10 +29,10 @@ kCGGradientDrawsAfterEndLocation = 1 << 1; function CGGradientCreateWithColorComponents(aColorSpace, components, locations, count) { - if (arguments["locations"] == NULL) + if (locations === NULL) var locations = [0.0, 1.0]; - if (arguments["count"] == NULL) + if (count === NULL) var count = locations.length; var colors = []; @@ -58,4 +58,4 @@ function CGGradientRelease() function CGGradientRetain(aGradient) { return aGradient; -} \ No newline at end of file +} diff --git a/AppKit/CoreGraphics/CGPath.j b/AppKit/CoreGraphics/CGPath.j index 5dde217cb..bc0fe4c2f 100644 --- a/AppKit/CoreGraphics/CGPath.j +++ b/AppKit/CoreGraphics/CGPath.j @@ -141,7 +141,7 @@ function CGPathAddLines(aPath, aTransform, points, count) { var i = 1; - if (arguments["count"] == NULL) + if (count === NULL) var count = points.length; if (!aPath || count < 2) @@ -224,7 +224,7 @@ function CGPathAddRects(aPath, aTransform, rects, count) { var i = 0; - if (arguments["count"] == NULL) + if (count === NULL) var count = rects.length; for (; i < count; ++i) From b249a1db13760823a513f4a3dbb18204a7409984 Mon Sep 17 00:00:00 2001 From: Gerrit Riessen Date: Tue, 19 Apr 2011 12:10:17 +0200 Subject: [PATCH 19/19] test demostrating limitations of CGGradientCreateWithColorComponents --- Tests/AppKit/CGGradientTest.j | 66 +++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Tests/AppKit/CGGradientTest.j diff --git a/Tests/AppKit/CGGradientTest.j b/Tests/AppKit/CGGradientTest.j new file mode 100644 index 000000000..187dd713d --- /dev/null +++ b/Tests/AppKit/CGGradientTest.j @@ -0,0 +1,66 @@ +@import + +@implementation CGGradientTest : OJTestCase + +/* + Using default values for location and count. +*/ +- (void)testCreateWithColorComponentsDefault +{ + var components = [ 0.2,0.2,0.4,0.4, + 0.6,0.6,0.8,0.8 ]; + + var tmp = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), + components); + [self assert:2 equals:tmp.colors.length]; + [self assert:2 equals:tmp.locations.length]; + + [self assert:0 equals:tmp.locations[0]]; + [self assert:1.0 equals:tmp.locations[1]]; + + [self assert:components.slice(4,8) equals:tmp.colors[1].components]; + [self assert:components.slice(0,4) equals:tmp.colors[0].components]; +} + +/* + Using location and components to specify two color stops that aren't + evenly spread out. +*/ +- (void)testCreateWithColorComponentsUsingTwoColorStops +{ + var components = [ 0.2,0.2,0.4,0.4, + 0.6,0.6,0.8,0.8 ]; + var locations = [0.3,0.6]; + + var tmp = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), + components,locations); + [self assert:2 equals:tmp.colors.length]; + [self assert:2 equals:tmp.locations.length]; + + [self assert:0.3 equals:tmp.locations[0]]; + [self assert:0.6 equals:tmp.locations[1]]; + + [self assert:components.slice(4,8) equals:tmp.colors[1].components]; + [self assert:components.slice(0,4) equals:tmp.colors[0].components]; +} + +/* + Define three color components and ensure that the Gradient defined contains 3 color stops. +*/ +- (void)testCanHaveMoreThanTwoColorStops +{ + var components = [ 1,2,3,4, 5,6,7,8, 9,10,11,12 ]; + var locations = [1,2,3]; + + var tmp = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), + components, locations, 3); + [self assert:3 equals:tmp.colors.length]; + [self assert:3 equals:tmp.locations.length]; + + [self assert:1 equals:tmp.locations[0]]; + [self assert:2 equals:tmp.locations[1]]; + [self assert:3 equals:tmp.locations[2]]; +} + + +@end