From 8ee443a43c6e04391a0b04f1f315251658b03a30 Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Thu, 6 Nov 2014 10:10:05 -0800 Subject: [PATCH 01/18] NEW: @typedef and ivar type warning Previously, ObjJ was ignoring unknow ivar type. This patch adds some check to ensure the type is either a known class, the current class itself, a global, a basic JS type or a declared custom type. In order to declare custom types, this patch introduces the @typedef keyword. For instance, this will throw a warning: ```objj @import @implementation MyClass: CPObject { NUSuppaType mode; } @end ``` This will not: ```objj @import @typedef NUSuppaType @implementation NUMyClass: CPObject { NUSuppaType mode; } @end ``` Declared types are shared accross all application, one type can only be declared once. --- Objective-J/ObjJAcornCompiler.js | 82 ++++++++++++++++++++++++++++++-- Objective-J/Runtime.js | 33 +++++++++++++ Objective-J/acorn.js | 78 +++++++++++++++++++----------- Objective-J/acornwalk.js | 2 + 4 files changed, 161 insertions(+), 34 deletions(-) diff --git a/Objective-J/ObjJAcornCompiler.js b/Objective-J/ObjJAcornCompiler.js index 08b231ebe..fd6f020d3 100644 --- a/Objective-J/ObjJAcornCompiler.js +++ b/Objective-J/ObjJAcornCompiler.js @@ -353,6 +353,11 @@ ProtocolDef.prototype.getClassMethod = function(name) { return null; } +var TypeDef = function(name) +{ + this.name = name; +} + // methodDef = {"types": types, "name": selector} var MethodDef = function(name, types) { @@ -369,7 +374,7 @@ var wordPrefixOperators = exports.acorn.makePredicate("delete in instanceof new var isLogicalBinary = exports.acorn.makePredicate("LogicalExpression BinaryExpression"); var isInInstanceof = exports.acorn.makePredicate("in instanceof"); -var ObjJAcornCompiler = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags, /*unsigned*/ pass, /* Dictionary */ classDefs, /* Dictionary */ protocolDefs) +var ObjJAcornCompiler = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags, /*unsigned*/ pass, /* Dictionary */ classDefs, /* Dictionary */ protocolDefs, /* Dictionary */ typeDefs) { this.source = aString; this.URL = new CFURL(aURL); @@ -399,6 +404,7 @@ var ObjJAcornCompiler = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned* this.flags = flags | ObjJAcornCompiler.Flags.IncludeDebugSymbols; this.classDefs = classDefs ? classDefs : Object.create(null); this.protocolDefs = protocolDefs ? protocolDefs : Object.create(null); + this.typeDefs = typeDefs ? typeDefs : Object.create(null); this.lastPos = 0; if (currentCompilerFlags & ObjJAcornCompiler.Flags.Generate) this.generate = true; @@ -415,9 +421,9 @@ exports.ObjJAcornCompiler.compileToExecutable = function(/*String*/ aString, /*C return new ObjJAcornCompiler(aString, aURL, flags, 2).executable(); } -exports.ObjJAcornCompiler.compileToIMBuffer = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags, classDefs, protocolDefs) +exports.ObjJAcornCompiler.compileToIMBuffer = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags, classDefs, protocolDefs, typeDefs) { - return new ObjJAcornCompiler(aString, aURL, flags, 2, classDefs, protocolDefs).IMBuffer(); + return new ObjJAcornCompiler(aString, aURL, flags, 2, classDefs, protocolDefs, typeDefs).IMBuffer(); } exports.ObjJAcornCompiler.compileFileDependencies = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*/ flags) @@ -581,6 +587,31 @@ ObjJAcornCompiler.prototype.getProtocolDef = function(/* String */ aProtocolName // protocolDef = {"name": protocolName, "protocols": Object.create(null), "required": Object.create(null), "optional": Object.create(null)}; } +ObjJAcornCompiler.prototype.getTypeDef = function(/* String */ aTypeDefName) +{ + if (!aTypeDefName) + return null; + + var t = this.typeDefs[aTypeDefName]; + + if (t) + return t; + + if (typeof objj_getTypeDef === 'function') + { + var aTypeDef = objj_getTypeDef(aTypeDefName); + if (aTypeDef) + { + var typeDefName = typeDef_getName(aTypeDef) + t = new TypeDef(typeDefName); + this.typeDefs[typeDefName] = t; + return t; + } + } + + return null; +} + ObjJAcornCompiler.methodDefsFromMethodList = function(/* Array */ methodList) { var methodSize = methodList.length, @@ -1715,12 +1746,19 @@ ClassDeclarationStatement: function(node, st, c) { { var ivarDecl = node.ivardeclarations[i], ivarType = ivarDecl.ivartype ? ivarDecl.ivartype.name : null, + ivarTypeIsClass = ivarDecl.ivartype ? ivarDecl.ivartype.typeisclass : false, ivarName = ivarDecl.id.name, ivar = {"type": ivarType, "name": ivarName}, accessors = ivarDecl.accessors; if (ivars[ivarName]) - throw compiler.error_message("Instance variable '" + ivarName + "'is already declared for class " + className, ivarDecl.id); + throw compiler.error_message("Instance variable '" + ivarName + "' is already declared for class " + className, ivarDecl.id); + + var isTypeDefined = !ivarTypeIsClass || typeof global[ivarType] !== "undefined" || typeof window[ivarType] !== "undefined" + || compiler.getClassDef(ivarType) || compiler.getTypeDef(ivarType) || ivarType == classDef.name; + + if (!isTypeDefined) + compiler.addWarning(createMessage("Unknown type '" + ivarType + "' for ivar '" + ivarName + "'", ivarDecl.id, compiler.source)); if (firstIvarDeclaration) { @@ -1824,7 +1862,7 @@ ClassDeclarationStatement: function(node, st, c) { // Remove all @accessors or we will get a recursive loop in infinity var b = getterSetterBuffer.toString().replace(/@accessors(\(.*\))?/g, ""); - var imBuffer = ObjJAcornCompiler.compileToIMBuffer(b, "Accessors", compiler.flags, compiler.classDefs, compiler.protocolDefs); + var imBuffer = ObjJAcornCompiler.compileToIMBuffer(b, "Accessors", compiler.flags, compiler.classDefs, compiler.protocolDefs, compiler.typeDefs); // Add the accessors methods first to instance method buffer. // This will allow manually added set and get methods to override the compiler generated @@ -2393,5 +2431,39 @@ PreprocessStatement: function(node, st, c) { compiler.lastPos = node.start; compiler.jsBuffer.concat("//"); } +}, +TypeDefStatement: function(node, st, c) { + + var compiler = st.compiler, + generate = compiler.generate, + buffer = compiler.jsBuffer, + typeDefName = node.typedefname.name, + typeDef = compiler.getTypeDef(typeDefName), + typeDefScope = new Scope(st); + + if (typeDef) + throw compiler.error_message("Duplicate type definition " + typeDefName, node.typedefname); + + compiler.imBuffer = new StringBuffer(); + compiler.cmBuffer = new StringBuffer(); + + if (!generate) + buffer.concat(compiler.source.substring(compiler.lastPos, node.start)); + + buffer.concat("{var the_typedef = objj_allocateTypeDef(\"" + typeDefName + "\");"); + + typeDef = new TypeDef(typeDefName); + compiler.typeDefs[typeDefName] = typeDef; + typeDefScope.typeDef = typeDef; + + buffer.concat("\nobjj_registerTypeDef(the_typedef);\n"); + + buffer.concat("}"); + + compiler.jsBuffer = buffer; + + // Skip the "@end" + if (!generate) + compiler.lastPos = node.end; } }); diff --git a/Objective-J/Runtime.js b/Objective-J/Runtime.js index 75a43bf78..e352cf3e1 100644 --- a/Objective-J/Runtime.js +++ b/Objective-J/Runtime.js @@ -100,6 +100,11 @@ GLOBAL(objj_object) = function() this._UID = -1; } +GLOBAL(objj_typeDef) = function(/*String*/ aName) +{ + this.name = aName; +} + // Working with Classes GLOBAL(class_getName) = function(/*Class*/ aClass) @@ -440,6 +445,26 @@ GLOBAL(protocol_addProtocol) = function(/*Protocol*/ proto, /*Protocol*/ additio (proto.protocol_list || (proto.protocol_list = [])).push(addition); } + +var REGISTERED_TYPEDEFS = Object.create(null); + +GLOBAL(objj_allocateTypeDef) = function(/*String*/ aName) +{ + var typeDef = new objj_typeDef(aName); + + return typeDef; +} + +GLOBAL(objj_registerTypeDef) = function(/*TypeDef*/ typeDef) +{ + REGISTERED_TYPEDEFS[typeDef.name] = typeDef; +} + +GLOBAL(typeDef_getName) = function(/*TypeDef*/ typeDef) +{ + return typeDef.name; +} + var _class_initialize = function(/*Class*/ aClass) { var meta = GETMETA(aClass); @@ -619,6 +644,7 @@ GLOBAL(objj_resetRegisterClasses) = function() REGISTERED_CLASSES = Object.create(null); REGISTERED_PROTOCOLS = Object.create(null); + REGISTERED_TYPEDEFS = Object.create(null); resetBundle(); } @@ -751,6 +777,13 @@ GLOBAL(objj_getProtocol) = function(/*String*/ aName) return REGISTERED_PROTOCOLS[aName]; } +// Working with typeDef + +GLOBAL(objj_getTypeDef) = function(/*String*/ aName) +{ + return REGISTERED_TYPEDEFS[aName]; +} + // Working with Instance Variables GLOBAL(ivar_getName) = function(anIvar) diff --git a/Objective-J/acorn.js b/Objective-J/acorn.js index f12994057..594111ee0 100644 --- a/Objective-J/acorn.js +++ b/Objective-J/acorn.js @@ -375,12 +375,15 @@ if (typeof exports != "undefined" && !exports.acorn) { var _ref = {keyword: "ref"}, _deref = {keyword: "deref"}; var _protocol = {keyword: "protocol"}, _optional = {keyword: "optional"}, _required = {keyword: "required"}; var _interface = {keyword: "interface"}; + var _typedef = {keyword: "typedef"}; // Objective-J keywords var _filename = {keyword: "filename"}, _unsigned = {keyword: "unsigned", okAsIdent: true}, _signed = {keyword: "signed", okAsIdent: true}; var _byte = {keyword: "byte", okAsIdent: true}, _char = {keyword: "char", okAsIdent: true}, _short = {keyword: "short", okAsIdent: true}; var _int = {keyword: "int", okAsIdent: true}, _long = {keyword: "long", okAsIdent: true}, _id = {keyword: "id", okAsIdent: true}; + var _boolean = {keyword: "BOOL", okAsIdent: true}, _SEL = {keyword: "SEL", okAsIdent: true}, _float = {keyword: "float", okAsIdent: true}; + var _double = {keyword: "double", okAsIdent: true}; var _preprocess = {keyword: "#"}; // Preprocessor keywords @@ -415,14 +418,15 @@ if (typeof exports != "undefined" && !exports.acorn) { // Map Objective-J keyword names to token types. var keywordTypesObjJ = {"IBAction": _action, "IBOutlet": _outlet, "unsigned": _unsigned, "signed": _signed, "byte": _byte, "char": _char, - "short": _short, "int": _int, "long": _long, "id": _id }; + "short": _short, "int": _int, "long": _long, "id": _id, "float": _float, "BOOL": _boolean, "SEL": _SEL, + "double": _double}; // Map Objective-J "@" keyword names to token types. var objJAtKeywordTypes = {"implementation": _implementation, "outlet": _outlet, "accessors": _accessors, "end": _end, "import": _import, "action": _action, "selector": _selector, "class": _class, "global": _global, "ref": _ref, "deref": _deref, "protocol": _protocol, "optional": _optional, "required": _required, - "interface": _interface}; + "interface": _interface, "typedef": _typedef}; // Map Preprocessor keyword names to token types. @@ -547,7 +551,7 @@ if (typeof exports != "undefined" && !exports.acorn) { // The Objective-J keywords. - var isKeywordObjJ = makePredicate("IBAction IBOutlet byte char short int long unsigned signed id"); + var isKeywordObjJ = makePredicate("IBAction IBOutlet byte char short int long float unsigned signed id BOOL SEL double"); // The preprocessor keywords. @@ -662,6 +666,7 @@ var preprocessTokens = [_preIf, _preIfdef, _preIfndef, _preElse, _preElseIf, _pr } } } + tokVal = val; lastTokCommentsAfter = tokCommentsAfter; lastTokSpacesAfter = tokSpacesAfter; @@ -2277,6 +2282,15 @@ var preIfLevel = 0; } break; + // This is a Objective-J statement + case _typedef: + if (options.objj) { + next(); + node.typedefname = parseIdent(true); + return finishNode(node, "TypeDefStatement"); + } + break; + } // The indentation is one step to the right here to make sure it @@ -2317,6 +2331,7 @@ var preIfLevel = 0; if (outlet) decl.outlet = outlet; decl.ivartype = type; + // print("keyword: " + type.name + " is class " + type.typeisclass) decl.id = parseIdent(); if (strict && isStrictBadIdWord(decl.id.name)) raise(decl.id.start, "Binding " + decl.id.name + " in strict mode"); @@ -3021,6 +3036,7 @@ var preIfLevel = 0; node.typeisclass = true; next(); } else { + node.typeisclass = false; node.name = tokType.keyword; // Do nothing more if it is 'void' if (!eat(_void)) { @@ -3043,32 +3059,36 @@ var preIfLevel = 0; } else { // Now check if it is some basic type or an approved combination of basic types var nextKeyWord; - if (eat(_signed) || eat(_unsigned)) - nextKeyWord = tokType.keyword || true; - if (eat(_char) || eat(_byte) || eat(_short)) { - if (nextKeyWord) - node.name += " " + nextKeyWord; - nextKeyWord = tokType.keyword || true; - } else { - if (eat(_int)) { - if (nextKeyWord) - node.name += " " + nextKeyWord; - nextKeyWord = tokType.keyword || true; - } - if (eat(_long)) { - if (nextKeyWord) - node.name += " " + nextKeyWord; - nextKeyWord = tokType.keyword || true; - if (eat(_long)) { - node.name += " " + nextKeyWord; - } - } - } - if (!nextKeyWord) { - // It must be a class name if it was not a basic type. // FIXME: This is not true - node.name = (!options.forbidReserved && tokType.keyword) || unexpected(); - node.typeisclass = true; - next(); + if (eat(_float) || eat(_boolean) || eat(_SEL) || eat(_double)) + nextKeyWord = tokType.keyword; + else { + if (eat(_signed) || eat(_unsigned)) + nextKeyWord = tokType.keyword || true; + if (eat(_char) || eat(_byte) || eat(_short)) { + if (nextKeyWord) + node.name += " " + nextKeyWord; + nextKeyWord = tokType.keyword || true; + } else { + if (eat(_int)) { + if (nextKeyWord) + node.name += " " + nextKeyWord; + nextKeyWord = tokType.keyword || true; + } + if (eat(_long)) { + if (nextKeyWord) + node.name += " " + nextKeyWord; + nextKeyWord = tokType.keyword || true; + if (eat(_long)) { + node.name += " " + nextKeyWord; + } + } + } + if (!nextKeyWord) { + // It must be a class name if it was not a basic type. // FIXME: This is not true + node.name = (!options.forbidReserved && tokType.keyword) || unexpected(); + node.typeisclass = true; + next(); + } } } } diff --git a/Objective-J/acornwalk.js b/Objective-J/acornwalk.js index 87753e3f4..8d5666529 100644 --- a/Objective-J/acornwalk.js +++ b/Objective-J/acornwalk.js @@ -221,6 +221,8 @@ if (!exports.acorn) { } } + exports.TypeDefStatement = ignore; + exports.MethodDeclarationStatement = function(node, st, c) { var body = node.body; if (body) From f9275a70afe88236fb6cbe8c90c749ccdf8bb02b Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Thu, 6 Nov 2014 10:17:05 -0800 Subject: [PATCH 02/18] FIXED: New warnings reveleaded by ivar type checking This patch fixes all new warnings --- AppKit/CPAlert.j | 97 +++--- AppKit/CPAnimation.j | 17 +- AppKit/CPApplication.j | 2 + AppKit/CPArrayController.j | 2 +- AppKit/CPBox.j | 3 + AppKit/CPButton.j | 4 +- AppKit/CPCollectionView.j | 1 + AppKit/CPColorPanel.j | 3 + AppKit/CPColorPicker.j | 2 + AppKit/CPComboBox.j | 2 +- AppKit/CPControl.j | 6 + AppKit/CPDatePicker/_CPDatePickerCalendar.j | 2 + AppKit/CPDatePicker/_CPDatePickerTextField.j | 6 +- AppKit/CPDragServer_Constants.j | 1 + AppKit/CPEvent.j | 5 + AppKit/CPImageView.j | 1 + AppKit/CPKeyValueBinding.j | 1 + AppKit/CPLevelIndicator.j | 2 + AppKit/CPMenu/_CPMenuBarWindow.j | 1 + AppKit/CPMenu/_CPMenuWindow.j | 2 + AppKit/CPMenuItem/_CPMenuItemMenuBarView.j | 1 + AppKit/CPMenuItem/_CPMenuItemStandardView.j | 3 + AppKit/CPMenuItem/_CPMenuItemView.j | 1 + AppKit/CPPasteboard.j | 3 +- AppKit/CPProgressIndicator.j | 1 + AppKit/CPRadio.j | 2 + AppKit/CPResponder.j | 1 + AppKit/CPRuleEditor/CPRuleEditor_Constants.j | 2 + AppKit/CPRuleEditor/_CPPredicateEditorTree.j | 2 + AppKit/CPRuleEditor/_CPRuleEditorViewSlice.j | 2 + .../CPRuleEditor/_CPRuleEditorViewSliceRow.j | 2 + AppKit/CPScroller.j | 2 + AppKit/CPSegmentedControl.j | 1 + AppKit/CPShadowView.j | 2 +- AppKit/CPTabView.j | 1 + AppKit/CPTabViewItem.j | 2 +- AppKit/CPTableColumn.j | 1 + AppKit/CPTableView.j | 3 +- AppKit/CPTextField.j | 1 + AppKit/CPTheme.j | 1 + AppKit/CPTokenField.j | 3 + AppKit/CPToolbar.j | 4 +- AppKit/CPView.j | 3 + AppKit/CPWebView.j | 2 +- AppKit/CPWindow/CPWindow.j | 6 + AppKit/CPWindow/CPWindow_Constants.j | 2 + AppKit/CoreGraphics/CGAffineTransform.j | 2 + AppKit/CoreGraphics/CGColorSpace.j | 2 + AppKit/CoreGraphics/CGContext.j | 1 + AppKit/CoreGraphics/CGGradient.j | 1 + AppKit/CoreGraphics/CGPath.j | 3 +- AppKit/Platform/CPPlatformWindow.j | 3 + AppKit/_CPImageAndTextView.j | 2 +- AppKit/_CPPopUpList.j | 214 ++++++------- AppKit/_CPToolbarItem.j | 1 + Foundation/CPDateFormatter.j | 2 + Foundation/CPDecimal.j | 3 + Foundation/CPDictionary.j | 66 ++-- Foundation/CPGeometry.j | 1 + Foundation/CPJSONPConnection.j | 1 + Foundation/CPNotificationCenter.j | 291 +++++++++--------- Foundation/CPNumberFormatter.j | 3 +- Foundation/CPObject.j | 4 +- .../CPPredicate/CPComparisonPredicate.j | 4 +- Foundation/CPPredicate/CPCompoundPredicate.j | 2 +- Foundation/CPRange.j | 2 + Foundation/CPURLConnection.j | 2 + Foundation/CPUndoManager.j | 2 +- Foundation/CPUserSessionManager.j | 1 + Foundation/_CGGeometry.j | 6 + Foundation/_CPTypeDefinitions.j | 30 ++ 71 files changed, 496 insertions(+), 367 deletions(-) create mode 100644 Foundation/_CPTypeDefinitions.j diff --git a/AppKit/CPAlert.j b/AppKit/CPAlert.j index cbd40cfe6..2dec01211 100644 --- a/AppKit/CPAlert.j +++ b/AppKit/CPAlert.j @@ -44,6 +44,7 @@ var CPAlertDelegate_alertShowHelp_ = 1 << 0, CPAlertDelegate_alertDidEnd_returnCode_ = 1 << 1; +@typedef CPAlertStyle /* @global @group CPAlertStyle @@ -70,6 +71,54 @@ var bottomHeight = 71; @end + +@implementation _CPAlertThemeView : CPView + ++ (CPString)defaultThemeClass +{ + return @"alert"; +} + ++ (CPDictionary)themeAttributes +{ + return @{ + @"size": CGSizeMake(400.0, 110.0), + @"content-inset": CGInsetMake(15, 15, 15, 50), + @"informative-offset": 6, + @"button-offset": 10, + @"message-text-alignment": CPJustifiedTextAlignment, + @"message-text-color": [CPColor blackColor], + @"message-text-font": [CPFont boldSystemFontOfSize:13.0], + @"message-text-shadow-color": [CPNull null], + @"message-text-shadow-offset": CGSizeMakeZero(), + @"informative-text-alignment": CPJustifiedTextAlignment, + @"informative-text-color": [CPColor blackColor], + @"informative-text-font": [CPFont systemFontOfSize:12.0], + @"informative-text-shadow-color": [CPNull null], + @"informative-text-shadow-offset": CGSizeMakeZero(), + @"image-offset": CGPointMake(15, 12), + @"information-image": [CPNull null], + @"warning-image": [CPNull null], + @"error-image": [CPNull null], + @"help-image": [CPNull null], + @"help-image-left-offset": 15, + @"help-image-pressed": [CPNull null], + @"suppression-button-y-offset": 0.0, + @"suppression-button-x-offset": 0.0, + @"default-elements-margin": 3.0, + @"suppression-button-text-color": [CPColor blackColor], + @"suppression-button-text-font": [CPFont systemFontOfSize:12.0], + @"suppression-button-text-shadow-color": [CPNull null], + @"suppression-button-text-shadow-offset": 0.0, + @"modal-window-button-margin-y": 0.0, + @"modal-window-button-margin-x": 0.0, + @"standard-window-button-margin-y": 0.0, + @"standard-window-button-margin-x": 0.0, + }; +} + +@end + /*! @ingroup appkit @@ -813,51 +862,3 @@ var bottomHeight = 71; } @end - - -@implementation _CPAlertThemeView : CPView - -+ (CPString)defaultThemeClass -{ - return @"alert"; -} - -+ (CPDictionary)themeAttributes -{ - return @{ - @"size": CGSizeMake(400.0, 110.0), - @"content-inset": CGInsetMake(15, 15, 15, 50), - @"informative-offset": 6, - @"button-offset": 10, - @"message-text-alignment": CPJustifiedTextAlignment, - @"message-text-color": [CPColor blackColor], - @"message-text-font": [CPFont boldSystemFontOfSize:13.0], - @"message-text-shadow-color": [CPNull null], - @"message-text-shadow-offset": CGSizeMakeZero(), - @"informative-text-alignment": CPJustifiedTextAlignment, - @"informative-text-color": [CPColor blackColor], - @"informative-text-font": [CPFont systemFontOfSize:12.0], - @"informative-text-shadow-color": [CPNull null], - @"informative-text-shadow-offset": CGSizeMakeZero(), - @"image-offset": CGPointMake(15, 12), - @"information-image": [CPNull null], - @"warning-image": [CPNull null], - @"error-image": [CPNull null], - @"help-image": [CPNull null], - @"help-image-left-offset": 15, - @"help-image-pressed": [CPNull null], - @"suppression-button-y-offset": 0.0, - @"suppression-button-x-offset": 0.0, - @"default-elements-margin": 3.0, - @"suppression-button-text-color": [CPColor blackColor], - @"suppression-button-text-font": [CPFont systemFontOfSize:12.0], - @"suppression-button-text-shadow-color": [CPNull null], - @"suppression-button-text-shadow-offset": 0.0, - @"modal-window-button-margin-y": 0.0, - @"modal-window-button-margin-x": 0.0, - @"standard-window-button-margin-y": 0.0, - @"standard-window-button-margin-x": 0.0, - }; -} - -@end diff --git a/AppKit/CPAnimation.j b/AppKit/CPAnimation.j index 903cf3c2e..bef308b74 100644 --- a/AppKit/CPAnimation.j +++ b/AppKit/CPAnimation.j @@ -42,25 +42,10 @@ var CPAnimationDelegate_animationShouldStart_ = 1 << 1, CPAnimationDelegate_animationDidEnd_ = 1 << 3, CPAnimationDelegate_animationDidStop_ = 1 << 4; -/* - @global - @group CPAnimationCurve -*/ +@typedef CPAnimationCurve CPAnimationEaseInOut = 0; -/* - @global - @group CPAnimationCurve -*/ CPAnimationEaseIn = 1; -/* - @global - @group CPAnimationCurve -*/ CPAnimationEaseOut = 2; -/* - @global - @group CPAnimationCurve -*/ CPAnimationLinear = 3; ACTUAL_FRAME_RATE = 0; diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index f3783c75a..85e57a84f 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -37,6 +37,8 @@ @import "CPWindowController.j" @import "_CPPopoverWindow.j" +@typedef CPModalSession + var CPMainCibFile = @"CPMainCibFile", CPMainCibFileHumanFriendly = @"Main cib file base name", CPEventModifierFlags = 0; diff --git a/AppKit/CPArrayController.j b/AppKit/CPArrayController.j index 0b25334d9..67e2f681e 100644 --- a/AppKit/CPArrayController.j +++ b/AppKit/CPArrayController.j @@ -23,7 +23,7 @@ */ @import - +@import @import "CPObjectController.j" @import "CPKeyValueBinding.j" diff --git a/AppKit/CPBox.j b/AppKit/CPBox.j index dc10564ff..29d0b3a08 100644 --- a/AppKit/CPBox.j +++ b/AppKit/CPBox.j @@ -24,6 +24,7 @@ @import "CPView.j" // CPBoxType +@typedef CPBoxType CPBoxPrimary = 0; CPBoxSecondary = 1; CPBoxSeparator = 2; @@ -31,12 +32,14 @@ CPBoxOldStyle = 3; CPBoxCustom = 4; // CPBorderType +@typedef CPBorderType CPNoBorder = 0; CPLineBorder = 1; CPBezelBorder = 2; CPGrooveBorder = 3; // CPTitlePosition +@typedef CPTitlePosition CPNoTitle = 0; CPAboveTop = 1; CPAtTop = 2; diff --git a/AppKit/CPButton.j b/AppKit/CPButton.j index 8365d76c7..26c17edaa 100644 --- a/AppKit/CPButton.j +++ b/AppKit/CPButton.j @@ -29,8 +29,7 @@ @import "CPWindow_Constants.j" /* @group CPBezelStyle */ - - // IB style +@typedef CPBezelStyle CPRoundedBezelStyle = 1; // Push CPRegularSquareBezelStyle = 2; // Bevel CPThickSquareBezelStyle = 3; @@ -49,6 +48,7 @@ CPHUDBezelStyle = -1; /* @group CPButtonType */ +@typedef CPButtonType CPMomentaryLightButton = 0; CPPushOnPushOffButton = 1; CPToggleButton = 2; diff --git a/AppKit/CPCollectionView.j b/AppKit/CPCollectionView.j index 2da7f07d9..943c05a30 100644 --- a/AppKit/CPCollectionView.j +++ b/AppKit/CPCollectionView.j @@ -32,6 +32,7 @@ @import "CPPasteboard.j" @import "CPView.j" +@class _CPCollectionViewDropIndicator var CPCollectionViewDelegate_collectionView_acceptDrop_index_dropOperation_ = 1 << 0, CPCollectionViewDelegate_collectionView_canDragItemsAtIndexes_withEvent_ = 1 << 1, diff --git a/AppKit/CPColorPanel.j b/AppKit/CPColorPanel.j index af6bf3e1d..7d847a30f 100644 --- a/AppKit/CPColorPanel.j +++ b/AppKit/CPColorPanel.j @@ -27,6 +27,9 @@ @import "CPView.j" @class CPSlider +@class _CPColorPanelToolbar +@class _CPColorPanelSwatches +@class _CPColorPanelPreview @global CPApp diff --git a/AppKit/CPColorPicker.j b/AppKit/CPColorPicker.j index 14aed7793..ea3afcd88 100644 --- a/AppKit/CPColorPicker.j +++ b/AppKit/CPColorPicker.j @@ -25,6 +25,8 @@ @import "CPView.j" @class CPSlider +@class CPColorPanel +@class __CPColorWheel @global CPColorPickerViewWidth @global CPColorPickerViewHeight diff --git a/AppKit/CPComboBox.j b/AppKit/CPComboBox.j index b8a4481b8..01d424664 100644 --- a/AppKit/CPComboBox.j +++ b/AppKit/CPComboBox.j @@ -63,7 +63,7 @@ var CPComboBoxTextSubview = @"text", { CPArray _items; _CPPopUpList _listDelegate; - CPComboBoxDataSource _dataSource; + id _dataSource; BOOL _usesDataSource; BOOL _completes; BOOL _canComplete; diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j index c2b1083ce..c6b96ef73 100644 --- a/AppKit/CPControl.j +++ b/AppKit/CPControl.j @@ -42,16 +42,19 @@ @end +@typedef CPTextAlignment CPLeftTextAlignment = 0; CPRightTextAlignment = 1; CPCenterTextAlignment = 2; CPJustifiedTextAlignment = 3; CPNaturalTextAlignment = 4; +@typedef CPControlSize CPRegularControlSize = 0; CPSmallControlSize = 1; CPMiniControlSize = 2; +@typedef CPLineBreakMode CPLineBreakByWordWrapping = 0; CPLineBreakByCharWrapping = 1; CPLineBreakByClipping = 2; @@ -59,11 +62,13 @@ CPLineBreakByTruncatingHead = 3; CPLineBreakByTruncatingTail = 4; CPLineBreakByTruncatingMiddle = 5; +@typedef CPVerticalTextAlignment CPTopVerticalTextAlignment = 1; CPCenterVerticalTextAlignment = 2; CPBottomVerticalTextAlignment = 3; // Deprecated for use with images, use the CPImageScale constants +@typedef CPImageScaling CPScaleProportionally = 0; CPScaleToFit = 1; CPScaleNone = 2; @@ -73,6 +78,7 @@ CPImageScaleAxesIndependently = 1; CPImageScaleNone = 2; CPImageScaleProportionallyUpOrDown = 3; +@typedef CPCellImagePosition CPNoImage = 0; CPImageOnly = 1; CPImageLeft = 2; diff --git a/AppKit/CPDatePicker/_CPDatePickerCalendar.j b/AppKit/CPDatePicker/_CPDatePickerCalendar.j index 8ebd1ee8c..481bc6ba7 100644 --- a/AppKit/CPDatePicker/_CPDatePickerCalendar.j +++ b/AppKit/CPDatePicker/_CPDatePickerCalendar.j @@ -29,6 +29,8 @@ @import @class CPDatePicker +@class _CPDatePickerMonthView +@class _CPDatePickerHeaderView @global CPApp @global CPSingleDateMode diff --git a/AppKit/CPDatePicker/_CPDatePickerTextField.j b/AppKit/CPDatePicker/_CPDatePickerTextField.j index 39935b536..8fa09afce 100644 --- a/AppKit/CPDatePicker/_CPDatePickerTextField.j +++ b/AppKit/CPDatePicker/_CPDatePickerTextField.j @@ -31,6 +31,10 @@ @import @class CPDatePicker +@class _CPDatePickerElementTextField +@class _CPDatePickerElementView +@class _CPDatePickerMonthView +@class _CPDatePickerHeaderView @global CPSingleDateMode @global CPRangeDateMode @@ -1847,4 +1851,4 @@ var CPMonthDateType = 0, return CGRectMakeCopy(bounds); } -@end \ No newline at end of file +@end diff --git a/AppKit/CPDragServer_Constants.j b/AppKit/CPDragServer_Constants.j index 38ade5c31..7a347d3d4 100644 --- a/AppKit/CPDragServer_Constants.j +++ b/AppKit/CPDragServer_Constants.j @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +@typedef CPDragOperation CPDragOperationNone = 0; CPDragOperationCopy = 1 << 1; CPDragOperationLink = 1 << 1; diff --git a/AppKit/CPEvent.j b/AppKit/CPEvent.j index 8dbd7b720..d0ab4e128 100644 --- a/AppKit/CPEvent.j +++ b/AppKit/CPEvent.j @@ -31,9 +31,14 @@ @import "CPText.j" @class CPTextField +@class CPWindow @global CPApp +@typedef DOMEvent +@typedef CPEventType + + var _CPEventPeriodicEventPeriod = 0, _CPEventPeriodicEventTimer = nil, _CPEventUpperCaseRegex = new RegExp("[A-Z]"), diff --git a/AppKit/CPImageView.j b/AppKit/CPImageView.j index 1c4ef8dbc..6c041fdea 100644 --- a/AppKit/CPImageView.j +++ b/AppKit/CPImageView.j @@ -29,6 +29,7 @@ @global CPImagesPboardType @global appkit_tag_dom_elements +@typedef CPImageAlignment CPImageAlignCenter = 0; CPImageAlignTop = 1; CPImageAlignTopLeft = 2; diff --git a/AppKit/CPKeyValueBinding.j b/AppKit/CPKeyValueBinding.j index 1913a4436..662280d16 100644 --- a/AppKit/CPKeyValueBinding.j +++ b/AppKit/CPKeyValueBinding.j @@ -35,6 +35,7 @@ var exposedBindingsMap = @{}, bindingsMap = @{}; +@typedef CPBindingOperationKind var CPBindingOperationAnd = 0, CPBindingOperationOr = 1; diff --git a/AppKit/CPLevelIndicator.j b/AppKit/CPLevelIndicator.j index 07ce720c3..c4e6422ee 100644 --- a/AppKit/CPLevelIndicator.j +++ b/AppKit/CPLevelIndicator.j @@ -25,11 +25,13 @@ @global CPApp +@typedef CPTickMarkPosition CPTickMarkBelow = 0; CPTickMarkAbove = 1; CPTickMarkLeft = CPTickMarkAbove; CPTickMarkRight = CPTickMarkBelow; +@typedef CPLevelIndicatorStyle CPRelevancyLevelIndicatorStyle = 0; CPContinuousCapacityLevelIndicatorStyle = 1; CPDiscreteCapacityLevelIndicatorStyle = 2; diff --git a/AppKit/CPMenu/_CPMenuBarWindow.j b/AppKit/CPMenu/_CPMenuBarWindow.j index 2c6c2bcaa..db9077b06 100644 --- a/AppKit/CPMenu/_CPMenuBarWindow.j +++ b/AppKit/CPMenu/_CPMenuBarWindow.j @@ -24,6 +24,7 @@ @import "_CPMenuManager.j" @class _CPMenuView +@class CPMenu @global CPMenuDidAddItemNotification @global CPMenuDidChangeItemNotification diff --git a/AppKit/CPMenu/_CPMenuWindow.j b/AppKit/CPMenu/_CPMenuWindow.j index ddf53a7dd..b11522d99 100644 --- a/AppKit/CPMenu/_CPMenuWindow.j +++ b/AppKit/CPMenu/_CPMenuWindow.j @@ -25,6 +25,8 @@ @import "CPWindow.j" @import "_CPMenuManager.j" +@class _CPMenuView + var _CPMenuWindowPool = [], _CPMenuWindowPoolCapacity = 5, diff --git a/AppKit/CPMenuItem/_CPMenuItemMenuBarView.j b/AppKit/CPMenuItem/_CPMenuItemMenuBarView.j index 265b78867..e6b209f7b 100644 --- a/AppKit/CPMenuItem/_CPMenuItemMenuBarView.j +++ b/AppKit/CPMenuItem/_CPMenuItemMenuBarView.j @@ -25,6 +25,7 @@ @class _CPMenuBarWindow @class _CPMenuView +@class CPMenuItem @implementation _CPMenuItemMenuBarView : CPView { diff --git a/AppKit/CPMenuItem/_CPMenuItemStandardView.j b/AppKit/CPMenuItem/_CPMenuItemStandardView.j index 2fc534b24..f7112befb 100644 --- a/AppKit/CPMenuItem/_CPMenuItemStandardView.j +++ b/AppKit/CPMenuItem/_CPMenuItemStandardView.j @@ -24,6 +24,9 @@ @import "CPImageView.j" @import "_CPImageAndTextView.j" +@class CPMenuItem + + @implementation _CPMenuItemStandardView : CPView { CPMenuItem _menuItem @accessors(property=menuItem); diff --git a/AppKit/CPMenuItem/_CPMenuItemView.j b/AppKit/CPMenuItem/_CPMenuItemView.j index 7156db2ed..8d6b8b2cf 100644 --- a/AppKit/CPMenuItem/_CPMenuItemView.j +++ b/AppKit/CPMenuItem/_CPMenuItemView.j @@ -26,6 +26,7 @@ @import "_CPMenuItemStandardView.j" @import "_CPMenuItemMenuBarView.j" +@class CPMenuItem @global CPApp /* diff --git a/AppKit/CPPasteboard.j b/AppKit/CPPasteboard.j index e93d1ddfa..8f5c4f754 100644 --- a/AppKit/CPPasteboard.j +++ b/AppKit/CPPasteboard.j @@ -26,6 +26,7 @@ @import @import +@typedef CPWebScriptObject CPGeneralPboard = @"CPGeneralPboard"; CPFontPboard = @"CPFontPboard"; @@ -66,7 +67,7 @@ var CPPasteboards = nil, unsigned _changeCount; CPString _stateUID; - WebScriptObject _nativePasteboard; + CPWebScriptObject _nativePasteboard; } /* diff --git a/AppKit/CPProgressIndicator.j b/AppKit/CPProgressIndicator.j index e0ea06ab4..3732c229b 100644 --- a/AppKit/CPProgressIndicator.j +++ b/AppKit/CPProgressIndicator.j @@ -26,6 +26,7 @@ @import "CPWindow_Constants.j" +@typedef CPProgressIndicatorStyle /* @global @group CPProgressIndicatorStyle diff --git a/AppKit/CPRadio.j b/AppKit/CPRadio.j index 8cf37cc3d..bb845aef3 100644 --- a/AppKit/CPRadio.j +++ b/AppKit/CPRadio.j @@ -25,6 +25,8 @@ @import "CPButton.j" +@class CPRadioGroup + @global CPApp diff --git a/AppKit/CPResponder.j b/AppKit/CPResponder.j index 08e3db3ac..eddf8b628 100644 --- a/AppKit/CPResponder.j +++ b/AppKit/CPResponder.j @@ -26,6 +26,7 @@ @import "CPEvent.j" @class CPKeyBinding +@class CPMenu CPDeleteKeyCode = 8; CPTabKeyCode = 9; diff --git a/AppKit/CPRuleEditor/CPRuleEditor_Constants.j b/AppKit/CPRuleEditor/CPRuleEditor_Constants.j index d68b6f48a..0870aedeb 100644 --- a/AppKit/CPRuleEditor/CPRuleEditor_Constants.j +++ b/AppKit/CPRuleEditor/CPRuleEditor_Constants.j @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + CPRuleEditorPredicateLeftExpression = "CPRuleEditorPredicateLeftExpression"; CPRuleEditorPredicateRightExpression = "CPRuleEditorPredicateRightExpression"; CPRuleEditorPredicateComparisonModifier = "CPRuleEditorPredicateComparisonModifier"; @@ -36,5 +37,6 @@ CPRuleEditorNestingModeList = 1; // Allows a single list, with no nes CPRuleEditorNestingModeCompound = 2; // Unlimited nesting and compound rows; this is the default CPRuleEditorNestingModeSimple = 3; // One compound row at the top with subrows beneath it, and no further nesting allowed +@typedef CPRuleEditorRowType CPRuleEditorRowTypeSimple = 0; CPRuleEditorRowTypeCompound = 1; diff --git a/AppKit/CPRuleEditor/_CPPredicateEditorTree.j b/AppKit/CPRuleEditor/_CPPredicateEditorTree.j index f0d47086f..8cb807a84 100644 --- a/AppKit/CPRuleEditor/_CPPredicateEditorTree.j +++ b/AppKit/CPRuleEditor/_CPPredicateEditorTree.j @@ -20,6 +20,8 @@ @import @import +@class CPPredicateEditorRowTemplate + @implementation _CPPredicateEditorTree : CPObject { CPPredicateEditorRowTemplate template @accessors; diff --git a/AppKit/CPRuleEditor/_CPRuleEditorViewSlice.j b/AppKit/CPRuleEditor/_CPRuleEditorViewSlice.j index 39a6a1d47..2cec0efae 100644 --- a/AppKit/CPRuleEditor/_CPRuleEditorViewSlice.j +++ b/AppKit/CPRuleEditor/_CPRuleEditorViewSlice.j @@ -19,6 +19,8 @@ @import "CPView.j" +@class CPRuleEditor + @implementation _CPRuleEditorViewSlice : CPView { CPRuleEditor _ruleEditor; diff --git a/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j b/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j index 30470d5c6..d11eceb64 100644 --- a/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j +++ b/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j @@ -24,6 +24,8 @@ @import "CPDatePicker.j" @import "CPPopUpButton.j" +@class CPRuleEditorRowType + @global CPApp @global CPMiniControlSize @global CPSmallControlSize diff --git a/AppKit/CPScroller.j b/AppKit/CPScroller.j index efb3f5b2e..f293b34dd 100644 --- a/AppKit/CPScroller.j +++ b/AppKit/CPScroller.j @@ -33,6 +33,7 @@ @global CPApp // CPScroller Constants +@typedef CPScrollerPart CPScrollerNoPart = 0; CPScrollerDecrementPage = 1; CPScrollerKnob = 2; @@ -44,6 +45,7 @@ CPScrollerKnobSlot = 6; CPScrollerIncrementArrow = 0; CPScrollerDecrementArrow = 1; +@typedef CPUsableScrollerParts CPNoScrollerParts = 0; CPOnlyScrollerArrows = 1; CPAllScrollerParts = 2; diff --git a/AppKit/CPSegmentedControl.j b/AppKit/CPSegmentedControl.j index e95993152..e58d97ef1 100644 --- a/AppKit/CPSegmentedControl.j +++ b/AppKit/CPSegmentedControl.j @@ -28,6 +28,7 @@ @global CPApp +@typedef CPSegmentSwitchTracking CPSegmentSwitchTrackingSelectOne = 0; CPSegmentSwitchTrackingSelectAny = 1; CPSegmentSwitchTrackingMomentary = 2; diff --git a/AppKit/CPShadowView.j b/AppKit/CPShadowView.j index 5fcc5c26c..c6c223705 100644 --- a/AppKit/CPShadowView.j +++ b/AppKit/CPShadowView.j @@ -26,7 +26,7 @@ @import "CPImage.j" @import "CPView.j" - +@typedef CPShadowWeight CPLightShadow = 0; CPHeavyShadow = 1; diff --git a/AppKit/CPTabView.j b/AppKit/CPTabView.j index 75f1d1ad5..ec145d802 100644 --- a/AppKit/CPTabView.j +++ b/AppKit/CPTabView.j @@ -25,6 +25,7 @@ @import "CPTabViewItem.j" @import "CPView.j" +@typedef CPTabViewType CPTopTabsBezelBorder = 0; //CPLeftTabsBezelBorder = 1; CPBottomTabsBezelBorder = 2; diff --git a/AppKit/CPTabViewItem.j b/AppKit/CPTabViewItem.j index 6c073b1d0..671d5bc78 100644 --- a/AppKit/CPTabViewItem.j +++ b/AppKit/CPTabViewItem.j @@ -23,7 +23,7 @@ @import @import "CPView.j" - +@class CPTabView /* The tab is currently selected. diff --git a/AppKit/CPTableColumn.j b/AppKit/CPTableColumn.j index 951cf45e4..e0f944a8e 100644 --- a/AppKit/CPTableColumn.j +++ b/AppKit/CPTableColumn.j @@ -31,6 +31,7 @@ @global CPTableViewColumnDidResizeNotification @class _CPTableColumnHeaderView +@class CPTableView CPTableColumnNoResizing = 0; CPTableColumnAutoresizingMask = 1 << 0; diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 48157b537..e0961f6fa 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -42,6 +42,7 @@ @class CPTableHeaderView @class CPClipView @class CPButton +@class _CPDropOperationDrawingView @global CPApp @@ -170,7 +171,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; @implementation _CPTableDrawView : CPView { - CPTableView _tableView; + id _tableView; } - (id)initWithTableView:(CPTableView)aTableView diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 5f11f1d6e..28420db70 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -41,6 +41,7 @@ var CPTextFieldDelegate_control_didFailToFormatString_errorDescription_ = 1 << 1; +@typedef CPTextFieldBezelStyle CPTextFieldSquareBezel = 0; /*! A textfield bezel with squared corners. */ CPTextFieldRoundedBezel = 1; /*! A textfield bezel with rounded corners. */ diff --git a/AppKit/CPTheme.j b/AppKit/CPTheme.j index f87c3a2a2..426c462ca 100644 --- a/AppKit/CPTheme.j +++ b/AppKit/CPTheme.j @@ -26,6 +26,7 @@ @import @class CPView +@class _CPThemeAttribute var CPThemesByName = { }, CPThemeDefaultTheme = nil, diff --git a/AppKit/CPTokenField.j b/AppKit/CPTokenField.j index cc4b96765..705435aae 100644 --- a/AppKit/CPTokenField.j +++ b/AppKit/CPTokenField.j @@ -33,6 +33,9 @@ @import "CPTextField.j" @import "CPWindow_Constants.j" +@class _CPTokenFieldTokenCloseButton +@class _CPTokenFieldTokenDisclosureButton + @global CPApp @global CPTextFieldDidFocusNotification @global CPTextFieldDidBlurNotification diff --git a/AppKit/CPToolbar.j b/AppKit/CPToolbar.j index 3cc711518..49c78924e 100644 --- a/AppKit/CPToolbar.j +++ b/AppKit/CPToolbar.j @@ -37,6 +37,8 @@ var CPToolbarDelegate_toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar_ CPToolbarDelegate_toolbarSelectableItemIdentifiers_ = 1 << 4, CPToolbarDelegate_toolbarWillAddItem_ = 1 << 5; + +@typedef CPToolbarDisplayMode /* @global @group CPToolbarDisplayMode @@ -58,7 +60,7 @@ CPToolbarDisplayModeIconOnly = 2; */ CPToolbarDisplayModeLabelOnly = 3; - +@typedef CPToolbarSizeMode CPToolbarSizeModeDefault = 0; CPToolbarSizeModeRegular = 1; CPToolbarSizeModeSmall = 2; diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 1a600667c..70068d668 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -40,9 +40,12 @@ @class CPMenu @class CPClipView @class CPScrollView +@class CALayer @global appkit_tag_dom_elements +@typedef _CPViewFullScreenModeState + #if PLATFORM(DOM) if (typeof(appkit_tag_dom_elements) !== "undefined" && appkit_tag_dom_elements) diff --git a/AppKit/CPWebView.j b/AppKit/CPWebView.j index 98cc59caa..3f2ca713e 100644 --- a/AppKit/CPWebView.j +++ b/AppKit/CPWebView.j @@ -93,7 +93,7 @@ CPWebViewAppKitScrollMaxPollCount = 3; CPScrollView _scrollView; CPView _frameView; - IFrame _iframe; + DOMElement _iframe; CPString _mainFrameURL; CPArray _backwardStack; CPArray _forwardStack; diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index f770fc642..21a1b3f2d 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -50,9 +50,15 @@ @class CPMenu @class CPProgressIndicator +@class CPToolbar +@class CPWindowController +@class _CPWindowFrameAnimation @global CPApp +@typedef _CPWindowFullPlatformWindowSession + + @protocol CPWindowDelegate @optional diff --git a/AppKit/CPWindow/CPWindow_Constants.j b/AppKit/CPWindow/CPWindow_Constants.j index a9a2c3327..0caf4de78 100644 --- a/AppKit/CPWindow/CPWindow_Constants.j +++ b/AppKit/CPWindow/CPWindow_Constants.j @@ -81,6 +81,7 @@ CPWindowMinYMargin = 8; CPWindowHeightSizable = 16; CPWindowMaxYMargin = 32; +@typedef CPWindowLevel CPBackgroundWindowLevel = -1; /* Default level for windows @@ -143,6 +144,7 @@ CPDraggingWindowLevel = 500; */ CPScreenSaverWindowLevel = 1000; +@typedef CPWindowOrderingMode /* The receiver is placed directly in front of the window specified. @global diff --git a/AppKit/CoreGraphics/CGAffineTransform.j b/AppKit/CoreGraphics/CGAffineTransform.j index b73f26f07..0cfb36bcf 100644 --- a/AppKit/CoreGraphics/CGAffineTransform.j +++ b/AppKit/CoreGraphics/CGAffineTransform.j @@ -22,6 +22,8 @@ @import "CGGeometry.j" +@typedef CGAffineTransform + function CGAffineTransformMake(a, b, c, d, tx, ty) { diff --git a/AppKit/CoreGraphics/CGColorSpace.j b/AppKit/CoreGraphics/CGColorSpace.j index 9502a0703..e5d7673e8 100644 --- a/AppKit/CoreGraphics/CGColorSpace.j +++ b/AppKit/CoreGraphics/CGColorSpace.j @@ -20,6 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +@typedef CGColorSpace + kCGColorSpaceModelUnknown = -1; kCGColorSpaceModelMonochrome = 0; kCGColorSpaceModelRGB = 1; diff --git a/AppKit/CoreGraphics/CGContext.j b/AppKit/CoreGraphics/CGContext.j index c0b43eabd..a00199586 100644 --- a/AppKit/CoreGraphics/CGContext.j +++ b/AppKit/CoreGraphics/CGContext.j @@ -25,6 +25,7 @@ @import "CGGeometry.j" @import "CGPath.j" +@typedef CGContext kCGLineCapButt = 0; kCGLineCapRound = 1; diff --git a/AppKit/CoreGraphics/CGGradient.j b/AppKit/CoreGraphics/CGGradient.j index 3681c086e..aea212219 100644 --- a/AppKit/CoreGraphics/CGGradient.j +++ b/AppKit/CoreGraphics/CGGradient.j @@ -23,6 +23,7 @@ @import "CGColor.j" @import "CGColorSpace.j" +@typedef CGGradient kCGGradientDrawsBeforeStartLocation = 1 << 0; kCGGradientDrawsAfterEndLocation = 1 << 1; diff --git a/AppKit/CoreGraphics/CGPath.j b/AppKit/CoreGraphics/CGPath.j index 45c5d9062..b7cea5164 100644 --- a/AppKit/CoreGraphics/CGPath.j +++ b/AppKit/CoreGraphics/CGPath.j @@ -23,6 +23,7 @@ @import "CGAffineTransform.j" @import "CGGeometry.j" +@typedef CGPath kCGPathElementMoveToPoint = 0; kCGPathElementAddLineToPoint = 1; @@ -629,4 +630,4 @@ function CGPathContainsPoint(aPath, aTransform, point, eoFill) /*! @} -*/ \ No newline at end of file +*/ diff --git a/AppKit/Platform/CPPlatformWindow.j b/AppKit/Platform/CPPlatformWindow.j index 628293117..3e2ff2817 100644 --- a/AppKit/Platform/CPPlatformWindow.j +++ b/AppKit/Platform/CPPlatformWindow.j @@ -27,9 +27,12 @@ @class CPMenu @class CPPlatformPasteboard +@class CPWindow @global CPApp +@typedef DOMWindow + var PrimaryPlatformWindow = NULL; @implementation CPPlatformWindow : CPObject diff --git a/AppKit/_CPImageAndTextView.j b/AppKit/_CPImageAndTextView.j index 63b9d60b6..1a02755f5 100644 --- a/AppKit/_CPImageAndTextView.j +++ b/AppKit/_CPImageAndTextView.j @@ -71,7 +71,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0, #if PLATFORM(DOM) DOMElement _DOMImageElement; - DOMELement _DOMTextElement; + DOMElement _DOMTextElement; DOMElement _DOMTextShadowElement; #endif } diff --git a/AppKit/_CPPopUpList.j b/AppKit/_CPPopUpList.j index 2604f3652..3dd357132 100644 --- a/AppKit/_CPPopUpList.j +++ b/AppKit/_CPPopUpList.j @@ -65,6 +65,113 @@ var ListMinimumItems = 3; var ListColumnIdentifier = @"1"; +@implementation _CPPopUpPanel : CPPanel + +- (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned)aStyleMask +{ + if (self = [super initWithContentRect:aContentRect styleMask:aStyleMask]) + _constrainsToUsableScreen = NO; + + [self _trapNextMouseDown]; + + return self; +} + +/*! + Returns \c YES if the receiver is able to receive input events + even when a modal session is active. +*/ +- (BOOL)worksWhenModal +{ + return YES; +} + +- (void)sendEvent:(CPEvent)anEvent +{ + var type = [anEvent type]; + + if (type === CPLeftMouseDown || type === CPRightMouseDown) + [[self delegate] setListWasClicked:YES]; + + return [super sendEvent:anEvent]; +} + +- (void)orderFront:(id)sender +{ + [self _trapNextMouseDown]; + [super orderFront:sender]; +} + +- (void)_mouseWasClicked:(CPEvent)anEvent +{ + var mouseWindow = [anEvent window], + rect = [[[self delegate] dataSource] bounds], + point = [[[self delegate] dataSource] convertPoint:[anEvent locationInWindow] fromView:nil]; + + if (mouseWindow != self && !CGRectContainsPoint(rect, point)) + [[self delegate] close]; + else + [self _trapNextMouseDown]; +} + +- (void)_trapNextMouseDown +{ + // Don't dequeue the event so clicks in controls will work + [CPApp setTarget:self selector:@selector(_mouseWasClicked:) forNextEventMatchingMask:CPLeftMouseDownMask untilDate:nil inMode:CPDefaultRunLoopMode dequeue:NO]; +} + +@end + +@implementation _CPPopUpTableView : CPTableView +{ + BOOL _acceptFirstResponder; +} + +- (id)initWithFrame:(CGRect)aFrame +{ + if (self = [super initWithFrame:aFrame]) + { + // We want the autocomplete to remain first responder until we are clicked. + _acceptFirstResponder = NO; + } + + return self; +} + +- (void)trackMouse:(CPEvent)anEvent +{ + if (![self isEnabled]) + return; + + [[self delegate] setItemWasClicked:YES]; + + // CPTableView will not track the click if it is not first responder + _acceptFirstResponder = YES; + [[self window] makeFirstResponder:self]; + [super trackMouse:anEvent]; +} + +- (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp +{ + _acceptFirstResponder = NO; + [super stopTracking:lastPoint at:aPoint mouseIsUp:mouseIsUp]; +} + +- (BOOL)acceptsFirstResponder +{ + return _acceptFirstResponder; +} + +/*! + Return the column used for the list. +*/ +- (CPTableColumn)listColumn +{ + return _tableColumns[0]; +} + +@end + /*! This class is a controller for a panel that can pop up and display a scrollable list of items in a CPTableView. It is used by CPComboBox to display the list of choices. @@ -800,110 +907,3 @@ var _CPPopUpListDataSourceKey = @"_CPPopUpListDataSourceKey", } @end - -@implementation _CPPopUpTableView : CPTableView -{ - BOOL _acceptFirstResponder; -} - -- (id)initWithFrame:(CGRect)aFrame -{ - if (self = [super initWithFrame:aFrame]) - { - // We want the autocomplete to remain first responder until we are clicked. - _acceptFirstResponder = NO; - } - - return self; -} - -- (void)trackMouse:(CPEvent)anEvent -{ - if (![self isEnabled]) - return; - - [[self delegate] setItemWasClicked:YES]; - - // CPTableView will not track the click if it is not first responder - _acceptFirstResponder = YES; - [[self window] makeFirstResponder:self]; - [super trackMouse:anEvent]; -} - -- (void)stopTracking:(CGPoint)lastPoint at:(CGPoint)aPoint mouseIsUp:(BOOL)mouseIsUp -{ - _acceptFirstResponder = NO; - [super stopTracking:lastPoint at:aPoint mouseIsUp:mouseIsUp]; -} - -- (BOOL)acceptsFirstResponder -{ - return _acceptFirstResponder; -} - -/*! - Return the column used for the list. -*/ -- (CPTableColumn)listColumn -{ - return _tableColumns[0]; -} - -@end - -@implementation _CPPopUpPanel : CPPanel - -- (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned)aStyleMask -{ - if (self = [super initWithContentRect:aContentRect styleMask:aStyleMask]) - _constrainsToUsableScreen = NO; - - [self _trapNextMouseDown]; - - return self; -} - -/*! - Returns \c YES if the receiver is able to receive input events - even when a modal session is active. -*/ -- (BOOL)worksWhenModal -{ - return YES; -} - -- (void)sendEvent:(CPEvent)anEvent -{ - var type = [anEvent type]; - - if (type === CPLeftMouseDown || type === CPRightMouseDown) - [[self delegate] setListWasClicked:YES]; - - return [super sendEvent:anEvent]; -} - -- (void)orderFront:(id)sender -{ - [self _trapNextMouseDown]; - [super orderFront:sender]; -} - -- (void)_mouseWasClicked:(CPEvent)anEvent -{ - var mouseWindow = [anEvent window], - rect = [[[self delegate] dataSource] bounds], - point = [[[self delegate] dataSource] convertPoint:[anEvent locationInWindow] fromView:nil]; - - if (mouseWindow != self && !CGRectContainsPoint(rect, point)) - [[self delegate] close]; - else - [self _trapNextMouseDown]; -} - -- (void)_trapNextMouseDown -{ - // Don't dequeue the event so clicks in controls will work - [CPApp setTarget:self selector:@selector(_mouseWasClicked:) forNextEventMatchingMask:CPLeftMouseDownMask untilDate:nil inMode:CPDefaultRunLoopMode dequeue:NO]; -} - -@end diff --git a/AppKit/_CPToolbarItem.j b/AppKit/_CPToolbarItem.j index 5d5600b47..387805535 100644 --- a/AppKit/_CPToolbarItem.j +++ b/AppKit/_CPToolbarItem.j @@ -26,6 +26,7 @@ @import "CPImage.j" @import "CPView.j" +@class CPToolbar @global CPApp CPToolbarItemVisibilityPriorityStandard = 0; diff --git a/Foundation/CPDateFormatter.j b/Foundation/CPDateFormatter.j index 9f1badc65..b7c74cbf1 100644 --- a/Foundation/CPDateFormatter.j +++ b/Foundation/CPDateFormatter.j @@ -32,12 +32,14 @@ @global CPLocaleLanguageCode @global CPLocaleCountryCode +@typedef CPDateFormatterStyle CPDateFormatterNoStyle = 0; CPDateFormatterShortStyle = 1; CPDateFormatterMediumStyle = 2; CPDateFormatterLongStyle = 3; CPDateFormatterFullStyle = 4; +@typedef CPDateFormatterBehavior CPDateFormatterBehaviorDefault = 0; CPDateFormatterBehavior10_0 = 1000; CPDateFormatterBehavior10_4 = 1040; diff --git a/Foundation/CPDecimal.j b/Foundation/CPDecimal.j index 15d2f817d..72fbe89cc 100644 --- a/Foundation/CPDecimal.j +++ b/Foundation/CPDecimal.j @@ -52,6 +52,8 @@ @import "CPArray.j" @import "CPNumber.j" +@typedef CPDecimal + // Decimal size limits CPDecimalMaxDigits = 38; CPDecimalMaxExponent = 127; @@ -68,6 +70,7 @@ CPCalculationUnderflow = 3; CPCalculationDivideByZero = 4; //CPRoundingMode Enum +@typedef CPRoundingMode CPRoundPlain = 1; CPRoundDown = 2; CPRoundUp = 3; diff --git a/Foundation/CPDictionary.j b/Foundation/CPDictionary.j index b95792f78..9c673be0c 100755 --- a/Foundation/CPDictionary.j +++ b/Foundation/CPDictionary.j @@ -31,38 +31,6 @@ var CPDictionaryShowNilDeprecationMessage = YES, CPDictionaryMaxDescriptionRecursion = 10; -/* @ignore */ -@implementation _CPDictionaryValueEnumerator : CPEnumerator -{ - CPEnumerator _keyEnumerator; - CPDictionary _dictionary; -} - -- (id)initWithDictionary:(CPDictionary)aDictionary -{ - self = [super init]; - - if (self) - { - _keyEnumerator = [aDictionary keyEnumerator]; - _dictionary = aDictionary; - } - - return self; -} - -- (id)nextObject -{ - var key = [_keyEnumerator nextObject]; - - if (key === nil) - return nil; - - return [_dictionary objectForKey:key]; -} - -@end - /*! @class CPDictionary @ingroup foundation @@ -801,6 +769,40 @@ var CPDictionaryShowNilDeprecationMessage = YES, @end + +/* @ignore */ +@implementation _CPDictionaryValueEnumerator : CPEnumerator +{ + CPEnumerator _keyEnumerator; + CPDictionary _dictionary; +} + +- (id)initWithDictionary:(CPDictionary)aDictionary +{ + self = [super init]; + + if (self) + { + _keyEnumerator = [aDictionary keyEnumerator]; + _dictionary = aDictionary; + } + + return self; +} + +- (id)nextObject +{ + var key = [_keyEnumerator nextObject]; + + if (key === nil) + return nil; + + return [_dictionary objectForKey:key]; +} + +@end + + /*! @class CPMutableDictionary @ingroup compatibility diff --git a/Foundation/CPGeometry.j b/Foundation/CPGeometry.j index 93a3a2b05..f8ef04a4c 100644 --- a/Foundation/CPGeometry.j +++ b/Foundation/CPGeometry.j @@ -22,6 +22,7 @@ @import "_CGGeometry.j" +@typedef CPRectEdge CPMinXEdge = 0; CPMinYEdge = 1; CPMaxXEdge = 2; diff --git a/Foundation/CPJSONPConnection.j b/Foundation/CPJSONPConnection.j index 0330cb223..374395784 100644 --- a/Foundation/CPJSONPConnection.j +++ b/Foundation/CPJSONPConnection.j @@ -23,6 +23,7 @@ @import "CPException.j" @import "CPObject.j" @import "CPRunLoop.j" +@import "CPURLRequest.j" CPJSONPConnectionCallbacks = {}; diff --git a/Foundation/CPNotificationCenter.j b/Foundation/CPNotificationCenter.j index 99ab18183..d8744fe11 100644 --- a/Foundation/CPNotificationCenter.j +++ b/Foundation/CPNotificationCenter.j @@ -29,151 +29,6 @@ var CPNotificationDefaultCenter = nil; -/*! - @class CPNotificationCenter - @ingroup foundation - @brief Sends messages (CPNotification) between objects. - - Cappuccino provides a framework for sending messages between objects within - a process called notifications. Objects register with an - CPNotificationCenter to be informed whenever other objects post - CPNotifications to it matching certain criteria. The notification center - processes notifications synchronously -- that is, control is only returned - to the notification poster once every recipient of the notification has - received it and processed it. -*/ -@implementation CPNotificationCenter : CPObject -{ - CPMutableDictionary _namedRegistries; - _CPNotificationRegistry _unnamedRegistry; -} - -/*! - Returns the application's notification center -*/ -+ (CPNotificationCenter)defaultCenter -{ - if (!CPNotificationDefaultCenter) - CPNotificationDefaultCenter = [[CPNotificationCenter alloc] init]; - - return CPNotificationDefaultCenter; -} - -- (id)init -{ - self = [super init]; - - if (self) - { - _namedRegistries = @{}; - _unnamedRegistry = [[_CPNotificationRegistry alloc] init]; - } - return self; -} - -/*! - Adds an object as an observer. The observer will receive notifications with the specified name - and/or containing the specified object (depending on if they are \c nil. - @param anObserver the observing object - @param aSelector the message sent to the observer when a notification occurs - @param aNotificationName the name of the notification the observer wants to watch - @param anObject the object in the notification the observer wants to watch -*/ -- (void)addObserver:(id)anObserver selector:(SEL)aSelector name:(CPString)aNotificationName object:(id)anObject -{ - var registry, - observer = [[_CPNotificationObserver alloc] initWithObserver:anObserver selector:aSelector]; - - if (aNotificationName == nil) - registry = _unnamedRegistry; - else if (!(registry = [_namedRegistries objectForKey:aNotificationName])) - { - registry = [[_CPNotificationRegistry alloc] init]; - [_namedRegistries setObject:registry forKey:aNotificationName]; - } - - [registry addObserver:observer object:anObject]; -} - -/*! - Unregisters the specified observer from all notifications. - @param anObserver the observer to unregister -*/ -- (void)removeObserver:(id)anObserver -{ - var name = nil, - names = [_namedRegistries keyEnumerator]; - - while ((name = [names nextObject]) !== nil) - [[_namedRegistries objectForKey:name] removeObserver:anObserver object:nil]; - - [_unnamedRegistry removeObserver:anObserver object:nil]; -} - -/*! - Unregisters the specified observer from notifications matching the specified name and/or object. - @param anObserver the observer to remove - @param aNotificationName the name of notifications to no longer watch - @param anObject notifications containing this object will no longer be watched -*/ -- (void)removeObserver:(id)anObserver name:(CPString)aNotificationName object:(id)anObject -{ - if (aNotificationName == nil) - { - var name = nil, - names = [_namedRegistries keyEnumerator]; - - while ((name = [names nextObject]) !== nil) - [[_namedRegistries objectForKey:name] removeObserver:anObserver object:anObject]; - - [_unnamedRegistry removeObserver:anObserver object:anObject]; - } - else - [[_namedRegistries objectForKey:aNotificationName] removeObserver:anObserver object:anObject]; -} - -/*! - Posts a notification to all observers that match the specified notification's name and object. - @param aNotification the notification being posted - @throws CPInvalidArgumentException if aNotification is nil -*/ -- (void)postNotification:(CPNotification)aNotification -{ - if (!aNotification) - [CPException raise:CPInvalidArgumentException reason:"postNotification: does not except 'nil' notifications"]; - - _CPNotificationCenterPostNotification(self, aNotification); -} - -/*! - Posts a new notification with the specified name, object, and dictionary. - @param aNotificationName the name of the notification name - @param anObject the associated object - @param aUserInfo the associated dictionary -*/ -- (void)postNotificationName:(CPString)aNotificationName object:(id)anObject userInfo:(CPDictionary)aUserInfo -{ - _CPNotificationCenterPostNotification(self, [[CPNotification alloc] initWithName:aNotificationName object:anObject userInfo:aUserInfo]); -} - -/*! - Posts a new notification with the specified name and object. - @param aNotificationName the name of the notification - @param anObject the associated object -*/ -- (void)postNotificationName:(CPString)aNotificationName object:(id)anObject -{ - _CPNotificationCenterPostNotification(self, [[CPNotification alloc] initWithName:aNotificationName object:anObject userInfo:nil]); -} - -@end - -var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */ self, /* CPNotification */ aNotification) -{ - [self._unnamedRegistry postNotification:aNotification]; - [[self._namedRegistries objectForKey:[aNotification name]] postNotification:aNotification]; -}; - /* Mapping of Notification Name to listening object/selector. @ignore @@ -338,3 +193,149 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */ } @end + + +/*! + @class CPNotificationCenter + @ingroup foundation + @brief Sends messages (CPNotification) between objects. + + Cappuccino provides a framework for sending messages between objects within + a process called notifications. Objects register with an + CPNotificationCenter to be informed whenever other objects post + CPNotifications to it matching certain criteria. The notification center + processes notifications synchronously -- that is, control is only returned + to the notification poster once every recipient of the notification has + received it and processed it. +*/ +@implementation CPNotificationCenter : CPObject +{ + CPMutableDictionary _namedRegistries; + _CPNotificationRegistry _unnamedRegistry; +} + +/*! + Returns the application's notification center +*/ ++ (CPNotificationCenter)defaultCenter +{ + if (!CPNotificationDefaultCenter) + CPNotificationDefaultCenter = [[CPNotificationCenter alloc] init]; + + return CPNotificationDefaultCenter; +} + +- (id)init +{ + self = [super init]; + + if (self) + { + _namedRegistries = @{}; + _unnamedRegistry = [[_CPNotificationRegistry alloc] init]; + } + return self; +} + +/*! + Adds an object as an observer. The observer will receive notifications with the specified name + and/or containing the specified object (depending on if they are \c nil. + @param anObserver the observing object + @param aSelector the message sent to the observer when a notification occurs + @param aNotificationName the name of the notification the observer wants to watch + @param anObject the object in the notification the observer wants to watch +*/ +- (void)addObserver:(id)anObserver selector:(SEL)aSelector name:(CPString)aNotificationName object:(id)anObject +{ + var registry, + observer = [[_CPNotificationObserver alloc] initWithObserver:anObserver selector:aSelector]; + + if (aNotificationName == nil) + registry = _unnamedRegistry; + else if (!(registry = [_namedRegistries objectForKey:aNotificationName])) + { + registry = [[_CPNotificationRegistry alloc] init]; + [_namedRegistries setObject:registry forKey:aNotificationName]; + } + + [registry addObserver:observer object:anObject]; +} + +/*! + Unregisters the specified observer from all notifications. + @param anObserver the observer to unregister +*/ +- (void)removeObserver:(id)anObserver +{ + var name = nil, + names = [_namedRegistries keyEnumerator]; + + while ((name = [names nextObject]) !== nil) + [[_namedRegistries objectForKey:name] removeObserver:anObserver object:nil]; + + [_unnamedRegistry removeObserver:anObserver object:nil]; +} + +/*! + Unregisters the specified observer from notifications matching the specified name and/or object. + @param anObserver the observer to remove + @param aNotificationName the name of notifications to no longer watch + @param anObject notifications containing this object will no longer be watched +*/ +- (void)removeObserver:(id)anObserver name:(CPString)aNotificationName object:(id)anObject +{ + if (aNotificationName == nil) + { + var name = nil, + names = [_namedRegistries keyEnumerator]; + + while ((name = [names nextObject]) !== nil) + [[_namedRegistries objectForKey:name] removeObserver:anObserver object:anObject]; + + [_unnamedRegistry removeObserver:anObserver object:anObject]; + } + else + [[_namedRegistries objectForKey:aNotificationName] removeObserver:anObserver object:anObject]; +} + +/*! + Posts a notification to all observers that match the specified notification's name and object. + @param aNotification the notification being posted + @throws CPInvalidArgumentException if aNotification is nil +*/ +- (void)postNotification:(CPNotification)aNotification +{ + if (!aNotification) + [CPException raise:CPInvalidArgumentException reason:"postNotification: does not except 'nil' notifications"]; + + _CPNotificationCenterPostNotification(self, aNotification); +} + +/*! + Posts a new notification with the specified name, object, and dictionary. + @param aNotificationName the name of the notification name + @param anObject the associated object + @param aUserInfo the associated dictionary +*/ +- (void)postNotificationName:(CPString)aNotificationName object:(id)anObject userInfo:(CPDictionary)aUserInfo +{ + _CPNotificationCenterPostNotification(self, [[CPNotification alloc] initWithName:aNotificationName object:anObject userInfo:aUserInfo]); +} + +/*! + Posts a new notification with the specified name and object. + @param aNotificationName the name of the notification + @param anObject the associated object +*/ +- (void)postNotificationName:(CPString)aNotificationName object:(id)anObject +{ + _CPNotificationCenterPostNotification(self, [[CPNotification alloc] initWithName:aNotificationName object:anObject userInfo:nil]); +} + +@end + +var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */ self, /* CPNotification */ aNotification) +{ + [self._unnamedRegistry postNotification:aNotification]; + [[self._namedRegistries objectForKey:[aNotification name]] postNotification:aNotification]; +}; diff --git a/Foundation/CPNumberFormatter.j b/Foundation/CPNumberFormatter.j index f59dca490..52737fc1c 100644 --- a/Foundation/CPNumberFormatter.j +++ b/Foundation/CPNumberFormatter.j @@ -24,7 +24,7 @@ @import "CPFormatter.j" @import "CPDecimalNumber.j" - +@typedef CPNumberFormatterStyle CPNumberFormatterNoStyle = 0; CPNumberFormatterDecimalStyle = 1; CPNumberFormatterCurrencyStyle = 2; @@ -32,6 +32,7 @@ CPNumberFormatterPercentStyle = 3; CPNumberFormatterScientificStyle = 4; CPNumberFormatterSpellOutStyle = 5; +@typedef CPNumberFormatterRoundingMode CPNumberFormatterRoundCeiling = CPRoundUp; CPNumberFormatterRoundFloor = CPRoundDown; CPNumberFormatterRoundDown = CPRoundDown; diff --git a/Foundation/CPObject.j b/Foundation/CPObject.j index 912aafa09..f5aea7aa6 100644 --- a/Foundation/CPObject.j +++ b/Foundation/CPObject.j @@ -62,6 +62,8 @@ CPLog(@"Got some class: %@", inst); @todo document KVC usage. */ +@import "_CPTypeDefinitions.j" + @class CPString @class CPException @@ -104,7 +106,7 @@ CPLog(@"Got some class: %@", inst); @implementation CPObject { - Class isa; + id isa; } + (void)load diff --git a/Foundation/CPPredicate/CPComparisonPredicate.j b/Foundation/CPPredicate/CPComparisonPredicate.j index f2cfb3172..338a4e7f3 100644 --- a/Foundation/CPPredicate/CPComparisonPredicate.j +++ b/Foundation/CPPredicate/CPComparisonPredicate.j @@ -32,8 +32,8 @@ @import "_CPPredicate.j" -var CPComparisonPredicateModifier, - CPPredicateOperatorType; +@typedef CPComparisonPredicateModifier +@typedef CPPredicateOperatorType /*! @ingroup foundation diff --git a/Foundation/CPPredicate/CPCompoundPredicate.j b/Foundation/CPPredicate/CPCompoundPredicate.j index e36ceb0d0..a38f3b065 100644 --- a/Foundation/CPPredicate/CPCompoundPredicate.j +++ b/Foundation/CPPredicate/CPCompoundPredicate.j @@ -26,7 +26,7 @@ @import "CPArray.j" @import "_CPPredicate.j" -var CPCompoundPredicateType; +@typedef CPCompoundPredicateType /*! @class CPCompoundPredicate diff --git a/Foundation/CPRange.j b/Foundation/CPRange.j index c9f9c7c2a..58dd550bc 100755 --- a/Foundation/CPRange.j +++ b/Foundation/CPRange.j @@ -25,6 +25,8 @@ @{ */ +@typedef CPRange + /*! Makes a CPRange. @param location the location for new range diff --git a/Foundation/CPURLConnection.j b/Foundation/CPURLConnection.j index 420ce8402..88a1afbf8 100644 --- a/Foundation/CPURLConnection.j +++ b/Foundation/CPURLConnection.j @@ -26,6 +26,8 @@ @import "CPURLRequest.j" @import "CPURLResponse.j" +@typedef HTTPRequest + var CPURLConnectionDelegate = nil; /*! diff --git a/Foundation/CPUndoManager.j b/Foundation/CPUndoManager.j index af2111170..d4ad4914e 100644 --- a/Foundation/CPUndoManager.j +++ b/Foundation/CPUndoManager.j @@ -50,7 +50,7 @@ var _CPUndoGroupingPool = [], /* @ignore */ @implementation _CPUndoGrouping : CPObject { - _CPUndoGrouping _parent; + id _parent; CPMutableArray _invocations; CPString _actionName; } diff --git a/Foundation/CPUserSessionManager.j b/Foundation/CPUserSessionManager.j index b1cbd23cb..523a65e19 100644 --- a/Foundation/CPUserSessionManager.j +++ b/Foundation/CPUserSessionManager.j @@ -24,6 +24,7 @@ @import "CPObject.j" @import "CPString.j" +@typedef CPUserSessionStatus CPUserSessionUndeterminedStatus = 0; CPUserSessionLoggedInStatus = 1; CPUserSessionLoggedOutStatus = 2; diff --git a/Foundation/_CGGeometry.j b/Foundation/_CGGeometry.j index 4861ce8fd..d0482aa71 100644 --- a/Foundation/_CGGeometry.j +++ b/Foundation/_CGGeometry.j @@ -26,6 +26,12 @@ CGGeometry is not a part of Foundation. The reason _CGGeometry.j exists, and is */ +@typedef CGPoint +@typedef CGSize +@typedef CGRect +@typedef CGInset + + function CGPointMake(x, y) { return { x:x, y:y }; diff --git a/Foundation/_CPTypeDefinitions.j b/Foundation/_CPTypeDefinitions.j new file mode 100644 index 000000000..7aa874fe1 --- /dev/null +++ b/Foundation/_CPTypeDefinitions.j @@ -0,0 +1,30 @@ +/* + * _CPTypeDefintions.j + * Foundation + * + * Created by Antoine Mercadal. + * Copyright 2014, Antoine Mercadal. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +@typedef Class +@typedef CPInteger +@typedef CPUInteger +@typedef DOMElement +@typedef JSObject +@typedef CPMethodSignature +@typedef CPPropertyListFormat +@typedef CPTimeInterval From 45248bcb6553ecc797af910d261c3ea25c791393 Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Thu, 6 Nov 2014 12:17:58 -0800 Subject: [PATCH 03/18] FIXED: ivars warning fixes --- Foundation/CPDateFormatter.j | 1 + Foundation/CPTimeZone.j | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Foundation/CPDateFormatter.j b/Foundation/CPDateFormatter.j index b7c74cbf1..59a48019d 100644 --- a/Foundation/CPDateFormatter.j +++ b/Foundation/CPDateFormatter.j @@ -28,6 +28,7 @@ @import "CPLocale.j" @class CPNull +@class CPDictionary @global CPLocaleLanguageCode @global CPLocaleCountryCode diff --git a/Foundation/CPTimeZone.j b/Foundation/CPTimeZone.j index 3d294c25f..4b4ba6c1b 100644 --- a/Foundation/CPTimeZone.j +++ b/Foundation/CPTimeZone.j @@ -24,6 +24,8 @@ @import "CPDate.j" @import "CPLocale.j" +@class CPData + CPTimeZoneNameStyleStandard = 0; CPTimeZoneNameStyleShortStandard = 1; CPTimeZoneNameStyleDaylightSaving = 2; From ab2657b795f22817dfd1a81240b8aee077e7d582 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Thu, 6 Nov 2014 15:11:58 -0800 Subject: [PATCH 04/18] Fixed compilation warning in nib2cib --- Tools/nib2cib/NSDatePicker.j | 2 +- Tools/nib2cib/NSImageView.j | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Tools/nib2cib/NSDatePicker.j b/Tools/nib2cib/NSDatePicker.j index d3af0690c..a90983ec5 100644 --- a/Tools/nib2cib/NSDatePicker.j +++ b/Tools/nib2cib/NSDatePicker.j @@ -180,7 +180,7 @@ var NSDatePickerDefaultSize = 22, CPDateFormatter _formatter @accessors(getter=formatter); CPInteger _datePickerMode @accessors(getter=datePickerMode); CPInteger _datePickerElements @accessors(getter=datePickerElements); - CPinteger _datePickerType @accessors(getter=datePickerType); + CPInteger _datePickerType @accessors(getter=datePickerType); double _timeInterval @accessors(getter=timeInterval); CPColor _textColor @accessors(getter=textColor); CPColor _backgroundColor @accessors(getter=backgroundColor); diff --git a/Tools/nib2cib/NSImageView.j b/Tools/nib2cib/NSImageView.j index 909089fdf..02fd50f52 100644 --- a/Tools/nib2cib/NSImageView.j +++ b/Tools/nib2cib/NSImageView.j @@ -67,7 +67,7 @@ @end // NSImageCell - +@typedef NSImageAlignment NSImageAlignCenter = 0; NSImageAlignTop = 1; NSImageAlignTopLeft = 2; @@ -78,12 +78,13 @@ NSImageAlignBottomLeft = 6; NSImageAlignBottomRight = 7; NSImageAlignRight = 8; - +@typedef NSImageScaling NSImageScaleProportionallyDown = 0; NSImageScaleAxesIndependently = 1; NSImageScaleNone = 2; NSImageScaleProportionallyUpOrDown = 3; +@typedef NSImageFrameStyle NSImageFrameNone = 0; NSImageFramePhoto = 1; NSImageFrameGrayBezel = 2; From 86d24319255258446652a73fc49e34cd3b0c63f9 Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Wed, 19 Nov 2014 14:34:52 -0800 Subject: [PATCH 05/18] CPWebScriptObject is a class, not a typedef --- AppKit/CPPasteboard.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPPasteboard.j b/AppKit/CPPasteboard.j index 8f5c4f754..b8e0139f0 100644 --- a/AppKit/CPPasteboard.j +++ b/AppKit/CPPasteboard.j @@ -26,7 +26,7 @@ @import @import -@typedef CPWebScriptObject +@class CPWebScriptObject CPGeneralPboard = @"CPGeneralPboard"; CPFontPboard = @"CPFontPboard"; From 9e66c699e1e85b0d8f9fadf26653d242be07132f Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Wed, 19 Nov 2014 14:35:33 -0800 Subject: [PATCH 06/18] FIXED: prevent to declare a type that is already declared as a class and vice-versa --- Objective-J/ObjJAcornCompiler.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Objective-J/ObjJAcornCompiler.js b/Objective-J/ObjJAcornCompiler.js index fd6f020d3..e9bc334f5 100644 --- a/Objective-J/ObjJAcornCompiler.js +++ b/Objective-J/ObjJAcornCompiler.js @@ -1674,6 +1674,9 @@ ClassDeclarationStatement: function(node, st, c) { compiler.cmBuffer = new StringBuffer(); compiler.classBodyBuffer = new StringBuffer(); // TODO: Check if this is needed + if (compiler.getTypeDef(className)) + throw compiler.error_message(className + " is already declared as type", node.classname); + if (!generate) saveJSBuffer.concat(compiler.source.substring(compiler.lastPos, node.start)); // First we declare the class @@ -2444,6 +2447,9 @@ TypeDefStatement: function(node, st, c) { if (typeDef) throw compiler.error_message("Duplicate type definition " + typeDefName, node.typedefname); + if (compiler.getClassDef(typeDefName)) + throw compiler.error_message(typeDefName + " is already declared as class", node.typedefname); + compiler.imBuffer = new StringBuffer(); compiler.cmBuffer = new StringBuffer(); From 460a60440a54e50b548108368450faf9fe248882 Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Wed, 19 Nov 2014 14:53:38 -0800 Subject: [PATCH 07/18] Correctly set the type of datasource in CPComboBox --- AppKit/CPComboBox.j | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/AppKit/CPComboBox.j b/AppKit/CPComboBox.j index 01d424664..6787948e3 100644 --- a/AppKit/CPComboBox.j +++ b/AppKit/CPComboBox.j @@ -61,19 +61,19 @@ var CPComboBoxTextSubview = @"text", @implementation CPComboBox : CPTextField { - CPArray _items; - _CPPopUpList _listDelegate; - id _dataSource; - BOOL _usesDataSource; - BOOL _completes; - BOOL _canComplete; - int _numberOfVisibleItems; - BOOL _forceSelection; - BOOL _hasVerticalScroller; - CPString _selectedStringValue; - CGSize _intercellSpacing; - float _itemHeight; - BOOL _popUpButtonCausedResign; + CPArray _items; + _CPPopUpList _listDelegate; + id _dataSource; + BOOL _usesDataSource; + BOOL _completes; + BOOL _canComplete; + int _numberOfVisibleItems; + BOOL _forceSelection; + BOOL _hasVerticalScroller; + CPString _selectedStringValue; + CGSize _intercellSpacing; + float _itemHeight; + BOOL _popUpButtonCausedResign; } + (CPString)defaultThemeClass From d106e6485bb0970131e4e7fd295d0a3a97de1972 Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Wed, 19 Nov 2014 16:23:56 -0800 Subject: [PATCH 08/18] Add some manual test cases for objj output --- Tests/Manual/CompilationTests/README.md | 6 ++ Tests/Manual/CompilationTests/TestCases/1.j | 13 ++++ Tests/Manual/CompilationTests/TestCases/2.j | 20 +++++ Tests/Manual/CompilationTests/TestCases/3.j | 15 ++++ Tests/Manual/CompilationTests/TestCases/4.j | 15 ++++ Tests/Manual/CompilationTests/TestCases/5.j | 22 ++++++ Tests/Manual/CompilationTests/TestCases/6.j | 16 ++++ Tests/Manual/CompilationTests/TestCases/7.j | 20 +++++ Tests/Manual/CompilationTests/TestCases/8.j | 20 +++++ Tests/Manual/CompilationTests/TestCases/9.j | 22 ++++++ Tests/Manual/CompilationTests/run.py | 82 +++++++++++++++++++++ 11 files changed, 251 insertions(+) create mode 100644 Tests/Manual/CompilationTests/README.md create mode 100644 Tests/Manual/CompilationTests/TestCases/1.j create mode 100644 Tests/Manual/CompilationTests/TestCases/2.j create mode 100644 Tests/Manual/CompilationTests/TestCases/3.j create mode 100644 Tests/Manual/CompilationTests/TestCases/4.j create mode 100644 Tests/Manual/CompilationTests/TestCases/5.j create mode 100644 Tests/Manual/CompilationTests/TestCases/6.j create mode 100644 Tests/Manual/CompilationTests/TestCases/7.j create mode 100644 Tests/Manual/CompilationTests/TestCases/8.j create mode 100644 Tests/Manual/CompilationTests/TestCases/9.j create mode 100755 Tests/Manual/CompilationTests/run.py diff --git a/Tests/Manual/CompilationTests/README.md b/Tests/Manual/CompilationTests/README.md new file mode 100644 index 000000000..04a7e90c0 --- /dev/null +++ b/Tests/Manual/CompilationTests/README.md @@ -0,0 +1,6 @@ +To run these tests: + + - open x.j + - check what is the expected output in the comments + - run objj x.j + - check you get the correct output diff --git a/Tests/Manual/CompilationTests/TestCases/1.j b/Tests/Manual/CompilationTests/TestCases/1.j new file mode 100644 index 000000000..b2585522e --- /dev/null +++ b/Tests/Manual/CompilationTests/TestCases/1.j @@ -0,0 +1,13 @@ +// Expected output: 0 + +/* +*/ + + +@import + +@implementation MyCall : CPObject +{ + CPString property1; +} +@end diff --git a/Tests/Manual/CompilationTests/TestCases/2.j b/Tests/Manual/CompilationTests/TestCases/2.j new file mode 100644 index 000000000..af2c92cf1 --- /dev/null +++ b/Tests/Manual/CompilationTests/TestCases/2.j @@ -0,0 +1,20 @@ +// Expected output: 0 + +/* + +START_EXPECTED + MyType property1; + ^ +WARNING line 5 in file:[__PATH__]: Unknown type 'MyType' for ivar 'property1' +END_EXPECTED +*/ + + +@import + +@implementation MyCall : CPObject +{ + MyType property1; +} + +@end diff --git a/Tests/Manual/CompilationTests/TestCases/3.j b/Tests/Manual/CompilationTests/TestCases/3.j new file mode 100644 index 000000000..e00d77593 --- /dev/null +++ b/Tests/Manual/CompilationTests/TestCases/3.j @@ -0,0 +1,15 @@ +// Expected output: 0 + +/* +*/ + +@import + +@typedef MyType + +@implementation MyCall : CPObject +{ + MyType property1; +} + +@end diff --git a/Tests/Manual/CompilationTests/TestCases/4.j b/Tests/Manual/CompilationTests/TestCases/4.j new file mode 100644 index 000000000..889ab3036 --- /dev/null +++ b/Tests/Manual/CompilationTests/TestCases/4.j @@ -0,0 +1,15 @@ +// Expected output: 0 + +/* +*/ + +@import + +@class MyType + +@implementation MyCall : CPObject +{ + MyType property1; +} + +@end diff --git a/Tests/Manual/CompilationTests/TestCases/5.j b/Tests/Manual/CompilationTests/TestCases/5.j new file mode 100644 index 000000000..bcbf216ab --- /dev/null +++ b/Tests/Manual/CompilationTests/TestCases/5.j @@ -0,0 +1,22 @@ +// Expected output: 0 + +/* + +START_EXPECTED + MyType property1; + ^ +WARNING line 7 in file:[__PATH__]: Unknown type 'MyType' for ivar 'property1' +END_EXPECTED + +*/ + +@import + +@global MyType + +@implementation MyCall : CPObject +{ + MyType property1; +} + +@end diff --git a/Tests/Manual/CompilationTests/TestCases/6.j b/Tests/Manual/CompilationTests/TestCases/6.j new file mode 100644 index 000000000..b41c518cb --- /dev/null +++ b/Tests/Manual/CompilationTests/TestCases/6.j @@ -0,0 +1,16 @@ +// Expected output: 256 + +/* + +START_EXPECTED +Error on line 10771 of file [unknown] +SyntaxError: +@typedef MyType + ^ +ERROR line 2 in file:[__PATH__]: Duplicate type definition MyType +END_EXPECTED + +*/ + +@typedef MyType +@typedef MyType diff --git a/Tests/Manual/CompilationTests/TestCases/7.j b/Tests/Manual/CompilationTests/TestCases/7.j new file mode 100644 index 000000000..cdff5aeda --- /dev/null +++ b/Tests/Manual/CompilationTests/TestCases/7.j @@ -0,0 +1,20 @@ +// Expected output: 256 + +/* + +START_EXPECTED +Error on line 10001 of file [unknown] +SyntaxError: +@implementation MyType : CPObject + ^ +ERROR line 5 in file:[__PATH__]: MyType is already declared as type +END_EXPECTED + +*/ + +@import + +@typedef MyType + +@implementation MyType : CPObject +@end diff --git a/Tests/Manual/CompilationTests/TestCases/8.j b/Tests/Manual/CompilationTests/TestCases/8.j new file mode 100644 index 000000000..07a2aa769 --- /dev/null +++ b/Tests/Manual/CompilationTests/TestCases/8.j @@ -0,0 +1,20 @@ +// Expected output: 256 + +/* + +START_EXPECTED +Error on line 10774 of file [unknown] +SyntaxError: +@typedef MyType + ^ +ERROR line 6 in file:[__PATH__]: MyType is already declared as class +END_EXPECTED + +*/ + +@import + +@implementation MyType : CPObject +@end + +@typedef MyType diff --git a/Tests/Manual/CompilationTests/TestCases/9.j b/Tests/Manual/CompilationTests/TestCases/9.j new file mode 100644 index 000000000..0fd6c0678 --- /dev/null +++ b/Tests/Manual/CompilationTests/TestCases/9.j @@ -0,0 +1,22 @@ +// Expected output: 256 + +/* + +START_EXPECTED +Error on line 10014 of file [unknown] +SyntaxError: +@implementation MyType : CPObject + ^ +ERROR line 6 in file:[__PATH__]: Duplicate class MyType +END_EXPECTED + +*/ + +@import + +@implementation MyType : CPObject +@end + +@implementation MyType : CPObject +@end + diff --git a/Tests/Manual/CompilationTests/run.py b/Tests/Manual/CompilationTests/run.py new file mode 100755 index 000000000..e21eebaa3 --- /dev/null +++ b/Tests/Manual/CompilationTests/run.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python + +import os +import commands +import re + +PATH = os.path.abspath(os.path.join(os.path.dirname(__file__))) + + +def get_tests_cases(): + ret = [] + for filename in os.listdir("TestCases"): + ret.append("TestCases/%s" % filename) + return ret + # return ["TestCases/2.j"] + +def get_expected_output(test_case): + f = open(test_case) + content = f.readlines(); + f.close() + + status = int(content[0].replace("// Expected output: ", "")) + + recording = False + output = [] + + for line in content: + if "END_EXPECTED" in line: + recording = False + break; + + if "START_EXPECTED" in line: + recording = True + continue + + if recording: + output.append(line) + + output = "".join(output); + output = output.replace("[__PATH__]", "%s/%s" % (PATH, test_case)) + output = cleanup_output(output) + + return (status, output) + + +def get_actual_output(test_case): + status, output = commands.getstatusoutput("objj %s" % test_case) + output = cleanup_output(output) + return (status, output) + + +def cleanup_output(output): + if not output: + return "" + output = output.replace(" ", "") + output = output.replace("\n", "") + output = output.replace("[0m", "") + return re.sub('[^\s!-~]', '', output) + + +if __name__ == "__main__": + + for test in get_tests_cases(): + + expected_status, expected_output = get_expected_output(test) + actual_status, actual_output = get_actual_output(test) + + print "########################################" + print "Testing %s" % test + errored = False + if expected_status != actual_status: + errored = True + print " Error in %s: Status code is different: expected %d, actual %d" % (test, expected_status, actual_status) + + if expected_output != actual_output: + errored = True + print " Error in %s. Outputs are different" % test + print " EXPECTED: %s" % expected_output + print " ACTUAL: %s" % actual_output + + if not errored: + print " OK" From 653f706f1b02b867b4ccaf65b2e7667f39494382 Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Wed, 19 Nov 2014 16:29:05 -0800 Subject: [PATCH 09/18] Update README --- Tests/Manual/CompilationTests/README.md | 50 ++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/Tests/Manual/CompilationTests/README.md b/Tests/Manual/CompilationTests/README.md index 04a7e90c0..c852088b8 100644 --- a/Tests/Manual/CompilationTests/README.md +++ b/Tests/Manual/CompilationTests/README.md @@ -1,6 +1,46 @@ -To run these tests: +## Run tests - - open x.j - - check what is the expected output in the comments - - run objj x.j - - check you get the correct output +./run.py + + +## Create a test case + +create a `.j` file in `TestCases` folder: + +-First line MUST be: + + // Expected output: [OBJJ_STATUS_CODE] + + +Then after that add a block comment that contains: + + /* + START_EXPECTED + [CONSOLE_OUTPUT_OF_OBJJ] + END_EXPECTED + */ + + +Be sure to replace the file path by the token `[__PATH__]` After that, add the code you want to test. + +If your test doesn't expect any output, don't put any `START_EXPECTED` and `END_EXPECTED` + + +For instance: + + /* + START_EXPECTED + Error on line 10771 of file [unknown] + SyntaxError: + @typedef MyType + ^ + ERROR line 2 in file:[__PATH__]: Duplicate type definition MyType + END_EXPECTED + */ + @import + + @implementation MyCall : CPObject + { + CPString property1; + } + @end From 37b9895878319d11409ba660363eadc852048700 Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Thu, 20 Nov 2014 11:44:32 -0800 Subject: [PATCH 10/18] Add check to ensure a @class declaration is not already defined as a type --- Objective-J/ObjJAcornCompiler.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Objective-J/ObjJAcornCompiler.js b/Objective-J/ObjJAcornCompiler.js index e9bc334f5..ce3009ef7 100644 --- a/Objective-J/ObjJAcornCompiler.js +++ b/Objective-J/ObjJAcornCompiler.js @@ -2412,6 +2412,10 @@ ClassStatement: function(node, st, c) { compiler.jsBuffer.concat("//"); } var className = node.id.name; + + if (compiler.getTypeDef(className)) + throw compiler.error_message(className + " is already declared as type", node.id); + if (!compiler.getClassDef(className)) { classDef = new ClassDef(false, className); compiler.classDefs[className] = classDef; From f3090e7827b655e7eea4832ea6c668025ccc2445 Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Thu, 20 Nov 2014 11:44:51 -0800 Subject: [PATCH 11/18] Update test cases --- Tests/Manual/CompilationTests/TestCases/10.j | 18 ++++++++++++++++++ Tests/Manual/CompilationTests/TestCases/6.j | 2 +- Tests/Manual/CompilationTests/TestCases/8.j | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 Tests/Manual/CompilationTests/TestCases/10.j diff --git a/Tests/Manual/CompilationTests/TestCases/10.j b/Tests/Manual/CompilationTests/TestCases/10.j new file mode 100644 index 000000000..c614eeb4d --- /dev/null +++ b/Tests/Manual/CompilationTests/TestCases/10.j @@ -0,0 +1,18 @@ +// Expected output: 256 + +/* + +START_EXPECTED +Error on line 10778 of file [unknown] +SyntaxError: +@typedef mytype + ^ +ERROR line 4 in file:[__PATH__]: mytype is already declared as class +END_EXPECTED +*/ + +@import + +@class mytype +@typedef mytype + diff --git a/Tests/Manual/CompilationTests/TestCases/6.j b/Tests/Manual/CompilationTests/TestCases/6.j index b41c518cb..37a7f86bf 100644 --- a/Tests/Manual/CompilationTests/TestCases/6.j +++ b/Tests/Manual/CompilationTests/TestCases/6.j @@ -3,7 +3,7 @@ /* START_EXPECTED -Error on line 10771 of file [unknown] +Error on line 10775 of file [unknown] SyntaxError: @typedef MyType ^ diff --git a/Tests/Manual/CompilationTests/TestCases/8.j b/Tests/Manual/CompilationTests/TestCases/8.j index 07a2aa769..393371331 100644 --- a/Tests/Manual/CompilationTests/TestCases/8.j +++ b/Tests/Manual/CompilationTests/TestCases/8.j @@ -3,7 +3,7 @@ /* START_EXPECTED -Error on line 10774 of file [unknown] +Error on line 10778 of file [unknown] SyntaxError: @typedef MyType ^ From 0dcc645f229473a7221db6fd63b0928d315ff9af Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Thu, 20 Nov 2014 11:50:18 -0800 Subject: [PATCH 12/18] Fix a missing @class declaration --- AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j | 2 -- AppKit/CPWebView.j | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j b/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j index d11eceb64..30470d5c6 100644 --- a/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j +++ b/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j @@ -24,8 +24,6 @@ @import "CPDatePicker.j" @import "CPPopUpButton.j" -@class CPRuleEditorRowType - @global CPApp @global CPMiniControlSize @global CPSmallControlSize diff --git a/AppKit/CPWebView.j b/AppKit/CPWebView.j index 3f2ca713e..fe344027e 100644 --- a/AppKit/CPWebView.j +++ b/AppKit/CPWebView.j @@ -23,6 +23,7 @@ @import "CPView.j" @import "CPScrollView.j" +@class CPWebScriptObject // FIXME: implement these where possible: /* From fe25dbd87296402d921c7c2cbf8c2de2ed583e8a Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Thu, 20 Nov 2014 15:21:07 -0800 Subject: [PATCH 13/18] New: added method addObserverForName:object::usingBlock: in CPNotificationCenter Previously, the method addObserverForName:object::usingBlock: didn't exist in Cappuccino. Now it does. To observe, you need to use the method - (id )addObserverForName:(CPString)aNotificationName object:(id)anObject usingBlock:(Function)block To unregister observations, you pass the object returned by this method to removeObserver:. You must invoke removeObserver: or removeObserver:name:object:. Test /Tests/Foundation/CPNotificationCenterTest.j Fixed #2259 --- Foundation/CPNotificationCenter.j | 68 ++++++++++++++++++--- Tests/Foundation/CPNotificationCenterTest.j | 45 ++++++++++++++ 2 files changed, 106 insertions(+), 7 deletions(-) diff --git a/Foundation/CPNotificationCenter.j b/Foundation/CPNotificationCenter.j index 99ab18183..0d880276e 100644 --- a/Foundation/CPNotificationCenter.j +++ b/Foundation/CPNotificationCenter.j @@ -68,7 +68,8 @@ var CPNotificationDefaultCenter = nil; _namedRegistries = @{}; _unnamedRegistry = [[_CPNotificationRegistry alloc] init]; } - return self; + + return self; } /*! @@ -81,9 +82,35 @@ var CPNotificationDefaultCenter = nil; */ - (void)addObserver:(id)anObserver selector:(SEL)aSelector name:(CPString)aNotificationName object:(id)anObject { - var registry, + var registry = [self _registryForNotificationName:aNotificationName], observer = [[_CPNotificationObserver alloc] initWithObserver:anObserver selector:aSelector]; + [registry addObserver:observer object:anObject]; +} + +/*! + Adds an entry to the receiver’s dispatch table with a block, and optional criteria: notification name and sender. + @param aNotificationName the name of the notification the observer wants to watch + @param anObject the object in the notification the observer wants to watch + @param block the block to be executed when the notification is received. +*/ +- (id )addObserverForName:(CPString)aNotificationName object:(id)anObject usingBlock:(Function)block +{ + var registry = [self _registryForNotificationName:aNotificationName], + observer = [[_CPNotificationObserver alloc] initWithBlock:block]; + + [registry addObserver:observer object:anObject]; + + return observer; +} + +/*! + @ignore +*/ +- (_CPNotificationRegistry)_registryForNotificationName:(CPString)aNotificationName +{ + var registry; + if (aNotificationName == nil) registry = _unnamedRegistry; else if (!(registry = [_namedRegistries objectForKey:aNotificationName])) @@ -92,7 +119,7 @@ var CPNotificationDefaultCenter = nil; [_namedRegistries setObject:registry forKey:aNotificationName]; } - [registry addObserver:observer object:anObject]; + return registry; } /*! @@ -129,7 +156,10 @@ var CPNotificationDefaultCenter = nil; [_unnamedRegistry removeObserver:anObserver object:anObject]; } else + { [[_namedRegistries objectForKey:aNotificationName] removeObserver:anObserver object:anObject]; + } + } /*! @@ -233,7 +263,8 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */ observersEnumerator = [observers objectEnumerator]; while ((observer = [observersEnumerator nextObject]) !== nil) - if ([observer observer] == anObserver) + if ([observer observer] == anObserver || + ([observer block] && [anObserver respondsToSelector:@selector(block)] && [observer block] == [anObserver block])) [observers removeObject:observer]; if (![observers count]) @@ -248,7 +279,8 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */ observersEnumerator = [observers objectEnumerator]; while ((observer = [observersEnumerator nextObject]) !== nil) - if ([observer observer] == anObserver) + if ([observer observer] == anObserver || + ([observer block] && [anObserver respondsToSelector:@selector(block)] && [observer block] == [anObserver block])) [observers removeObject:observer]; if (![observers count]) @@ -312,8 +344,9 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */ /* @ignore */ @implementation _CPNotificationObserver : CPObject { - id _observer; - SEL _selector; + id _observer; + Function _block; + SEL _selector; } - (id)initWithObserver:(id)anObserver selector:(SEL)aSelector @@ -327,13 +360,34 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */ return self; } +- (id)initWithBlock:(Function)aBlock +{ + if (self) + { + _block = aBlock; + } + + return self; +} + - (id)observer { return _observer; } +- (id)block +{ + return _block; +} + - (void)postNotification:(CPNotification)aNotification { + if (_block) + { + _block(aNotification); + return; + } + [_observer performSelector:_selector withObject:aNotification]; } diff --git a/Tests/Foundation/CPNotificationCenterTest.j b/Tests/Foundation/CPNotificationCenterTest.j index b1f3b8bf5..e630e4064 100644 --- a/Tests/Foundation/CPNotificationCenterTest.j +++ b/Tests/Foundation/CPNotificationCenterTest.j @@ -52,6 +52,51 @@ var TestNotification = @"TestNotification"; [self assert:8 equals:notificationCount message:@"observer should not be notified"]; } +- (void)testNotifyWithBlocks +{ + var center = [CPNotificationCenter defaultCenter]; + + notificationCount = 0; + + var notificationBlock = function(notification){ + notificationCount += 1; + }; + + var observer2 = [center addObserverForName:TestNotification object:2 usingBlock:notificationBlock], + observer25 = [center addObserverForName:TestNotification object:25 usingBlock:notificationBlock]; + + [center postNotificationName:TestNotification object:self]; + [self assert:0 equals:notificationCount message:@"observer should only be notified for object '2'"]; + + [center postNotificationName:TestNotification object:2]; + [self assert:1 equals:notificationCount message:@"observer should be notified for object '2'"]; + + var observerNil = [center addObserverForName:TestNotification object:nil usingBlock:notificationBlock]; + + [center postNotificationName:TestNotification object:2]; + [self assert:3 equals:notificationCount message:@"observer should be notified for object '2' and for any object"]; + + [center removeObserver:observer2 name:TestNotification object:2]; + [center postNotificationName:TestNotification object:2]; + [self assert:4 equals:notificationCount message:@"observer should be notified only for any object"]; + + // At this point we have TestNofication:nil observer and a TestNotification:25 observer. + observer2 = [center addObserverForName:nil object:2 usingBlock:notificationBlock]; + + [center postNotificationName:TestNotification object:2]; + [self assert:6 equals:notificationCount message:@"observer should be notified for TestNofication and for object '2' (TestNotification)"]; + [center postNotificationName:@"RandomNotification" object:2]; + [self assert:7 equals:notificationCount message:@"observer should be notified for object '2' (RandomNotification)"]; + + [center removeObserver:observer2]; + [center removeObserver:observer25]; + [center removeObserver:observerNil]; + [center postNotificationName:TestNotification object:nil]; + [center postNotificationName:TestNotification object:2]; + [center postNotificationName:TestNotification object:25]; + [self assert:7 equals:notificationCount message:@"observer should not be notified"]; +} + - (void)testAddObserversDuringNotification { var center = [CPNotificationCenter defaultCenter]; From d481d9cca5348df486203e1954822547157bd1bb Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Thu, 20 Nov 2014 23:38:53 -0800 Subject: [PATCH 14/18] Fixed: added queue to the method addObserverForName:(CPString)aNotificationName object:(id)anObject queue:(id)queue usingBlock:(Function)block --- Foundation/CPNotificationCenter.j | 6 ++---- Tests/Foundation/CPNotificationCenterTest.j | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Foundation/CPNotificationCenter.j b/Foundation/CPNotificationCenter.j index 0d880276e..78cd7d354 100644 --- a/Foundation/CPNotificationCenter.j +++ b/Foundation/CPNotificationCenter.j @@ -92,9 +92,10 @@ var CPNotificationDefaultCenter = nil; Adds an entry to the receiver’s dispatch table with a block, and optional criteria: notification name and sender. @param aNotificationName the name of the notification the observer wants to watch @param anObject the object in the notification the observer wants to watch + @param queue is ignored for the moment @param block the block to be executed when the notification is received. */ -- (id )addObserverForName:(CPString)aNotificationName object:(id)anObject usingBlock:(Function)block +- (id )addObserverForName:(CPString)aNotificationName object:(id)anObject queue:(id)queue usingBlock:(Function)block { var registry = [self _registryForNotificationName:aNotificationName], observer = [[_CPNotificationObserver alloc] initWithBlock:block]; @@ -156,10 +157,7 @@ var CPNotificationDefaultCenter = nil; [_unnamedRegistry removeObserver:anObserver object:anObject]; } else - { [[_namedRegistries objectForKey:aNotificationName] removeObserver:anObserver object:anObject]; - } - } /*! diff --git a/Tests/Foundation/CPNotificationCenterTest.j b/Tests/Foundation/CPNotificationCenterTest.j index e630e4064..47aab1e0f 100644 --- a/Tests/Foundation/CPNotificationCenterTest.j +++ b/Tests/Foundation/CPNotificationCenterTest.j @@ -62,8 +62,8 @@ var TestNotification = @"TestNotification"; notificationCount += 1; }; - var observer2 = [center addObserverForName:TestNotification object:2 usingBlock:notificationBlock], - observer25 = [center addObserverForName:TestNotification object:25 usingBlock:notificationBlock]; + var observer2 = [center addObserverForName:TestNotification object:2 queue:nil usingBlock:notificationBlock], + observer25 = [center addObserverForName:TestNotification object:25 queue:nil usingBlock:notificationBlock]; [center postNotificationName:TestNotification object:self]; [self assert:0 equals:notificationCount message:@"observer should only be notified for object '2'"]; @@ -71,7 +71,7 @@ var TestNotification = @"TestNotification"; [center postNotificationName:TestNotification object:2]; [self assert:1 equals:notificationCount message:@"observer should be notified for object '2'"]; - var observerNil = [center addObserverForName:TestNotification object:nil usingBlock:notificationBlock]; + var observerNil = [center addObserverForName:TestNotification object:nil queue:nil usingBlock:notificationBlock]; [center postNotificationName:TestNotification object:2]; [self assert:3 equals:notificationCount message:@"observer should be notified for object '2' and for any object"]; @@ -81,7 +81,7 @@ var TestNotification = @"TestNotification"; [self assert:4 equals:notificationCount message:@"observer should be notified only for any object"]; // At this point we have TestNofication:nil observer and a TestNotification:25 observer. - observer2 = [center addObserverForName:nil object:2 usingBlock:notificationBlock]; + observer2 = [center addObserverForName:nil object:2 queue:nil usingBlock:notificationBlock]; [center postNotificationName:TestNotification object:2]; [self assert:6 equals:notificationCount message:@"observer should be notified for TestNofication and for object '2' (TestNotification)"]; From 31afae71d1ef73e5fbd9153c84d3f21e42f11fec Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Wed, 26 Nov 2014 11:52:25 -0800 Subject: [PATCH 15/18] Typos --- Objective-J/ObjJAcornCompiler.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objective-J/ObjJAcornCompiler.js b/Objective-J/ObjJAcornCompiler.js index ce3009ef7..79646a0e6 100644 --- a/Objective-J/ObjJAcornCompiler.js +++ b/Objective-J/ObjJAcornCompiler.js @@ -1675,7 +1675,7 @@ ClassDeclarationStatement: function(node, st, c) { compiler.classBodyBuffer = new StringBuffer(); // TODO: Check if this is needed if (compiler.getTypeDef(className)) - throw compiler.error_message(className + " is already declared as type", node.classname); + throw compiler.error_message(className + " is already declared as a type", node.classname); if (!generate) saveJSBuffer.concat(compiler.source.substring(compiler.lastPos, node.start)); @@ -2414,7 +2414,7 @@ ClassStatement: function(node, st, c) { var className = node.id.name; if (compiler.getTypeDef(className)) - throw compiler.error_message(className + " is already declared as type", node.id); + throw compiler.error_message(className + " is already declared as a type", node.id); if (!compiler.getClassDef(className)) { classDef = new ClassDef(false, className); From 243024e2322b3208b298e7e3f276af275034a4fe Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Wed, 26 Nov 2014 13:12:39 -0800 Subject: [PATCH 16/18] Fix broken tests due to new objj type checks --- Tests/AppKit/CPArrayControllerTest.j | 3 +++ Tests/AppKit/CPBrowserTest.j | 3 +++ Tests/AppKit/CPKeyValueBindingSimpleBindingsTest.j | 2 ++ Tests/AppKit/CPMenuValidatedUserInterfaceItemTest.j | 4 +++- Tests/AppKit/CPOutlineViewTest.j | 3 +++ Tests/AppKit/CPTokenFieldTest.j | 2 ++ Tests/Foundation/CPKVCArrayTest.j | 3 +++ Tests/Foundation/CPKVOTest.j | 3 +++ Tests/Foundation/CPKeyValueCodingTest.j | 3 +++ .../Preprocessor/OutputTests/Class/accessors.j | 4 ++-- .../Preprocessor/OutputTests/Class/accessors.js | 13 +++++++------ .../OutputTests/Class/root-class-multiple-ivars.j | 2 +- .../OutputTests/Class/root-class-multiple-ivars.js | 3 +-- .../OutputTests/Class/root-class-one-ivar.j | 3 +-- .../OutputTests/Class/root-class-one-ivar.js | 2 +- .../Preprocessor/OutputTests/Class/root-class.j | 2 +- .../Preprocessor/OutputTests/Class/root-class.js | 2 +- 17 files changed, 40 insertions(+), 17 deletions(-) diff --git a/Tests/AppKit/CPArrayControllerTest.j b/Tests/AppKit/CPArrayControllerTest.j index 3365cfdcf..35b8e3388 100644 --- a/Tests/AppKit/CPArrayControllerTest.j +++ b/Tests/AppKit/CPArrayControllerTest.j @@ -3,6 +3,9 @@ @import @import +@class Department +@class Employee + @implementation CPArrayControllerTest : OJTestCase { CPArrayController _arrayController @accessors(property=arrayController); diff --git a/Tests/AppKit/CPBrowserTest.j b/Tests/AppKit/CPBrowserTest.j index 420dfb279..bc29049bb 100644 --- a/Tests/AppKit/CPBrowserTest.j +++ b/Tests/AppKit/CPBrowserTest.j @@ -1,5 +1,8 @@ @import +@class CPBrowserDelegate + + @implementation CPBrowserTest : OJTestCase { CPBrowser browser; diff --git a/Tests/AppKit/CPKeyValueBindingSimpleBindingsTest.j b/Tests/AppKit/CPKeyValueBindingSimpleBindingsTest.j index d9c0e06d1..d1bb9af84 100644 --- a/Tests/AppKit/CPKeyValueBindingSimpleBindingsTest.j +++ b/Tests/AppKit/CPKeyValueBindingSimpleBindingsTest.j @@ -1,6 +1,8 @@ @import +@class Track + /*! Bindings tests exercising the functionality seen in the Cocoa example "SimpleBindingsAdoption". */ diff --git a/Tests/AppKit/CPMenuValidatedUserInterfaceItemTest.j b/Tests/AppKit/CPMenuValidatedUserInterfaceItemTest.j index e60c456db..5757c368d 100644 --- a/Tests/AppKit/CPMenuValidatedUserInterfaceItemTest.j +++ b/Tests/AppKit/CPMenuValidatedUserInterfaceItemTest.j @@ -1,5 +1,7 @@ var CPMenuValidatedUserInterfaceItemTestValidatedItems = []; +@class MenuTarget + @implementation CPMenuValidatedUserInterfaceItemTest : OJTestCase { CPMenu _menu @accessors(property=menu); @@ -83,4 +85,4 @@ var CPMenuValidatedUserInterfaceItemTestValidatedItems = []; } -@end \ No newline at end of file +@end diff --git a/Tests/AppKit/CPOutlineViewTest.j b/Tests/AppKit/CPOutlineViewTest.j index 65219ea41..129c6965b 100644 --- a/Tests/AppKit/CPOutlineViewTest.j +++ b/Tests/AppKit/CPOutlineViewTest.j @@ -1,5 +1,8 @@ @import +@class TestOutlineDataSource + + @implementation CPOutlineViewTest : OJTestCase { CPOutlineView outlineView; diff --git a/Tests/AppKit/CPTokenFieldTest.j b/Tests/AppKit/CPTokenFieldTest.j index 6c8320eeb..cd65113ad 100644 --- a/Tests/AppKit/CPTokenFieldTest.j +++ b/Tests/AppKit/CPTokenFieldTest.j @@ -1,5 +1,7 @@ @import +@class TestDelegateTokenField + [CPApplication sharedApplication]; @implementation CPTokenFieldTest : OJTestCase diff --git a/Tests/Foundation/CPKVCArrayTest.j b/Tests/Foundation/CPKVCArrayTest.j index 12e5edd52..6948d4177 100644 --- a/Tests/Foundation/CPKVCArrayTest.j +++ b/Tests/Foundation/CPKVCArrayTest.j @@ -1,5 +1,8 @@ var COUNTER; +@class TestObject +@class ImplementedTestObject + @implementation CPKVCArrayTest : OJTestCase { TestObject _object @accessors(property=object); diff --git a/Tests/Foundation/CPKVOTest.j b/Tests/Foundation/CPKVOTest.j index 1fa905abd..631e2ac80 100644 --- a/Tests/Foundation/CPKVOTest.j +++ b/Tests/Foundation/CPKVOTest.j @@ -1,6 +1,9 @@ @import @import +@class CarTester +@class ToManyTester + @implementation CPKVOTest : OJTestCase { BOOL _sawInitialObservation; diff --git a/Tests/Foundation/CPKeyValueCodingTest.j b/Tests/Foundation/CPKeyValueCodingTest.j index ac57d9f02..ccf560401 100644 --- a/Tests/Foundation/CPKeyValueCodingTest.j +++ b/Tests/Foundation/CPKeyValueCodingTest.j @@ -22,6 +22,9 @@ @import +@class Department2 +@class Employee2 + var accessIVARS = YES; @implementation KVCTestClass : CPObject diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Class/accessors.j b/Tests/Objective-J/Preprocessor/OutputTests/Class/accessors.j index fe7fcc5de..820cad2f6 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/Class/accessors.j +++ b/Tests/Objective-J/Preprocessor/OutputTests/Class/accessors.j @@ -1,10 +1,10 @@ -@implementation Class +@implementation TestClass { } @end -@implementation Class (Accessors) +@implementation TestClass (Accessors) { Type ivar @accessors; } diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Class/accessors.js b/Tests/Objective-J/Preprocessor/OutputTests/Class/accessors.js index 9db2e1754..ae78cbb53 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/Class/accessors.js +++ b/Tests/Objective-J/Preprocessor/OutputTests/Class/accessors.js @@ -1,13 +1,14 @@ -var the_class=objj_allocateClassPair(Nil,"Class"),meta_class=the_class.isa; +var the_class=objj_allocateClassPair(Nil,"TestClass"),meta_class=the_class.isa; objj_registerClassPair(the_class); -var the_class=objj_getClass("Class"); +var the_class=objj_getClass("TestClass"); if(!the_class){ -throw new SyntaxError("*** Could not find definition for class \"Class\""); +throw new SyntaxError("*** Could not find definition for class \"TestClass\""); } var meta_class=the_class.isa; class_addIvars(the_class,[new objj_ivar("ivar")]); -class_addMethods(the_class,[new objj_method(sel_getUid("ivar"),function $Class__ivar(_1,_2){ +class_addMethods(the_class,[new objj_method(sel_getUid("ivar"),function $TestClass__ivar(_1,_2){ return _1.ivar; -},["Type"]),new objj_method(sel_getUid("setIvar:"),function $Class__setIvar_(_3,_4,_5){ +},["Type"]),new objj_method(sel_getUid("setIvar:"),function $TestClass__setIvar_(_3,_4,_5){ _3.ivar=_5; -},["void","Type"])]); \ No newline at end of file +},["void","Type"])]); + diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.j b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.j index 50d1fa504..603bc25e5 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.j +++ b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.j @@ -1,5 +1,5 @@ -@implementation Class +@implementation TestClass { Type ivar; CPArray array; diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.js b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.js index 7eba069a9..8cf16dc3b 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.js +++ b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-multiple-ivars.js @@ -1,5 +1,4 @@ - -var the_class = objj_allocateClassPair(Nil, "Class"), +var the_class = objj_allocateClassPair(Nil, "TestClass"), meta_class = the_class.isa; class_addIvars(the_class,[new objj_ivar("ivar"), new objj_ivar("array"), new objj_ivar("string"), new objj_ivar("integer")]); diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.j b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.j index 14fc4dd73..3aebab79d 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.j +++ b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.j @@ -1,5 +1,4 @@ - -@implementation Class +@implementation TestClass { Type ivar; } diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.js b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.js index 4c6f93642..165c23dc8 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.js +++ b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class-one-ivar.js @@ -1,5 +1,5 @@ -var the_class = objj_allocateClassPair(Nil, "Class"), +var the_class = objj_allocateClassPair(Nil, "TestClass"), meta_class = the_class.isa; class_addIvars(the_class,[new objj_ivar("ivar")]); diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class.j b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class.j index f0e079126..6f4f77d3d 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class.j +++ b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class.j @@ -1,5 +1,5 @@ -@implementation Class +@implementation TestClass { } @end diff --git a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class.js b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class.js index c266954fc..75528fb97 100644 --- a/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class.js +++ b/Tests/Objective-J/Preprocessor/OutputTests/Class/root-class.js @@ -1,5 +1,5 @@ -var the_class = objj_allocateClassPair(Nil, "Class"), +var the_class = objj_allocateClassPair(Nil, "TestClass"), meta_class = the_class.isa; objj_registerClassPair(the_class); From 02a47dc7b93b866c91d46b3e7313bcb013729780 Mon Sep 17 00:00:00 2001 From: Mathieu Monney Date: Thu, 27 Nov 2014 13:25:29 +0100 Subject: [PATCH 17/18] FIXED bootstrap URL due to github URL change. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index b5a13beaa..ed10bd9e7 100644 --- a/README.markdown +++ b/README.markdown @@ -33,7 +33,7 @@ Getting Started --------------- To get started, download and install the current release version of Cappuccino: - $ curl https://raw.github.com/cappuccino/cappuccino/v0.9.7/bootstrap.sh >/tmp/cappuccino_bootstrap.sh && bash /tmp/cappuccino_bootstrap.sh + $ curl https://raw.githubusercontent.com/cappuccino/cappuccino/0.9.7/bootstrap.sh >/tmp/cappuccino_bootstrap.sh && bash /tmp/cappuccino_bootstrap.sh If you'd just like to get started using Cappuccino for your web apps, you are done. From c3fc6a087a1d4df406599c677a03c36e4eb0adbd Mon Sep 17 00:00:00 2001 From: Mathieu Monney Date: Thu, 27 Nov 2014 13:30:31 +0100 Subject: [PATCH 18/18] Fixed URL, wasn't the tagged released one. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index ed10bd9e7..ed87b834d 100644 --- a/README.markdown +++ b/README.markdown @@ -33,7 +33,7 @@ Getting Started --------------- To get started, download and install the current release version of Cappuccino: - $ curl https://raw.githubusercontent.com/cappuccino/cappuccino/0.9.7/bootstrap.sh >/tmp/cappuccino_bootstrap.sh && bash /tmp/cappuccino_bootstrap.sh + $ curl https://raw.githubusercontent.com/cappuccino/cappuccino/v0.9.7-1/bootstrap.sh >/tmp/cappuccino_bootstrap.sh && bash /tmp/cappuccino_bootstrap.sh If you'd just like to get started using Cappuccino for your web apps, you are done.