diff --git a/Foundation/CPKeyedUnarchiver.j b/Foundation/CPKeyedUnarchiver.j index 009f749857..8ad737c4a9 100644 --- a/Foundation/CPKeyedUnarchiver.j +++ b/Foundation/CPKeyedUnarchiver.j @@ -419,7 +419,7 @@ var _CPKeyedUnarchiverDecodeObjectAtIndex = function(self, anIndex) processedObject = [object awakeAfterUsingCoder:self]; - if (processedObject == object) + if (processedObject != object) { if (self._delegateSelectors & _CPKeyedUnarchiverWillReplaceObjectWithObjectSelector) [self._delegate unarchiver:self willReplaceObject:object withObject:processedObject]; diff --git a/Objective-J/preprocess.js b/Objective-J/preprocess.js index b7e7362145..df246bce9e 100644 --- a/Objective-J/preprocess.js +++ b/Objective-J/preprocess.js @@ -322,12 +322,9 @@ var objj_preprocess_brackets = function(tokens) // not within parenthesis or a tertiary statement. var preprocess = !braces && !tertiary && !parenthesis && !array; - // Generally we are unconcerned with whitespace, however the new - // operator is a special case since it could alse be part of an identifier. - if(token == TOKEN_NEW) token = "new "; // We handle the special case where the receiver is super. In this case, // use an objj_super object and use objj_msgSendSuper instead of objj_msgSend. - else if(token == TOKEN_SUPER) + if (token == TOKEN_SUPER) { if (!receiver.length) { @@ -385,15 +382,21 @@ var objj_preprocess_brackets = function(tokens) } } else - { + { + // Generally we are unconcerned with whitespace, however the new + // operator requires it. + if (previous == TOKEN_NEW) + previous = "new "; + // If we've already begun building our selector, then the token // should be applied to the current argument. if (selector.length) marg_list[marg_list.length - 1] += previous; + // If not, then it belongs to the receiver. - else + else receiver += previous; - + previous = token; } } @@ -409,8 +412,12 @@ var objj_preprocess_brackets = function(tokens) } // The literal interpretation is always handled in the same - // manner, simply aggregate the tokens. - literal += token; + // manner, simply aggregate the tokens, unless we have a new token, + // in which case we need to add back the whitespace we removed. + if (token == TOKEN_NEW) + literal += "new "; + else + literal += token; } // If we have a selector, then add the remaining string to the argument. @@ -425,7 +432,7 @@ var objj_preprocess_brackets = function(tokens) // array[i%] becomes arrayobjj_msgSend(i,"%") if not. This is an error either // way though. https://trac.280north.com/ticket/6 else if(!array && receiver.length && !((/[\:\+\-\*\/\=\<\>\&\|\!\.\%]/).test(receiver.charAt(receiver.length - 1))) && - receiver != "new " && !(/[\+\-\*\/\=\<\>\&\|\!\.\[\^\(]/).test(previous.charAt(0))) + receiver != TOKEN_NEW && !(/[\+\-\*\/\=\<\>\&\|\!\.\[\^\(]/).test(previous.charAt(0))) selector = previous; // If we did not build a selector through the parsing process, then we // are either a single entry literal array, or an array index, and so diff --git a/Tools/READMEs/TOOLS-README b/Tools/READMEs/TOOLS-README index 76a60cc249..0213d784a5 100644 --- a/Tools/READMEs/TOOLS-README +++ b/Tools/READMEs/TOOLS-README @@ -13,14 +13,15 @@ This package includes syntax highlighting modes for both SubEthaEdit, Coda, Text + Coda - Unarchive Tools/Editors/Objective-J.mode.zip - - Place the generated Objective-J.mode file in ~/Library/Application\ Support/Coda/Modes + - Place the generated Objective-J.mode file in ~/Library/Application Support/Coda/Modes -+ TextMate ++ TextMate (Thanks to Michael Sheets for providing us with this!) - - Unarchive Tools/Editors/Objective-J.tmbundle.zip - - Double click the generated Objective-J.tmbundle file + - Unarchive Tools/Editors/JavaScript Objective-J.tmbundle.zip + - Double click the generated "JavaScript Objective-J.tmbundle" file + ++ Vim (Thanks to Shawn MacIntyre for providing us with this!) -+ Vim - Place Tools/Editors/objj.vim in ~/.vim/syntax/ - in ~/.vimrc, add: diff --git a/Tools/Vim/objj.vim b/Tools/Vim/objj.vim new file mode 100644 index 0000000000..530fdbac87 --- /dev/null +++ b/Tools/Vim/objj.vim @@ -0,0 +1,197 @@ +" Vim syntax file +" Language: Objective-J +" Maintainer: Shawn MacIntyre +" Updaters: +" URL: +" Changes: (sm) merged javascript syntax Claudio Fleiner and Scott Shattuck and objc syntax by Kazunobu Kuriyama and Anthony Hodsdon +" Last Change: 2008 Sep 8 + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +" tuning parameters: +" unlet objj_fold + +if !exists("main_syntax") + if version < 600 + syntax clear + elseif exists("b:current_syntax") + finish + endif + let main_syntax = 'objj' +endif + +" Drop fold if it set but vim doesn't support it. +if version < 600 && exists("objj_fold") + unlet objj_fold +endif + +syn case ignore + +" objj keywords, types, type qualifiers etc. +syn keyword objjStatement self super _cmd +syn keyword objjType id Class SEL IMP BOOL +"syn keyword objjTypeModifier bycopy in out inout oneway +syn keyword objjConstant nil Nil + +" Match the objj #import directive (like C's #include) +syn region objjImported display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ +syn match objjImported display contained "<[_0-9a-zA-Z.\/]*>" +syn match objjImport display "^\s*\(%:\|#\)\s*import\>\s*["<]" contains=objjImported + +" Match the important objj directives +syn match objjScopeDecl "@public\|@private\|@protected" +syn match objjDirective "@interface\|@implementation" +syn match objjDirective "@class\|@end\|@defs" +syn match objjDirective "@encode\|@protocol\|@selector" +syn match objjDirective "@try\|@catch\|@finally\|@throw\|@synchronized" + +" Match the ObjC method types +" +" NOTE: here I match only the indicators, this looks +" much nicer and reduces cluttering color highlightings. +" However, if you prefer full method declaration matching +" append .* at the end of the next two patterns! +" +syn match objjInstMethod "^\s*-\s*" +syn match objjFactMethod "^\s*+\s*" + +" To distinguish from a header inclusion from a protocol list. +"syn match objjProtocol display "<[_a-zA-Z][_a-zA-Z0-9]*>" contains=objjType,cType,Type + + +" To distinguish labels from the keyword for a method's parameter. +syn region objjKeyForMethodParam display + \ start="^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*:\s*(" + \ end=")\s*[_a-zA-Z][_a-zA-Z0-9]*" + \ contains=objjType,Type + +" Objective-C Constant Strings +syn match objjSpecial display "%@" contained +syn region objjString start=+\(@"\|"\)+ skip=+\\\\\|\\"+ end=+"+ contains=cFormat,cSpecial,objcSpecial + +" Objective-C Message Expressions +syn region objjMessage display start="\[" end="\]" contains=objjMessage,objjStatement,objjType,objjTypeModifier,objjString,objjConstant,objjDirective + +syn cluster cParenGroup add=objjMessage +syn cluster cPreProcGroup add=objjMessage + + +syn keyword objjCommentTodo TODO FIXME XXX TBD contained +syn match objjLineComment "\/\/.*" contains=objjCommentTodo +syn match objjCommentSkip "^[ \t]*\*\($\|[ \t]\+\)" +syn region objjComment start="/\*" end="\*/" contains=objjCommentTodo +syn match objjSpecial "\\\d\d\d\|\\." +syn region objjStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=objjSpecial,@htmlPreproc +syn region objjStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=objjSpecial,@htmlPreproc + +syn match objjSpecialCharacter "'\\.'" +syn match objjNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>" +syn region objjRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gi]\{0,2\}\s*$+ end=+/[gi]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline + +syn keyword objjConditional if else switch +syn keyword objjRepeat while for do in +syn keyword objjBranch break continue +syn keyword objjOperator new delete instanceof typeof +syn keyword objjType Array Boolean Date Function Number Object String RegExp +syn keyword objjStatement return with +syn keyword objjBoolean true false +syn keyword objjNull null undefined +syn keyword objjIdentifier arguments this var +syn keyword objjLabel case default +syn keyword objjException try catch finally throw +syn keyword objjMessage alert confirm prompt status +syn keyword objjGlobal self window top parent +syn keyword objjMember document event location +syn keyword objjDeprecated escape unescape +syn keyword objjReserved abstract boolean byte char class const debugger double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile + +if exists("objj_fold") + syn match objjFunction "\" + syn region objjFunctionFold start="\.*[^};]$" end="^\z1}.*$" transparent fold keepend + + syn sync match objjSync grouphere objjFunctionFold "\" + syn sync match objjSync grouphere NONE "^}" + + setlocal foldmethod=syntax + setlocal foldtext=getline(v:foldstart) +else + syn keyword objjFunction function + syn match objjBraces "[{}\[\]]" + syn match objjParens "[()]" +endif + +syn sync fromstart +syn sync maxlines=100 + +if main_syntax == "objj" + syn sync ccomment objjComment +endif + +" Define the default highlighting. +" For version 5.7 and earlier: only when not done already +" For version 5.8 and later: only when an item doesn't have highlighting yet +if version >= 508 || !exists("did_objj_syn_inits") + if version < 508 + let did_objj_syn_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + HiLink objjComment Comment + HiLink objjLineComment Comment + HiLink objjCommentTodo Todo + HiLink objjSpecial Special + HiLink objjStringS String + HiLink objjStringD String + HiLink objjCharacter Character + HiLink objjSpecialCharacter objjSpecial + HiLink objjNumber objjValue + HiLink objjConditional Conditional + HiLink objjRepeat Repeat + HiLink objjBranch Conditional + HiLink objjOperator Operator + HiLink objjType Type + HiLink objjStatement Statement + HiLink objjFunction Function + HiLink objjBraces Function + HiLink objjError Error + HiLink javaScrParenError objjError + HiLink objjNull Keyword + HiLink objjBoolean Boolean + HiLink objjRegexpString String + + HiLink objjIdentifier Identifier + HiLink objjLabel Label + HiLink objjException Exception + HiLink objjMessage Keyword + HiLink objjGlobal Keyword + HiLink objjMember Keyword + HiLink objjDeprecated Exception + HiLink objjReserved Keyword + HiLink objjDebug Debug + HiLink objjConstant Label + + HiLink objjImport Include + HiLink objjImported String + HiLink objjTypeModifier objjType + HiLink objjType Type + HiLink objjScopeDecl Statement + HiLink objjInstMethod Function + HiLink objjFactMethod Function + HiLink objjStatement Statement + HiLink objjDirective Statement + HiLink objjKeyForMethodParam None + HiLink objjString String + HiLink objjSpecial Special + HiLink objjProtocol None + HiLink objjConstant Constant + + delcommand HiLink +endif + +let b:current_syntax = "objj" +if main_syntax == 'objj' + unlet main_syntax +endif + +" vim: ts=8 \ No newline at end of file diff --git a/Tools/objj/objj.js b/Tools/objj/objj.js index 548601e171..58188d62fb 100644 --- a/Tools/objj/objj.js +++ b/Tools/objj/objj.js @@ -27,29 +27,38 @@ else OBJJ_INCLUDE_PATHS = [OBJJ_LIB+'/Frameworks']; } -if (arguments.length > 0) -{ - var main_file = arguments[0]; - arguments.splice(0, 1); - - if (debug) - print("Loading: " + main_file); - - objj_import(main_file, NO); - - serviceTimeouts(); - - if (debug) - print("Done!"); -} -else if (typeof objj_console != "undefined") -{ - if (debug) - print("Starting Objective-J console."); - - objj_console(); -} -else -{ - print("Error: No file provided or console available.") -} +try { + if (arguments.length > 0) + { + var main_file = arguments[0]; + arguments.splice(0, 1); + + if (debug) + print("Loading: " + main_file); + + objj_import(main_file, NO); + + serviceTimeouts(); + + if (debug) + print("Done!"); + } + else if (typeof objj_console != "undefined") + { + if (debug) + print("Starting Objective-J console."); + + objj_console(); + } + else + { + print("Error: No file provided or console available.") + } +} catch (e) { + print("OBJJ EXCEPTION: " + e); + print(" Name: " + e.name); + print(" Message: " + e.message); + print(" Java: " + e.javaException); + print(" File: " + e.fileName); + print(" Line: " + e.lineNumber); +} \ No newline at end of file