From 7e99e3ca20f48fde3b91c2b2486b33658f48cb9c Mon Sep 17 00:00:00 2001 From: daboe01 Date: Sat, 19 Jul 2025 14:21:10 +0200 Subject: [PATCH] removed: unwanted files --- dist/cappuccino/bin/flatten | 368 --------------- dist/cappuccino/bin/fontinfo | Bin 70736 -> 0 bytes dist/cappuccino/bin/objj2objcskeleton | 623 -------------------------- 3 files changed, 991 deletions(-) delete mode 100755 dist/cappuccino/bin/flatten delete mode 100755 dist/cappuccino/bin/fontinfo delete mode 100755 dist/cappuccino/bin/objj2objcskeleton diff --git a/dist/cappuccino/bin/flatten b/dist/cappuccino/bin/flatten deleted file mode 100755 index 80b9ecf8e..000000000 --- a/dist/cappuccino/bin/flatten +++ /dev/null @@ -1,368 +0,0 @@ -#!/usr/bin/env objj - -require("narwhal").ensureEngine("rhino"); - -@import - -@import "../lib/cappuccino/objj-analysis-tools.j" - -var FILE = require("file"); -var OS = require("os"); -var UTIL = require("narwhal/util"); - -var CACHEMANIFEST = require("objective-j/cache-manifest"); - -var stream = require("narwhal/term").stream; -var parser = new (require("narwhal/args").Parser)(); - -parser.usage("INPUT_PROJECT OUTPUT_PROJECT"); -parser.help("Combine a Cappuccino application into a single JavaScript file."); - -parser.option("-m", "--main", "main") - .def("main.j") - .set() - .help("The relative path (from INPUT_PROJECT) to the main file (default: 'main.j')"); - -parser.option("-F", "--framework", "frameworks") - .push() - .help("Add a frameworks directory, relative to INPUT_PROJECT (default: ['Frameworks'])"); - -parser.option("-P", "--path", "paths") - .push() - .help("Add a path (relative to the application root) to inline."); - -parser.option("-f", "--force", "force") - .def(false) - .set(true) - .help("Force overwriting OUTPUT_PROJECT if it exists"); - -parser.option("--index", "index") - .def("index.html") - .set() - .help("The root HTML file to modify (default: index.html)"); - -parser.option("-s", "--split", "number", "split") - .natural() - .def(0) - .help("Split into multiple files"); - -parser.option("-c", "--compressor", "compressor") - .def("shrinksafe") - .set() - .help("Select a compressor to use (closure-compiler, yuicompressor, shrinksafe), or \"none\" (default: shrinksafe)"); - -parser.option("--manifest", "manifest") - .set(true) - .help("Generate HTML5 cache manifest."); - -parser.option("-v", "--verbose", "verbose") - .def(false) - .set(true) - .help("Verbose logging"); - -parser.helpful(); - -function main(args) -{ - var options = parser.parse(args); - - if (options.args.length < 2) { - parser.printUsage(options); - return; - } - - var rootPath = FILE.path(options.args[0]).join("").absolute(); - var outputPath = FILE.path(options.args[1]).join("").absolute(); - - if (outputPath.exists()) { - if (options.force) { - // FIXME: why doesn't this work?! - //outputPath.rmtree(); - OS.system(["rm", "-rf", outputPath]); - } else { - stream.print("\0red(OUTPUT_PROJECT " + outputPath + " exists. Use -f to overwrite.\0)"); - OS.exit(1); - } - } - - options.frameworks.push("Frameworks"); - - var mainPath = String(rootPath.join(options.main)); - var frameworks = options.frameworks.map(function(framework) { return rootPath.join(framework); }); - var environment = "Browser"; - - stream.print("\0yellow("+Array(81).join("=")+"\0)"); - stream.print("Application root: \0green(" + rootPath + "\0)"); - stream.print("Output directory: \0green(" + outputPath + "\0)"); - - stream.print("\0yellow("+Array(81).join("=")+"\0)"); - stream.print("Main file: \0green(" + mainPath + "\0)"); - stream.print("Frameworks: \0green(" + frameworks + "\0)"); - stream.print("Environment: \0green(" + environment + "\0)"); - - var flattener = new ObjectiveJFlattener(rootPath); - - flattener.options = options; - - flattener.setIncludePaths(frameworks); - flattener.setEnvironments([environment, "ObjJ"]); - - print("Loading application."); - flattener.load(mainPath); - - print("Loading default theme."); - flattener.require("objective-j").objj_eval("("+(function() { - - var defaultThemeName = [CPApplication defaultThemeName], - bundle = nil; - - if (defaultThemeName === @"Aristo" || defaultThemeName === @"Aristo2") - bundle = [CPBundle bundleForClass:[CPApplication class]]; - else - bundle = [CPBundle mainBundle]; - - var blend = [[CPThemeBlend alloc] initWithContentsOfURL:[bundle pathForResource:defaultThemeName + @".blend"]]; - [blend loadWithDelegate:nil]; - - })+")")(); - - var applicationJSs = flattener.buildApplicationJS(); - - FILE.copyTree(rootPath, outputPath); - - applicationJSs.forEach(function(applicationJS, n) { - var name = "Application"+(n||"")+".js"; - if (options.compressor === "none") { - print("skipping compression: " + name); - } else { - print("compressing: " + name); - applicationJS = require("minify/"+options.compressor).compress(applicationJS, { charset : "UTF-8", useServer : true }); - } - outputPath.join(name).write(applicationJS, { charset : "UTF-8" }); - }); - - rewriteMainHTML(outputPath.join(options.index)); - - if (options.manifest) { - CACHEMANIFEST.generateManifest(outputPath, { - index : outputPath.join(options.index), - exclude : Object.keys(flattener.filesToCache).map(function(path) { return outputPath.join(path).toString(); }) - }); - } -} - -// ObjectiveJFlattener inherits from ObjectiveJRuntimeAnalyzer -function ObjectiveJFlattener(rootPath) { - ObjectiveJRuntimeAnalyzer.apply(this, arguments); - - this.filesToCache = {}; - this.fileCacheBuffer = []; - this.functionsBuffer = []; -} - -ObjectiveJFlattener.prototype = Object.create(ObjectiveJRuntimeAnalyzer.prototype); - -ObjectiveJFlattener.prototype.buildApplicationJS = function() { - - this.setupFileCache(); - this.serializeFunctions(); - this.serializeFileCache(); - - var additions = FILE.read(FILE.join(FILE.dirname(module.path), "..", "..", "cappuccino", "lib", "cappuccino", "objj-flatten-additions.js"), { charset:"UTF-8" }); - - var applicationJSs = []; - - if (this.options.split === 0) { - var buffer = []; - buffer.push("var baseURL = new CFURL(\".\", ObjectiveJ.pageURL);"); - buffer.push(additions); - buffer.push(this.fileCacheBuffer.join("\n")); - buffer.push(this.functionsBuffer.join("\n")); - buffer.push("ObjectiveJ.bootstrap();"); - applicationJSs.push(buffer.join("\n")); - } else { - var appFilesCount = this.options.split; - - var buffers = []; - for (var i = 0; i <= appFilesCount; i++) - buffers.push([]); - - var chunks = this.fileCacheBuffer.concat(this.functionsBuffer).sort(function(chunkA, chunkB) { - return chunkA.length - chunkB.length; - }); - - // try to equally distribute the chunks. could be better but good enough for now. - var n = 0; - while (chunks.length) { - buffers[(n++ % appFilesCount) + 1].push(chunks.pop()); - } - - buffers[0].push("var baseURL = new CFURL(\".\", ObjectiveJ.pageURL);"); - buffers[0].push(additions); - - buffers[0].push("var appFilesCount = " + appFilesCount +";"); - buffers[0].push("for (var i = 1; i <= appFilesCount; i++) {"); - buffers[0].push(" var script = document.createElement(\"script\");"); - buffers[0].push(" script.src = \"Application\"+i+\".js\";"); - buffers[0].push(" script.charset = \"UTF-8\";"); - buffers[0].push(" script.onload = function() { if (--appFilesCount === 0) ObjectiveJ.bootstrap(); };"); - buffers[0].push(" document.getElementsByTagName(\"head\")[0].appendChild(script);"); - buffers[0].push("}"); - - buffers.forEach(function(buffer) { - applicationJSs.push(buffer.join("\n")); - }); - } - - return applicationJSs; -} - -ObjectiveJFlattener.prototype.serializeFunctions = function() { - var inlineFunctions = true;//this.options.inlineFunctions; - - var outputFiles = {}; - - var _cachedExecutableFunctions = {}; - - this.require("objective-j").FileExecutable.allFileExecutables().forEach(function(executable) { - var path = executable.path(); - - if (inlineFunctions) - { - // stringify the function, replacing arguments - var functionString = executable._function.toString().replace(", require, exports, module, system, print, window", ""); // HACK - - var relative = this.rootPath.relative(path).toString(); - this.functionsBuffer.push("ObjectiveJ.FileExecutable._cacheFunction(new CFURL("+JSON.stringify(relative)+", baseURL),\n"+functionString+");"); - } - - var bundle = this.context.global.CFBundle.bundleContainingURL(path); - if (bundle && bundle.infoDictionary()) - { - var executablePath = bundle.executablePath(), - relativeToBundle = FILE.relative(FILE.join(bundle.path(), ""), path); - - if (executablePath) - { - if (inlineFunctions) - { - // remove the code since we're inlining the functions - executable._code = "alert("+JSON.stringify(relativeToBundle)+");"; - } - - if (!outputFiles[executablePath]) - { - outputFiles[executablePath] = []; - outputFiles[executablePath].push("@STATIC;1.0;"); - } - - var fileContents = executable.toMarkedString(); - - outputFiles[executablePath].push("p;" + relativeToBundle.length + ";" + relativeToBundle); - outputFiles[executablePath].push("t;" + fileContents.length + ";" + fileContents); - - // stream.print("Adding \0green(" + this.rootPath.relative(path) + "\0) to \0cyan(" + this.rootPath.relative(executablePath) + "\0)"); - } - } - else - CPLog.warn("No bundle (or info dictionary for) " + rootPath.relative(path)); - }, this); - - for (var executablePath in outputFiles) - { - var relative = this.rootPath.relative(executablePath).toString(); - var contents = outputFiles[executablePath].join(""); - this.filesToCache[relative] = contents; - } -} - -ObjectiveJFlattener.prototype.serializeFileCache = function() { - for (var relative in this.filesToCache) { - var contents = this.filesToCache[relative]; - print("caching: " + relative + " => " + (contents == null ? 404 : 200)); - if (contents == null) - this.fileCacheBuffer.push("CFHTTPRequest._cacheRequest(new CFURL("+JSON.stringify(relative)+", baseURL), 404);"); - else - this.fileCacheBuffer.push("CFHTTPRequest._cacheRequest(new CFURL("+JSON.stringify(relative)+", baseURL), 200, {}, "+JSON.stringify(contents)+");"); - } -} - -ObjectiveJFlattener.prototype.setupFileCache = function() { - var paths = {}; - - UTIL.update(paths, this.requestedURLs); - - this.options.paths.forEach(function(relativePath) { - paths[this.rootPath.join(relativePath)] = true; - }, this); - - Object.keys(paths).forEach(function(absolute) { - var relative = this.rootPath.relative(absolute).toString(); - if (relative.indexOf("..") === 0) - { - print("skipping (parent of app root): " + absolute); - return; - } - - if (FILE.isFile(absolute)) - { - // if (this.options.maxCachedSize && FILE.size(absolute) > this.options.maxCachedSize) - // { - // print("skipping (larger than "+this.options.maxCachedSize+" bytes): " + absolute); - // return; - // } - - var contents = FILE.read(absolute, { charset : "UTF-8" }); - this.filesToCache[relative] = contents; - } else { - this.filesToCache[relative] = null; - } - }, this); -} - -// "$1" is the matching indentation -var scriptTagsBefore = - '$1'; - -var scriptTagsAfter = - '$1'; - -// enable CPLog: -// scriptTagsAfter = '$1\n' + scriptTagsAfter; - -function rewriteMainHTML(indexHTMLPath) { - if (indexHTMLPath.isFile()) { - var indexHTML = indexHTMLPath.read({ charset : "UTF-8" }); - - // inline the Application.js if it's smallish - var applicationJSPath = indexHTMLPath.dirname().join("Application.js"); - if (applicationJSPath.size() < 10*1024) { - // escape any dollar signs by replacing them with two - // then indent by splitting/joining on newlines - scriptTagsAfter = - '$1'; - } - - // attempt to find Objective-J script tag and add ours - var newIndexHTML = indexHTML.replace(/([ \t]+)]+Objective-J\.js[^>]+>(?:\s*<\/script>)?/, - scriptTagsBefore+'\n$&\n'+scriptTagsAfter); - - if (newIndexHTML !== indexHTML) { - stream.print("\0green(Modified: "+indexHTMLPath+".\0)"); - indexHTMLPath.write(newIndexHTML, { charset : "UTF-8" }); - return; - } - } else { - stream.print("\0yellow(Warning: "+indexHTMLPath+" does not exist. Specify an alternate index HTML file with the --index option.\0)"); - } - - stream.print("\0yellow(Warning: Unable to automatically modify "+indexHTMLPath + ".\0)"); - stream.print("\nAdd the following before the Objective-J script tag:"); - stream.print(scriptTagsBefore.replace(/\$1/g, " ")); - stream.print("\nAdd the following after the Objective-J script tag:"); - stream.print(scriptTagsAfter.replace(/\$1/g, " ")); -} diff --git a/dist/cappuccino/bin/fontinfo b/dist/cappuccino/bin/fontinfo deleted file mode 100755 index 1a91ba1c8040bbcfe787719cb7e44c0e7578d180..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 70736 zcmeI5eQ;FO6~OQACJ;h^1yK+YmgU3nk-PvA!-B9OAAH3mLl%j&?3ZpyJRPbmx_ioUv5-(a^H?;YI6xLpX%D8sm06b*U1!3|K^`Od)H zF<&b#1`67|YBdzFq*bwgMNv26em&ikoo`jKl@A$UK|3>F5zhw<%_54be@kE>X?DH? zJYO$|hBmG*U2^6Z&<#zAw($*M)O^CW0z zmfU>tXonIFib^!3LdWd+ofyTh2Ty`_c8<*axKFBpjVRVu`>Ms7rp6X)w|My`1#Olr z?SRIVIH4|zZED6g88Tmr8-sippDMWDQhN^DL@^M`yb#&*+wQgIm&DFc(9X!3uWHW|@n=j(%b+#*Fh2JL*@_CsGQ4-Z0>%;E;NS-h4?G2`12;;sEFhc!6_x5ZHT z(%h1R*9m(W@u$nc`O&btacy1g>eRj8!{?RcUBSlE%>6i@)SR%r5>{d+?g0ZpEKJ!i zFy^wF*hJ8!V9x>V`ZHrEU~wa%-VA~T=YoQHCxHx_DA<|h@ShmFJhO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755 index 51ecab38d..000000000 --- a/dist/cappuccino/bin/objj2objcskeleton +++ /dev/null @@ -1,623 +0,0 @@ -#!/usr/bin/env objj - -@import - -var fs = require("fs"), - acorn = require("objj-parser"), - walk = require("acorn-walk"), - stream = ObjectiveJ.term; - -function main(args) -{ - args.shift(); - - if (args.length < 1) - return printUsage(); - - parser(args); -} - -function printUsage() -{ - console.log("objj2objskeleton [FILE] [DESTINATION]"); - console.log("Convert a objective-j file to an objective-c files skeleton (.h and .m)") -} - -// Debug function to print some JS objects -function dump(obj) -{ - console.log(JSON.stringify(obj)); -} - -function raise(pos, message) -{ - var syntaxError = new SyntaxError(message); - syntaxError.line = pos.line; - - throw syntaxError; -} - -function ignore(_node, _st, _c) {} - -var errors = [], - xcc = walk.make( - { - ClassDeclarationStatement: function(node, st, c) - { - var className = node.classname.name, - superclassname = node.superclassname ? node.superclassname.name : "", - declaredOutletsName = [], - classInfo = { - "name": className, - "category": node.categoryname ? node.categoryname.name : "", - "superClass": superclassname, - "outlets": [], - "actions": [], - "actionNames": [] - }; - - if (node.ivardeclarations) - { - for (var i = 0; i < node.ivardeclarations.length; ++i) - { - var ivarDecl = node.ivardeclarations[i], - ivarType = ivarDecl.ivartype ? ivarDecl.ivartype.name : null, - ivarName = ivarDecl.id.name, - ivarHasOutlet = ivarDecl.outlet ? "@outlet" : null; - - if (ivarHasOutlet) - { - if (declaredOutletsName.indexOf(ivarName) !== -1) - raise(ivarDecl.loc.start, "Outlet '" + ivarName + "' declared more than once"); - - declaredOutletsName.push(ivarName); - classInfo.outlets.push({"type": ivarType, "name": ivarName}); - } - } - } - - st.push(classInfo) - - for (var i = 0; i < node.body.length; ++i) - c(node.body[i], classInfo, "Statement"); - }, - - MethodDeclarationStatement: function(node, st, c) - { - var selectors = node.selectors, - arguments = node.arguments, - //methodReturnType = [node.returntype ? node.returntype.name : "id"], - methodHasAction = node.action ? "IBAction" : null, - selector = selectors[0].name, - actionInfo = {"name": selector, "arguments":[]}; - - if (methodHasAction) - { - if (arguments.length == 1) - { - if (st.actionNames.indexOf(selector) !== -1) - raise(node.loc.start, "Action '" + selector + "' declared more than once"); - - st.actionNames.push(selector); - - for (var i = 0; i < arguments.length; i++) - { - var argument = arguments[i], - argumentName = argument.identifier.name, - argumentType = argument.type ? argument.type.name : null; - - actionInfo.arguments.push({"type": argumentType, "name": argumentName}); - } - - st.actions.push(actionInfo) - } - else - raise(node.loc.start, "Action methods must have exactly one parameter"); - } - }, - TypeDefStatement: ignore, - ClassStatement: ignore, - MessageSendExpression: ignore, - GlobalStatement: ignore, - ProtocolDeclarationStatement: ignore, - ArrayLiteral: ignore, - Reference: ignore, - DictionaryLiteral: ignore, - Dereference: ignore, - ImportStatement: ignore, - SelectorLiteralExpression: ignore - } -); - -function compile(node, state, visitor) -{ - function c(node, st, override) - { - visitor[override || node.type](node, st, c); - } - - c(node, state); -}; - -function removeLastSlashIfNecessary(path) -{ - if (path[path.length - 1] == "/") - return path.substring(0, path.length - 1); - - return path; -} - -/* - $1 Full project source path - $2 Destination - $-n name of the cocoa files -*/ -function parser(args) -{ - try - { - var sourcePath = args.shift(), - projectBasePath = removeLastSlashIfNecessary(args.shift()), - outputDirectory = projectBasePath, - baseFilename = [sourcePath lastPathComponent], - baseFilenameWithNoExtension = args.shift() == "-n" ? args.shift() : baseFilename.substring(0, baseFilename.length - 2), - outputHeaderURL = new CFURL([outputDirectory stringByAppendingPathComponent:baseFilenameWithNoExtension + ".h"]), - outputImplementationURL = new CFURL([outputDirectory stringByAppendingPathComponent:baseFilenameWithNoExtension + ".m"]), - source = fs.readFileSync(sourcePath, { encoding: "utf8" }), - tokens = acorn.parse(source, { locations:true, sourceFile:sourcePath, ecmaVersion: 2022 }), - classesInformation = [], - ObjectiveCSource = "", - ObjectiveCHeader = "", - hasErrors = NO; - - compile(tokens, classesInformation, xcc); - - // dump(classesInformation) - - ObjectiveCHeader += - "#import \n" + - '#import "xcc_general_include.h"\n'; - - ObjectiveCSource += "#import \"" + outputHeaderURL.lastPathComponent() + "\"\n"; - - // Traverse each found classes - classesInformation.forEach(function(aClass) - { - // add new class definition - if (aClass.superClass) - ObjectiveCHeader += [CPString stringWithFormat:@"\n@interface %@ : %@", aClass.name, NSCompatibleClassName(aClass.superClass)]; - else - ObjectiveCHeader += [CPString stringWithFormat:@"\n@interface %@ (%@)", NSCompatibleClassName(aClass.name, NO), aClass.category]; - - // add each outlet in header - if (aClass.outlets.length > 0) - ObjectiveCHeader += "\n"; - - aClass.outlets.forEach(function(anOutlet) - { - ObjectiveCHeader += [CPString stringWithFormat:@"\n@property (assign) IBOutlet %@ %@;", NSCompatibleClassName(anOutlet.type, YES), anOutlet.name]; - }); - - if (aClass.actions.length > 0) - ObjectiveCHeader += "\n"; - - // add each action in header - aClass.actions.forEach(function(anAction) - { - ObjectiveCHeader += [CPString stringWithFormat:@"\n- (IBAction)%@:(%@)%@;", anAction.name, anAction.arguments[0].type, anAction.arguments[0].name]; - }); - - if (aClass.outlets.length > 0 || aClass.actions.length > 0) - ObjectiveCHeader += "\n"; - - ObjectiveCHeader += "\n@end\n"; - - // fill up the implementation file - ObjectiveCSource += "\n@implementation " + NSCompatibleClassName(aClass.name, NO) + "\n@end\n"; - }); - - if (ObjectiveCSource.length) - fs.writeFileSync(outputImplementationURL.absoluteString(), ObjectiveCSource, 'utf8'); - - if (ObjectiveCHeader.length) - fs.writeFileSync(outputHeaderURL.absoluteString(), ObjectiveCHeader, 'utf8'); - } - catch (e) - { - [errors addObject:@{ - @"message": e.message, - @"sourcePath": sourcePath, - @"line": e.line - }]; - - hasErrors = YES; - } - - if ([errors count]) - { - var plist = [CPPropertyListSerialization dataFromPropertyList:errors format:CPPropertyListXMLFormat_v1_0]; - - stream.printError([plist rawString]); - - // If there were category warnings, hasErrors is NO, so return a warning status - process.exit(hasErrors ? 1 : 2); - } -} - -function NSCompatibleClassName(aClassName, asPointer) -{ - if (aClassName === "var" || aClassName === "id") - return "id"; - - var prefix = aClassName.substr(0, 2), - asterisk = asPointer ? "*" : ""; - - if (prefix !== "CP") - return aClassName + asterisk; - - var NSClassName = "NS" + aClassName.substr(2); - - if (NSClasses[NSClassName]) - return NSClassName + asterisk; - - if (ReplacementClasses[aClassName]) - return ReplacementClasses[aClassName] + asterisk; - - return aClassName + asterisk; -} - -var ReplacementClasses = { - "CPWebView": "WebView", - "CPRadio": "NSButtonCell", - "CPRadioGroup": "NSMatrix" - }; - -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, - "NSTableCellView" : 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, - "NSPopover": YES, - "NSAppearance" : YES, - "NSVisualEffectView" : YES, - };