One of the fundamental things command line scripts want to do is access their command line arguments. One way to do this would be to expose a global ARGV array containing each argument passed the script.
Created attachment 224227 [details] Patch
Comment on attachment 224227 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=224227&action=review > Tools/jsc-cli/jsc-cli.xcodeproj/project.pbxproj:8 > - classes = { > - }; > - objectVersion = 46; > - objects = { > + archiveVersion = 1; > + classes = { > + }; > + objectVersion = 46; > + objects = { > Goddammit Xcode :)
(In reply to comment #2) > (From update of attachment 224227 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=224227&action=review > > > Tools/jsc-cli/jsc-cli.xcodeproj/project.pbxproj:8 > > - classes = { > > - }; > > - objectVersion = 46; > > - objects = { > > + archiveVersion = 1; > > + classes = { > > + }; > > + objectVersion = 46; > > + objects = { > > > > Goddammit Xcode :) Yeah, I dunno what's going on there lol.
Comment on attachment 224227 [details] Patch Commit queue looks like it's having a bad time, so I'll land manually.
Committed r164134: <http://trac.webkit.org/changeset/164134>
Comment on attachment 224227 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=224227&action=review > Tools/jsc-cli/jsc-cli/CLIInstance.m:75 > + [_context[@"ARGV"] setValue:(_baseFile ? _baseFile : @"") atIndex:0]; Nit: You could pull _context[@"ARGV"] out into a local instead of potentially calling it a bunch of times in a loop. I don't think ObjC has any support for optimizing away repeated calls like this. Of course performance right here is not important, but this is a good idiom to get used to for ObjC.
(In reply to comment #6) > (From update of attachment 224227 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=224227&action=review > > > Tools/jsc-cli/jsc-cli/CLIInstance.m:75 > > + [_context[@"ARGV"] setValue:(_baseFile ? _baseFile : @"") atIndex:0]; > > Nit: You could pull _context[@"ARGV"] out into a local instead of potentially calling it a bunch of times in a loop. I don't think ObjC has any support for optimizing away repeated calls like this. Of course performance right here is not important, but this is a good idiom to get used to for ObjC. Yeah, that's definitely a good idea. Not only does Obj-C not do a good job optimizing this, but these lookups aren't exactly cheap in the JSC API.