From 5144a5a57926207e4aaed0b1872009e4e93c90fd Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Sun, 26 Oct 2008 00:48:49 -0700 Subject: [PATCH] Added @accessor support, @import, and fixed spacing bug with @selector. Reviewed by ross. --- AppKit/AppKit.j | 82 +- AppKit/CPAnimation.j | 5 +- AppKit/CPApplication.j | 13 +- AppKit/CPButton.j | 7 +- AppKit/CPClipView.j | 3 +- AppKit/CPCollectionView.j | 13 +- AppKit/CPColor.j | 9 +- AppKit/CPColorPanel.j | 12 +- AppKit/CPColorPicker.j | 9 +- AppKit/CPColorWell.j | 8 +- AppKit/CPCompatibility.j | 2 +- AppKit/CPControl.j | 7 +- AppKit/CPCookie.j | 4 +- AppKit/CPDocument.j | 9 +- AppKit/CPDocumentController.j | 7 +- AppKit/CPDragServer.j | 9 +- AppKit/CPEvent.j | 3 +- AppKit/CPFlashMovie.j | 2 +- AppKit/CPFlashView.j | 6 +- AppKit/CPFontManager.j | 4 +- AppKit/CPGeometry.j | 3 +- AppKit/CPImage.j | 12 +- AppKit/CPImageView.j | 8 +- AppKit/CPMenu.j | 18 +- AppKit/CPMenuItem.j | 12 +- AppKit/CPOutlineView.j | 2 +- AppKit/CPPanel.j | 2 +- AppKit/CPPasteboard.j | 8 +- AppKit/CPPopUpButton.j | 8 +- AppKit/CPProgressIndicator.j | 7 +- AppKit/CPResponder.j | 3 +- AppKit/CPScrollView.j | 7 +- AppKit/CPScroller.j | 2 +- AppKit/CPSecureTextField.j | 2 +- AppKit/CPSegmentedControl.j | 4 +- AppKit/CPShadow.j | 3 +- AppKit/CPShadowView.j | 11 +- AppKit/CPSlider.j | 3 +- AppKit/CPSliderColorPicker.j | 11 +- AppKit/CPSplitView.j | 4 +- AppKit/CPStringDrawing.j | 2 +- AppKit/CPTabView.j | 7 +- AppKit/CPTabViewItem.j | 5 +- AppKit/CPTableColumn.j | 2 +- AppKit/CPTextField.j | 5 +- AppKit/CPToolbar.j | 7 +- AppKit/CPToolbarItem.j | 9 +- AppKit/CPView.j | 19 +- AppKit/CPWebView.j | 3 +- AppKit/CPWindow.j | 18 +- AppKit/CPWindowController.j | 11 +- AppKit/Cib/CPCib.j | 17 +- AppKit/Cib/_CPCibConnector.j | 4 +- AppKit/Cib/_CPCibCustomObject.j | 2 +- AppKit/Cib/_CPCibCustomView.j | 2 +- AppKit/Cib/_CPCibKeyedUnarchiver.j | 2 +- AppKit/Cib/_CPCibLoading.j | 6 +- AppKit/Cib/_CPCibObjectData.j | 10 +- AppKit/Cib/_CPCibWindowTemplate.j | 2 +- AppKit/CoreAnimation/CAAnimation.j | 6 +- AppKit/CoreAnimation/CABackingStore.j | 5 +- AppKit/CoreAnimation/CAFlashLayer.j | 4 +- AppKit/CoreAnimation/CALayer.j | 8 +- AppKit/CoreAnimation/CAMediaTimingFunction.j | 6 +- AppKit/CoreGraphics/CGAffineTransform.j | 3 +- AppKit/CoreGraphics/CGColor.j | 3 +- AppKit/CoreGraphics/CGContext.j | 6 +- AppKit/CoreGraphics/CGGradient.j | 5 +- AppKit/CoreGraphics/CGPath.j | 5 +- AppKit/Platform/DOM/CPDOMDisplayServer.j | 2 +- AppKit/Platform/DOM/CPDOMWindowBridge.j | 10 +- AppKit/Platform/DOM/CPDOMWindowLayer.j | 4 +- AppKit/_CPImageAndTitleView.j | 12 +- AppKit/_CPWindowView.j | 4 +- Foundation/CPArray.j | 10 +- Foundation/CPBundle.j | 5 +- Foundation/CPCoder.j | 5 +- Foundation/CPData.j | 5 +- Foundation/CPDate.j | 5 +- Foundation/CPDictionary.j | 8 +- Foundation/CPEnumerator.j | 3 +- Foundation/CPException.j | 6 +- Foundation/CPIndexSet.j | 5 +- Foundation/CPInvocation.j | 5 +- Foundation/CPJSONPConnection.j | 3 +- Foundation/CPKeyValueCoding.j | 7 +- Foundation/CPKeyValueObserving.j | 9 +- Foundation/CPKeyedArchiver.j | 15 +- Foundation/CPKeyedUnarchiver.j | 4 +- Foundation/CPNotification.j | 5 +- Foundation/CPNotificationCenter.j | 8 +- Foundation/CPNull.j | 3 +- Foundation/CPNumber.j | 5 +- Foundation/CPObjJRuntime.j | 3 +- Foundation/CPPropertyListSerialization.j | 3 + Foundation/CPRunLoop.j | 6 +- Foundation/CPSortDescriptor.j | 5 +- Foundation/CPString.j | 7 +- Foundation/CPURLConnection.j | 8 +- Foundation/CPURLRequest.j | 3 +- Foundation/CPURLResponse.j | 2 +- Foundation/CPUndoManager.j | 5 +- Foundation/CPUserSessionManager.j | 4 +- Foundation/CPValue.j | 5 +- Foundation/Foundation.j | 66 +- Objective-J/constants.js | 12 + Objective-J/preprocess.js | 890 +++++++++++-------- Tools/nib2cib/NSAppKit.j | 26 +- Tools/nib2cib/NSArray.j | 2 +- Tools/nib2cib/NSButton.j | 6 +- Tools/nib2cib/NSCell.j | 4 +- Tools/nib2cib/NSControl.j | 6 +- Tools/nib2cib/NSCustomObject.j | 2 +- Tools/nib2cib/NSCustomView.j | 4 +- Tools/nib2cib/NSFont.j | 3 +- Tools/nib2cib/NSFoundation.j | 2 +- Tools/nib2cib/NSIBObjectData.j | 5 +- Tools/nib2cib/NSNibConnector.j | 2 +- Tools/nib2cib/NSResponder.j | 2 +- Tools/nib2cib/NSSlider.j | 4 +- Tools/nib2cib/NSSplitView.j | 2 +- Tools/nib2cib/NSView.j | 2 +- Tools/nib2cib/NSWindowTemplate.j | 2 +- Tools/nib2cib/main.j | 8 +- 124 files changed, 1017 insertions(+), 760 deletions(-) diff --git a/AppKit/AppKit.j b/AppKit/AppKit.j index b0a9f66d1..2c24e60d9 100644 --- a/AppKit/AppKit.j +++ b/AppKit/AppKit.j @@ -20,44 +20,44 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CALayer.j" -import "CPAnimation.j" -import "CPApplication.j" -import "CPButton.j" -import "CPClipView.j" -import "CPCollectionView.j" -import "CPColor.j" -import "CPColorPanel.j" -import "CPColorWell.j" -import "CPCompatibility.j" -import "CPControl.j" -import "CPCookie.j" -import "CPDocument.j" -import "CPDocumentController.j" -import "CPEvent.j" -import "CPFont.j" -import "CPFontManager.j" -import "CPGeometry.j" -import "CPImage.j" -import "CPImageView.j" -import "CPMenu.j" -import "CPMenuItem.j" -import "CPPanel.j" -import "CPPasteboard.j" -import "CPPopUpButton.j" -import "CPProgressIndicator.j" -import "CPResponder.j" -import "CPScroller.j" -import "CPScrollView.j" -import "CPSecureTextField.j" -import "CPSegmentedControl.j" -import "CPShadow.j" -import "CPSlider.j" -import "CPSplitView.j" -import "CPTextField.j" -import "CPToolbar.j" -import "CPToolbarItem.j" -import "CPView.j" -import "CPWebView.j" -import "CPWindow.j" -import "CPWindowController.j" +@import "CALayer.j" +@import "CPAnimation.j" +@import "CPApplication.j" +@import "CPButton.j" +@import "CPClipView.j" +@import "CPCollectionView.j" +@import "CPColor.j" +@import "CPColorPanel.j" +@import "CPColorWell.j" +@import "CPCompatibility.j" +@import "CPControl.j" +@import "CPCookie.j" +@import "CPDocument.j" +@import "CPDocumentController.j" +@import "CPEvent.j" +@import "CPFont.j" +@import "CPFontManager.j" +@import "CPGeometry.j" +@import "CPImage.j" +@import "CPImageView.j" +@import "CPMenu.j" +@import "CPMenuItem.j" +@import "CPPanel.j" +@import "CPPasteboard.j" +@import "CPPopUpButton.j" +@import "CPProgressIndicator.j" +@import "CPResponder.j" +@import "CPScroller.j" +@import "CPScrollView.j" +@import "CPSecureTextField.j" +@import "CPSegmentedControl.j" +@import "CPShadow.j" +@import "CPSlider.j" +@import "CPSplitView.j" +@import "CPTextField.j" +@import "CPToolbar.j" +@import "CPToolbarItem.j" +@import "CPView.j" +@import "CPWebView.j" +@import "CPWindow.j" +@import "CPWindowController.j" diff --git a/AppKit/CPAnimation.j b/AppKit/CPAnimation.j index 36e5df43a..d60c13526 100644 --- a/AppKit/CPAnimation.j +++ b/AppKit/CPAnimation.j @@ -20,9 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import + +@import "CAMediaTimingFunction.j" -import "CAMediaTimingFunction.j" /* @global diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index 0529d3f51..6a223543d 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -20,13 +20,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import + +@import "CPCompatibility.j" +@import "CPEvent.j" +@import "CPMenu.j" +@import "CPResponder.j" +@import "CPDocumentController.j" -import "CPCompatibility.j" -import "CPEvent.j" -import "CPMenu.j" -import "CPResponder.j" -import "CPDocumentController.j" CPApp = nil; diff --git a/AppKit/CPButton.j b/AppKit/CPButton.j index f30806fc6..a28fba9fb 100644 --- a/AppKit/CPButton.j +++ b/AppKit/CPButton.j @@ -20,13 +20,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "_CPImageAndTitleView.j" -import "CGGeometry.j" +@import "_CPImageAndTitleView.j" +@import "CGGeometry.j" -import "CPControl.j" +@import "CPControl.j" #include "CoreGraphics/CGGeometry.h" + CPScaleProportionally = 0; CPScaleToFit = 1; CPScaleNone = 2; diff --git a/AppKit/CPClipView.j b/AppKit/CPClipView.j index 45081b1c5..70638ac65 100644 --- a/AppKit/CPClipView.j +++ b/AppKit/CPClipView.j @@ -20,10 +20,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPView.j" +@import "CPView.j" #include "CoreGraphics/CGGeometry.h" + /*! @class CPClipView CPClipView allows you to define a clip rect and display only that portion of its containing view. diff --git a/AppKit/CPCollectionView.j b/AppKit/CPCollectionView.j index b35a66f5e..e1e537dcd 100644 --- a/AppKit/CPCollectionView.j +++ b/AppKit/CPCollectionView.j @@ -20,13 +20,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import -import -import -import +@import +@import +@import +@import +@import + +@import -import /*! @class CPCollectionView diff --git a/AppKit/CPColor.j b/AppKit/CPColor.j index 09ab40804..5a5eb98c1 100644 --- a/AppKit/CPColor.j +++ b/AppKit/CPColor.j @@ -20,12 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import -import "CGColor.j" +@import "CGColor.j" + +@import "CPCompatibility.j" +@import "CPImage.j" -import "CPCompatibility.j" -import "CPImage.j" var _redComponent = 0, _greenComponent = 1, diff --git a/AppKit/CPColorPanel.j b/AppKit/CPColorPanel.j index 58cdbed40..0bf26d314 100644 --- a/AppKit/CPColorPanel.j +++ b/AppKit/CPColorPanel.j @@ -20,12 +20,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPButton.j" -import "CPColorPicker.j" -import "CPCookie.j" -import "CPPanel.j" -import "CPSliderColorPicker.j" -import "CPView.j" +@import "CPButton.j" +@import "CPColorPicker.j" +@import "CPCookie.j" +@import "CPPanel.j" +@import "CPSliderColorPicker.j" +@import "CPView.j" CPColorPanelColorDidChangeNotification = @"CPColorPanelColorDidChangeNotification"; diff --git a/AppKit/CPColorPicker.j b/AppKit/CPColorPicker.j index 65465f1b1..544d93661 100644 --- a/AppKit/CPColorPicker.j +++ b/AppKit/CPColorPicker.j @@ -20,10 +20,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import -import -import +@import +@import +@import +@import + /*! @class CPColorPicker diff --git a/AppKit/CPColorWell.j b/AppKit/CPColorWell.j index f72bcc21e..e1cdd1dbc 100644 --- a/AppKit/CPColorWell.j +++ b/AppKit/CPColorWell.j @@ -20,11 +20,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import -import "CPView.j" -import "CPColor.j" -import "CPColorPanel.j" +@import "CPView.j" +@import "CPColor.j" +@import "CPColorPanel.j" var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiveNotification"; diff --git a/AppKit/CPCompatibility.j b/AppKit/CPCompatibility.j index bd5ab647e..183b298fa 100644 --- a/AppKit/CPCompatibility.j +++ b/AppKit/CPCompatibility.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPEvent.j" +@import "CPEvent.j" // Browser Engines CPUnknownBrowserEngine = 0; diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j index 75b661c96..a357ec925 100644 --- a/AppKit/CPControl.j +++ b/AppKit/CPControl.j @@ -20,12 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPFont.j" -import "CPShadow.j" -import "CPView.j" +@import "CPFont.j" +@import "CPShadow.j" +@import "CPView.j" #include "Platform/Platform.h" + /* @global @group CPTextAlignment diff --git a/AppKit/CPCookie.j b/AppKit/CPCookie.j index 396d74a73..460e92040 100644 --- a/AppKit/CPCookie.j +++ b/AppKit/CPCookie.j @@ -20,8 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import +@import +@import /*! @class CPCookie diff --git a/AppKit/CPDocument.j b/AppKit/CPDocument.j index 90b3ee443..27274a1da 100644 --- a/AppKit/CPDocument.j +++ b/AppKit/CPDocument.j @@ -20,11 +20,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import +@import +@import + +@import "CPResponder.j" +@import "CPWindowController.j" -import "CPResponder.j" -import "CPWindowController.j" /* @global diff --git a/AppKit/CPDocumentController.j b/AppKit/CPDocumentController.j index da3bc1cdd..4bde36b86 100644 --- a/AppKit/CPDocumentController.j +++ b/AppKit/CPDocumentController.j @@ -20,10 +20,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import +@import +@import + +@import "CPDocument.j" -import "CPDocument.j" var CPSharedDocumentController = nil; diff --git a/AppKit/CPDragServer.j b/AppKit/CPDragServer.j index b27c0d142..8ef08829d 100644 --- a/AppKit/CPDragServer.j +++ b/AppKit/CPDragServer.j @@ -20,10 +20,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import -import -import +@import +@import +@import +@import + var CPSharedDragServer = nil; diff --git a/AppKit/CPEvent.j b/AppKit/CPEvent.j index 555ba7c96..413e5079f 100644 --- a/AppKit/CPEvent.j +++ b/AppKit/CPEvent.j @@ -20,10 +20,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import #include "CoreGraphics/CGGeometry.h" + /* @global @group CPEventType diff --git a/AppKit/CPFlashMovie.j b/AppKit/CPFlashMovie.j index 278d0664c..1fca8eccf 100644 --- a/AppKit/CPFlashMovie.j +++ b/AppKit/CPFlashMovie.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import @implementation CPFlashMovie : CPObject diff --git a/AppKit/CPFlashView.j b/AppKit/CPFlashView.j index 95db3b039..f1cfa724b 100644 --- a/AppKit/CPFlashView.j +++ b/AppKit/CPFlashView.j @@ -20,9 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPDOMWindowBridge.j" -import "CPFlashMovie.j" -import "CPView.j" +@import "CPDOMWindowBridge.j" +@import "CPFlashMovie.j" +@import "CPView.j" @implementation CPFlashView : CPView diff --git a/AppKit/CPFontManager.j b/AppKit/CPFontManager.j index c28e93dbd..607bdbf1a 100644 --- a/AppKit/CPFontManager.j +++ b/AppKit/CPFontManager.j @@ -20,9 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import -import +@import var CPSharedFontManager = nil, diff --git a/AppKit/CPGeometry.j b/AppKit/CPGeometry.j index 027d3a920..b17470d72 100644 --- a/AppKit/CPGeometry.j +++ b/AppKit/CPGeometry.j @@ -20,7 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CGGeometry.j" +@import "CGGeometry.j" + CPMinXEdge = 0; CPMinYEdge = 1; diff --git a/AppKit/CPImage.j b/AppKit/CPImage.j index 1c3b448d8..fec6095e0 100644 --- a/AppKit/CPImage.j +++ b/AppKit/CPImage.j @@ -20,13 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import -import -import -import +@import +@import +@import +@import +@import -import "CPGeometry.j" +@import "CPGeometry.j" CPImageLoadStatusInitialized = 0; CPImageLoadStatusLoading = 1; diff --git a/AppKit/CPImageView.j b/AppKit/CPImageView.j index 87141bdaa..a62f9e7ba 100644 --- a/AppKit/CPImageView.j +++ b/AppKit/CPImageView.j @@ -20,11 +20,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import -import "CPControl.j" -import "CPImage.j" -import "CPShadowView.j" +@import "CPControl.j" +@import "CPImage.j" +@import "CPShadowView.j" #include "Platform/Platform.h" #include "Platform/DOM/CPDOMDisplayServer.h" diff --git a/AppKit/CPMenu.j b/AppKit/CPMenu.j index e2c3f7750..acf210e68 100644 --- a/AppKit/CPMenu.j +++ b/AppKit/CPMenu.j @@ -20,16 +20,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import -import -import +@import +@import +@import +@import -import "_CPImageAndTitleView.j" -import "CPApplication.j" -import "CPClipView.j" -import "CPMenuItem.j" -import "CPPanel.j" +@import "_CPImageAndTitleView.j" +@import "CPApplication.j" +@import "CPClipView.j" +@import "CPMenuItem.j" +@import "CPPanel.j" #include "Platform/Platform.h" diff --git a/AppKit/CPMenuItem.j b/AppKit/CPMenuItem.j index f5fbd792e..1459f3bcb 100644 --- a/AppKit/CPMenuItem.j +++ b/AppKit/CPMenuItem.j @@ -20,13 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import -import +@import +@import +@import -import -import -import +@import +@import +@import /*! @class CPMenuItem diff --git a/AppKit/CPOutlineView.j b/AppKit/CPOutlineView.j index 1b938bece..a2af0bfb9 100644 --- a/AppKit/CPOutlineView.j +++ b/AppKit/CPOutlineView.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPTableView.j" +@import "CPTableView.j" /*! @ignore diff --git a/AppKit/CPPanel.j b/AppKit/CPPanel.j index e1bebf005..93798d28e 100644 --- a/AppKit/CPPanel.j +++ b/AppKit/CPPanel.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPWindow.j" +@import "CPWindow.j" CPOKButton = 1; diff --git a/AppKit/CPPasteboard.j b/AppKit/CPPasteboard.j index 2ab4a2362..9037b1d8a 100644 --- a/AppKit/CPPasteboard.j +++ b/AppKit/CPPasteboard.j @@ -20,10 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import -import -import +@import +@import +@import +@import CPGeneralPboard = @"CPGeneralPboard"; diff --git a/AppKit/CPPopUpButton.j b/AppKit/CPPopUpButton.j index 0d3b36f87..dff075dcf 100644 --- a/AppKit/CPPopUpButton.j +++ b/AppKit/CPPopUpButton.j @@ -20,10 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPButton.j" -import "CPGeometry.j" -import "CPMenu.j" -import "CPMenuItem.j" +@import "CPButton.j" +@import "CPGeometry.j" +@import "CPMenu.j" +@import "CPMenuItem.j" var VISIBLE_MARGIN = 7.0; diff --git a/AppKit/CPProgressIndicator.j b/AppKit/CPProgressIndicator.j index 1d17cabef..f4f345d2e 100644 --- a/AppKit/CPProgressIndicator.j +++ b/AppKit/CPProgressIndicator.j @@ -20,12 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import -import +@import +@import +@import #include "CoreGraphics/CGGeometry.h" + /* @global @group CPProgressIndicatorStyle diff --git a/AppKit/CPResponder.j b/AppKit/CPResponder.j index cc475b7f3..6331472fb 100644 --- a/AppKit/CPResponder.j +++ b/AppKit/CPResponder.j @@ -20,7 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import + CPDeleteKeyCode = 8; CPUpArrowKeyCode = 63232; diff --git a/AppKit/CPScrollView.j b/AppKit/CPScrollView.j index ec2fb1d7c..c0710de4d 100644 --- a/AppKit/CPScrollView.j +++ b/AppKit/CPScrollView.j @@ -20,12 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPView.j" -import "CPClipView.j" -import "CPScroller.j" +@import "CPView.j" +@import "CPClipView.j" +@import "CPScroller.j" #include "CoreGraphics/CGGeometry.h" + /*! @class CPScrollView Used to display views that are too large for the viewing area. the CPScrollView diff --git a/AppKit/CPScroller.j b/AppKit/CPScroller.j index bbab08d1f..12bdb3bc6 100644 --- a/AppKit/CPScroller.j +++ b/AppKit/CPScroller.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPControl.j" +@import "CPControl.j" #include "CoreGraphics/CGGeometry.h" diff --git a/AppKit/CPSecureTextField.j b/AppKit/CPSecureTextField.j index 145c4dce1..d53c3402e 100644 --- a/AppKit/CPSecureTextField.j +++ b/AppKit/CPSecureTextField.j @@ -1,4 +1,4 @@ -import "CPTextField.j" +@import "CPTextField.j" #include "Platform/Platform.h" diff --git a/AppKit/CPSegmentedControl.j b/AppKit/CPSegmentedControl.j index 79724ac03..3721bc29b 100644 --- a/AppKit/CPSegmentedControl.j +++ b/AppKit/CPSegmentedControl.j @@ -20,9 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import -import "CPControl.j" +@import "CPControl.j" /* @global diff --git a/AppKit/CPShadow.j b/AppKit/CPShadow.j index 64ee6d091..ffd825bbf 100644 --- a/AppKit/CPShadow.j +++ b/AppKit/CPShadow.j @@ -20,7 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import + /*! @class CPShadow diff --git a/AppKit/CPShadowView.j b/AppKit/CPShadowView.j index 0f306e237..8b31ad4e3 100644 --- a/AppKit/CPShadowView.j +++ b/AppKit/CPShadowView.j @@ -20,12 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import + +@import "CGGeometry.j" +@import "CPImage.j" +@import "CPImageView.j" +@import "CPView.j" -import "CGGeometry.j" -import "CPImage.j" -import "CPImageView.j" -import "CPView.j" #include "CoreGraphics/CGGeometry.h" diff --git a/AppKit/CPSlider.j b/AppKit/CPSlider.j index 5372740ee..13f71a3aa 100644 --- a/AppKit/CPSlider.j +++ b/AppKit/CPSlider.j @@ -20,7 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPControl.j" +@import "CPControl.j" + var CPSliderHorizontalKnobImage = nil, CPSliderHorizontalBarLeftImage = nil, diff --git a/AppKit/CPSliderColorPicker.j b/AppKit/CPSliderColorPicker.j index ef48581af..2d5fc5cea 100644 --- a/AppKit/CPSliderColorPicker.j +++ b/AppKit/CPSliderColorPicker.j @@ -20,12 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import + +@import +@import +@import +@import -import -import -import -import /* @ignore diff --git a/AppKit/CPSplitView.j b/AppKit/CPSplitView.j index 93a0d6445..89727ba3b 100644 --- a/AppKit/CPSplitView.j +++ b/AppKit/CPSplitView.j @@ -20,8 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPImage.j" -import "CPView.j" +@import "CPImage.j" +@import "CPView.j" #include "CoreGraphics/CGGeometry.h" #include "Platform/Platform.h" diff --git a/AppKit/CPStringDrawing.j b/AppKit/CPStringDrawing.j index 15e224fc4..78028180b 100644 --- a/AppKit/CPStringDrawing.j +++ b/AppKit/CPStringDrawing.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import var CPStringReferenceElement = nil; diff --git a/AppKit/CPTabView.j b/AppKit/CPTabView.j index f182ae0f1..3af164570 100644 --- a/AppKit/CPTabView.j +++ b/AppKit/CPTabView.j @@ -20,12 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPImageView.j" -import "CPTabViewItem.j" -import "CPView.j" +@import "CPImageView.j" +@import "CPTabViewItem.j" +@import "CPView.j" #include "CoreGraphics/CGGeometry.h" + /* Places tabs on top with a bezeled border. @global diff --git a/AppKit/CPTabViewItem.j b/AppKit/CPTabViewItem.j index 626465d63..b1906576a 100644 --- a/AppKit/CPTabViewItem.j +++ b/AppKit/CPTabViewItem.j @@ -20,9 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import + +@import -import /* The tab is currently selected. diff --git a/AppKit/CPTableColumn.j b/AppKit/CPTableColumn.j index 6c5b17297..09046f916 100644 --- a/AppKit/CPTableColumn.j +++ b/AppKit/CPTableColumn.j @@ -20,8 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +@import -import /* @ignore diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 7f9fe736f..512fcada9 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -20,12 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPControl.j" -import "CPStringDrawing.j" +@import "CPControl.j" +@import "CPStringDrawing.j" #include "Platform/Platform.h" #include "Platform/DOM/CPDOMDisplayServer.h" + /* @global @group CPLineBreakMode diff --git a/AppKit/CPToolbar.j b/AppKit/CPToolbar.j index dfb8d2f7e..816a4e8dc 100644 --- a/AppKit/CPToolbar.j +++ b/AppKit/CPToolbar.j @@ -20,10 +20,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import + +@import "CPPopUpButton.j" +@import "CPToolbarItem.j" -import "CPPopUpButton.j" -import "CPToolbarItem.j" /* @global diff --git a/AppKit/CPToolbarItem.j b/AppKit/CPToolbarItem.j index 4e4c524b3..6416a7e48 100644 --- a/AppKit/CPToolbarItem.j +++ b/AppKit/CPToolbarItem.j @@ -20,11 +20,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import +@import +@import + +@import +@import -import -import /* @global diff --git a/AppKit/CPView.j b/AppKit/CPView.j index c1f2e5d86..866fbaec2 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -20,17 +20,18 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import +@import +@import -import "CGAffineTransform.j" -import "CGGeometry.j" +@import "CGAffineTransform.j" +@import "CGGeometry.j" + +@import "CPColor.j" +@import "CPDOMDisplayServer.j" +@import "CPGeometry.j" +@import "CPResponder.j" +@import "CPGraphicsContext.j" -import "CPColor.j" -import "CPDOMDisplayServer.j" -import "CPGeometry.j" -import "CPResponder.j" -import "CPGraphicsContext.j" #include "Platform/Platform.h" #include "CoreGraphics/CGAffineTransform.h" diff --git a/AppKit/CPWebView.j b/AppKit/CPWebView.j index 2240d4dc0..0faf788f2 100644 --- a/AppKit/CPWebView.j +++ b/AppKit/CPWebView.j @@ -20,7 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPView.j" +@import "CPView.j" + // FIXME: implement these where possible: /* diff --git a/AppKit/CPWindow.j b/AppKit/CPWindow.j index 4e81213f5..ed41510d5 100644 --- a/AppKit/CPWindow.j +++ b/AppKit/CPWindow.j @@ -20,12 +20,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import +@import +@import -import "CGGeometry.j" -import "CPAnimation.j" -import "CPResponder.j" +@import "CGGeometry.j" +@import "CPAnimation.j" +@import "CPResponder.j" #include "Platform/Platform.h" #include "Platform/DOM/CPDOMDisplayServer.h" @@ -1750,7 +1750,7 @@ var interpolate = function(fromValue, toValue, progress) @end -import "CPDragServer.j" -import "CPDOMWindowBridge.j" -import "_CPWindowView.j" -import "CPView.j" +@import "CPDragServer.j" +@import "CPDOMWindowBridge.j" +@import "_CPWindowView.j" +@import "CPView.j" diff --git a/AppKit/CPWindowController.j b/AppKit/CPWindowController.j index 8c398f9c4..fe7db2f2c 100644 --- a/AppKit/CPWindowController.j +++ b/AppKit/CPWindowController.j @@ -20,15 +20,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import +@import +@import -import "CPResponder.j" -import "CPWindow.j" -import "CPDocument.j" +@import "CPResponder.j" +@import "CPWindow.j" +@import "CPDocument.j" #include "Platform/Platform.h" + /*! @class CPWindowController An instance of a CPWindowController manages a CPWindow. It has methods diff --git a/AppKit/Cib/CPCib.j b/AppKit/Cib/CPCib.j index 05ab20eb4..62ea03c1b 100644 --- a/AppKit/Cib/CPCib.j +++ b/AppKit/Cib/CPCib.j @@ -20,15 +20,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import -import +@import +@import +@import + +@import "_CPCibCustomObject.j" +@import "_CPCibCustomView.j" +@import "_CPCibKeyedUnarchiver.j" +@import "_CPCibObjectData.j" +@import "_CPCibWindowTemplate.j" -import "_CPCibCustomObject.j" -import "_CPCibCustomView.j" -import "_CPCibKeyedUnarchiver.j" -import "_CPCibObjectData.j" -import "_CPCibWindowTemplate.j" CPCibOwner = @"CPCibOwner", CPCibTopLevelObjects = @"CPCibTopLevelObjects"; diff --git a/AppKit/Cib/_CPCibConnector.j b/AppKit/Cib/_CPCibConnector.j index 21225891e..324f75cfe 100644 --- a/AppKit/Cib/_CPCibConnector.j +++ b/AppKit/Cib/_CPCibConnector.j @@ -1,6 +1,6 @@ -import -import +@import +@import var _CPCibConnectorSourceKey = @"_CPCibConnectorSourceKey", diff --git a/AppKit/Cib/_CPCibCustomObject.j b/AppKit/Cib/_CPCibCustomObject.j index 5064784d8..61a8374b1 100644 --- a/AppKit/Cib/_CPCibCustomObject.j +++ b/AppKit/Cib/_CPCibCustomObject.j @@ -1,5 +1,5 @@ -import +@import var _CPCibCustomObjectClassName = @"_CPCibCustomObjectClassName"; diff --git a/AppKit/Cib/_CPCibCustomView.j b/AppKit/Cib/_CPCibCustomView.j index bffe2b357..b71fa4593 100644 --- a/AppKit/Cib/_CPCibCustomView.j +++ b/AppKit/Cib/_CPCibCustomView.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPView.j" +@import "CPView.j" /* @ignore */ diff --git a/AppKit/Cib/_CPCibKeyedUnarchiver.j b/AppKit/Cib/_CPCibKeyedUnarchiver.j index 3776cc5a8..f05af5396 100644 --- a/AppKit/Cib/_CPCibKeyedUnarchiver.j +++ b/AppKit/Cib/_CPCibKeyedUnarchiver.j @@ -1,5 +1,5 @@ -import +@import @implementation _CPCibKeyedUnarchiver : CPKeyedUnarchiver diff --git a/AppKit/Cib/_CPCibLoading.j b/AppKit/Cib/_CPCibLoading.j index 6c3a46438..8cc04543e 100644 --- a/AppKit/Cib/_CPCibLoading.j +++ b/AppKit/Cib/_CPCibLoading.j @@ -20,9 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import -import +@import +@import +@import var CPCibOwner = @"CPCibOwner"; diff --git a/AppKit/Cib/_CPCibObjectData.j b/AppKit/Cib/_CPCibObjectData.j index f336e6942..b992d18b5 100644 --- a/AppKit/Cib/_CPCibObjectData.j +++ b/AppKit/Cib/_CPCibObjectData.j @@ -20,12 +20,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import -import +@import +@import +@import -import "CPCib.j" -import "_CPCibConnector.j" +@import "CPCib.j" +@import "_CPCibConnector.j" @implementation _CPCibObjectData : CPObject diff --git a/AppKit/Cib/_CPCibWindowTemplate.j b/AppKit/Cib/_CPCibWindowTemplate.j index dec6bd3c4..addf32c19 100644 --- a/AppKit/Cib/_CPCibWindowTemplate.j +++ b/AppKit/Cib/_CPCibWindowTemplate.j @@ -1,5 +1,5 @@ -import +@import var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey", diff --git a/AppKit/CoreAnimation/CAAnimation.j b/AppKit/CoreAnimation/CAAnimation.j index 12731968a..d94804b7f 100644 --- a/AppKit/CoreAnimation/CAAnimation.j +++ b/AppKit/CoreAnimation/CAAnimation.j @@ -20,10 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import +@import +@import -import "CAMediaTimingFunction.j" +@import "CAMediaTimingFunction.j" /* This is an animation class. diff --git a/AppKit/CoreAnimation/CABackingStore.j b/AppKit/CoreAnimation/CABackingStore.j index b70bd44cf..9a0b53ce7 100644 --- a/AppKit/CoreAnimation/CABackingStore.j +++ b/AppKit/CoreAnimation/CABackingStore.j @@ -20,11 +20,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CGGeometry.j" -import "CPCompatibility.j" +@import "CGGeometry.j" +@import "CPCompatibility.j" #define PIXEL(pixels) pixels + "px"; + function CABackingStoreGetContext(aBackingStore) { return aBackingStore.context; diff --git a/AppKit/CoreAnimation/CAFlashLayer.j b/AppKit/CoreAnimation/CAFlashLayer.j index e7a5bdfba..f70af2587 100644 --- a/AppKit/CoreAnimation/CAFlashLayer.j +++ b/AppKit/CoreAnimation/CAFlashLayer.j @@ -20,8 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CALayer.j" -import "CPFlashMovie.j" +@import "CALayer.j" +@import "CPFlashMovie.j" @implementation CAFlashLayer : CALayer diff --git a/AppKit/CoreAnimation/CALayer.j b/AppKit/CoreAnimation/CALayer.j index cde607bb3..583ad8ccc 100644 --- a/AppKit/CoreAnimation/CALayer.j +++ b/AppKit/CoreAnimation/CALayer.j @@ -20,12 +20,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import -import +@import -import -import +@import +@import #include "../CoreGraphics/CGGeometry.h" #include "../CoreGraphics/CGAffineTransform.j" diff --git a/AppKit/CoreAnimation/CAMediaTimingFunction.j b/AppKit/CoreAnimation/CAMediaTimingFunction.j index eb97fd140..9a6091da1 100644 --- a/AppKit/CoreAnimation/CAMediaTimingFunction.j +++ b/AppKit/CoreAnimation/CAMediaTimingFunction.j @@ -20,9 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import -import +@import +@import +@import kCAMediaTimingFunctionLinear = @"kCAMediaTimingFunctionLinear"; diff --git a/AppKit/CoreGraphics/CGAffineTransform.j b/AppKit/CoreGraphics/CGAffineTransform.j index bcbc84dc1..b366ed842 100644 --- a/AppKit/CoreGraphics/CGAffineTransform.j +++ b/AppKit/CoreGraphics/CGAffineTransform.j @@ -25,7 +25,8 @@ #define _function(inline) function inline { return _##inline; } -import "CGGeometry.j" +@import "CGGeometry.j" + _function(CGAffineTransformMake(a, b, c, d, tx, ty)) _function(CGAffineTransformMakeIdentity()) diff --git a/AppKit/CoreGraphics/CGColor.j b/AppKit/CoreGraphics/CGColor.j index c7796ff51..fd48edb6f 100644 --- a/AppKit/CoreGraphics/CGColor.j +++ b/AppKit/CoreGraphics/CGColor.j @@ -21,7 +21,8 @@ */ //import "CGPattern.j" -import "CGColorSpace.j" +@import "CGColorSpace.j" + // FIXME: Move this to Objective-J.js!!! var CFTypeGlobalCount = 0; diff --git a/AppKit/CoreGraphics/CGContext.j b/AppKit/CoreGraphics/CGContext.j index b43c82c6b..e536a52d8 100644 --- a/AppKit/CoreGraphics/CGContext.j +++ b/AppKit/CoreGraphics/CGContext.j @@ -23,9 +23,9 @@ #include "CGGeometry.h" #include "CGAffineTransform.h" -import "CGGeometry.j" -import "CGAffineTransform.j" -import "CGPath.j" +@import "CGGeometry.j" +@import "CGAffineTransform.j" +@import "CGPath.j" kCGLineCapButt = 0; kCGLineCapRound = 1; diff --git a/AppKit/CoreGraphics/CGGradient.j b/AppKit/CoreGraphics/CGGradient.j index b46bc35ab..a97d23103 100644 --- a/AppKit/CoreGraphics/CGGradient.j +++ b/AppKit/CoreGraphics/CGGradient.j @@ -20,8 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CGColor.j" -import "CGColorSpace.j" +@import "CGColor.j" +@import "CGColorSpace.j" + kCGGradientDrawsBeforeStartLocation = 1 << 0; kCGGradientDrawsAfterEndLocation = 1 << 1; diff --git a/AppKit/CoreGraphics/CGPath.j b/AppKit/CoreGraphics/CGPath.j index f06095629..00a3d542d 100644 --- a/AppKit/CoreGraphics/CGPath.j +++ b/AppKit/CoreGraphics/CGPath.j @@ -23,8 +23,9 @@ #include "CGGeometry.h" #include "CGAffineTransform.h" -import "CGGeometry.j" -import "CGAffineTransform.j" +@import "CGGeometry.j" +@import "CGAffineTransform.j" + kCGPathElementMoveToPoint = 0; kCGPathElementAddLineToPoint = 1; diff --git a/AppKit/Platform/DOM/CPDOMDisplayServer.j b/AppKit/Platform/DOM/CPDOMDisplayServer.j index b2338c339..d5dd91280 100644 --- a/AppKit/Platform/DOM/CPDOMDisplayServer.j +++ b/AppKit/Platform/DOM/CPDOMDisplayServer.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import #include "../../CoreGraphics/CGAffineTransform.h" #include "CPDOMDisplayServer.h" diff --git a/AppKit/Platform/DOM/CPDOMWindowBridge.j b/AppKit/Platform/DOM/CPDOMWindowBridge.j index bd099c6e9..f6c2746eb 100644 --- a/AppKit/Platform/DOM/CPDOMWindowBridge.j +++ b/AppKit/Platform/DOM/CPDOMWindowBridge.j @@ -20,13 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import +@import +@import -import "CPEvent.j" -import "CPCompatibility.j" +@import "CPEvent.j" +@import "CPCompatibility.j" -import "CPDOMWindowLayer.j" +@import "CPDOMWindowLayer.j" #import "../../CoreGraphics/CGGeometry.h" diff --git a/AppKit/Platform/DOM/CPDOMWindowLayer.j b/AppKit/Platform/DOM/CPDOMWindowLayer.j index 85393aa2a..aec5d4868 100644 --- a/AppKit/Platform/DOM/CPDOMWindowLayer.j +++ b/AppKit/Platform/DOM/CPDOMWindowLayer.j @@ -20,8 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import +@import +@import #include "CPDOMDisplayServer.h" diff --git a/AppKit/_CPImageAndTitleView.j b/AppKit/_CPImageAndTitleView.j index 9db027d95..3486fa4f1 100644 --- a/AppKit/_CPImageAndTitleView.j +++ b/AppKit/_CPImageAndTitleView.j @@ -20,13 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import -import "CPColor.j" -import "CPFont.j" -import "CPImage.j" -import "CPTextField.j" -import "CPView.j" +@import "CPColor.j" +@import "CPFont.j" +@import "CPImage.j" +@import "CPTextField.j" +@import "CPView.j" #include "Platform/Platform.h" #include "Platform/DOM/CPDOMDisplayServer.h" diff --git a/AppKit/_CPWindowView.j b/AppKit/_CPWindowView.j index 7bbadec51..8954d52f4 100644 --- a/AppKit/_CPWindowView.j +++ b/AppKit/_CPWindowView.j @@ -20,8 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPView.j" -import "CPImageView.j" +@import "CPView.j" +@import "CPImageView.j" var _CPWindowViewResizeIndicatorImage = nil; diff --git a/Foundation/CPArray.j b/Foundation/CPArray.j index 860a9b0b6..52462121b 100755 --- a/Foundation/CPArray.j +++ b/Foundation/CPArray.j @@ -20,11 +20,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" -import "CPRange.j" -import "CPEnumerator.j" -import "CPSortDescriptor.j" -import "CPException.j" +@import "CPObject.j" +@import "CPRange.j" +@import "CPEnumerator.j" +@import "CPSortDescriptor.j" +@import "CPException.j" /* @ignore */ @implementation _CPArrayEnumerator : CPEnumerator diff --git a/Foundation/CPBundle.j b/Foundation/CPBundle.j index 453e5943e..66b20a9a3 100644 --- a/Foundation/CPBundle.j +++ b/Foundation/CPBundle.j @@ -20,8 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" -import "CPDictionary.j" +@import "CPObject.j" +@import "CPDictionary.j" + @implementation CPBundle : CPObject { diff --git a/Foundation/CPCoder.j b/Foundation/CPCoder.j index fefe54947..6939068ef 100644 --- a/Foundation/CPCoder.j +++ b/Foundation/CPCoder.j @@ -20,8 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" -import "CPException.j" +@import "CPObject.j" +@import "CPException.j" + /*! @class CPCoder Top-level class defining methods for use when archiving (encoding) objects to a byte array diff --git a/Foundation/CPData.j b/Foundation/CPData.j index 625036004..8acbc95fa 100644 --- a/Foundation/CPData.j +++ b/Foundation/CPData.j @@ -20,8 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" -import "CPString.j" +@import "CPObject.j" +@import "CPString.j" + @implementation CPData : CPObject { diff --git a/Foundation/CPDate.j b/Foundation/CPDate.j index 29279b6b9..db83c63c4 100644 --- a/Foundation/CPDate.j +++ b/Foundation/CPDate.j @@ -20,8 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" -import "CPString.j" +@import "CPObject.j" +@import "CPString.j" + var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0)); diff --git a/Foundation/CPDictionary.j b/Foundation/CPDictionary.j index 54c5a3b4b..f05fcc0c3 100755 --- a/Foundation/CPDictionary.j +++ b/Foundation/CPDictionary.j @@ -20,10 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -//import "CPRange.j" -import "CPObject.j" -import "CPEnumerator.j" -import "CPException.j" +//@import "CPRange.j" +@import "CPObject.j" +@import "CPEnumerator.j" +@import "CPException.j" /* @ignore */ @implementation _CPDictionaryValueEnumerator : CPEnumerator diff --git a/Foundation/CPEnumerator.j b/Foundation/CPEnumerator.j index f2692349a..a7cf7b09b 100755 --- a/Foundation/CPEnumerator.j +++ b/Foundation/CPEnumerator.j @@ -20,7 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" +@import "CPObject.j" + /*! @class CPEnumerator CPEnumerator is a superclass (with useless method bodies) diff --git a/Foundation/CPException.j b/Foundation/CPException.j index 80e78741f..861e4bf51 100755 --- a/Foundation/CPException.j +++ b/Foundation/CPException.j @@ -20,9 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPCoder.j" -import "CPObject.j" -import "CPString.j" +@import "CPCoder.j" +@import "CPObject.j" +@import "CPString.j" CPInvalidArgumentException = "CPInvalidArgumentException"; diff --git a/Foundation/CPIndexSet.j b/Foundation/CPIndexSet.j index ec3c30283..d4df88094 100644 --- a/Foundation/CPIndexSet.j +++ b/Foundation/CPIndexSet.j @@ -20,8 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPRange.j" -import "CPObject.j" +@import "CPRange.j" +@import "CPObject.j" + /*! @class CPIndexSet Instances of this class are collections of numbers. Each integer can appear in a collection only once. diff --git a/Foundation/CPInvocation.j b/Foundation/CPInvocation.j index 7fd45bf16..802188778 100644 --- a/Foundation/CPInvocation.j +++ b/Foundation/CPInvocation.j @@ -20,8 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" -import "CPException.j" +@import "CPObject.j" +@import "CPException.j" + /*! @class CPInvocation A CPInvocation is an object representation of a message sent to an object. diff --git a/Foundation/CPJSONPConnection.j b/Foundation/CPJSONPConnection.j index a61f8c3fe..56f4d9408 100644 --- a/Foundation/CPJSONPConnection.j +++ b/Foundation/CPJSONPConnection.j @@ -20,7 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import + CPJSONPConnectionCallbacks = {}; diff --git a/Foundation/CPKeyValueCoding.j b/Foundation/CPKeyValueCoding.j index 3d56f260c..859a67713 100644 --- a/Foundation/CPKeyValueCoding.j +++ b/Foundation/CPKeyValueCoding.j @@ -20,9 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPArray.j" -import "CPObject.j" -import "CPDictionary.j" +@import "CPArray.j" +@import "CPObject.j" +@import "CPDictionary.j" + var CPObjectAccessorsForClass = nil, CPObjectModifiersForClass = nil; diff --git a/Foundation/CPKeyValueObserving.j b/Foundation/CPKeyValueObserving.j index f68b67f91..8ec109a43 100644 --- a/Foundation/CPKeyValueObserving.j +++ b/Foundation/CPKeyValueObserving.j @@ -20,10 +20,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPArray.j" -import "CPDictionary.j" -import "CPException.j" -import "CPObject.j" +@import "CPArray.j" +@import "CPDictionary.j" +@import "CPException.j" +@import "CPObject.j" + @implementation CPObject (KeyValueObserving) diff --git a/Foundation/CPKeyedArchiver.j b/Foundation/CPKeyedArchiver.j index 289e0f5f6..4d3e15435 100644 --- a/Foundation/CPKeyedArchiver.j +++ b/Foundation/CPKeyedArchiver.j @@ -20,13 +20,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPData.j" -import "CPCoder.j" -import "CPArray.j" -import "CPString.j" -import "CPNumber.j" -import "CPDictionary.j" -import "CPValue.j" +@import "CPData.j" +@import "CPCoder.j" +@import "CPArray.j" +@import "CPString.j" +@import "CPNumber.j" +@import "CPDictionary.j" +@import "CPValue.j" + var CPArchiverReplacementClassNames = nil; diff --git a/Foundation/CPKeyedUnarchiver.j b/Foundation/CPKeyedUnarchiver.j index 40cdc1c72..4d09f62c8 100644 --- a/Foundation/CPKeyedUnarchiver.j +++ b/Foundation/CPKeyedUnarchiver.j @@ -20,8 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPNull.j" -import "CPCoder.j" +@import "CPNull.j" +@import "CPCoder.j" var _CPKeyedUnarchiverCannotDecodeObjectOfClassNameOriginalClassesSelector = 1, diff --git a/Foundation/CPNotification.j b/Foundation/CPNotification.j index fcfc70474..aa6513e65 100644 --- a/Foundation/CPNotification.j +++ b/Foundation/CPNotification.j @@ -20,8 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" -import "CPException.j" +@import "CPObject.j" +@import "CPException.j" + /*! @class CPNotification Represents a notification for posting to an CPNotificationCenter. Consists of a name, an object, and an optional dictionary. The notification center will check for observers registered to receive either notifications with the name, the object, or both and pass the notification instance on to them. diff --git a/Foundation/CPNotificationCenter.j b/Foundation/CPNotificationCenter.j index 705dd21c2..7a78d662f 100644 --- a/Foundation/CPNotificationCenter.j +++ b/Foundation/CPNotificationCenter.j @@ -20,10 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPArray.j" -import "CPDictionary.j" -import "CPNotification.j" -import "CPException.j" +@import "CPArray.j" +@import "CPDictionary.j" +@import "CPNotification.j" +@import "CPException.j" var CPNotificationDefaultCenter = nil; diff --git a/Foundation/CPNull.j b/Foundation/CPNull.j index fc143b9f0..0f1c55081 100644 --- a/Foundation/CPNull.j +++ b/Foundation/CPNull.j @@ -20,7 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" +@import "CPObject.j" + var CPNullSharedNull = nil; diff --git a/Foundation/CPNumber.j b/Foundation/CPNumber.j index b3dedaffe..093e9176a 100644 --- a/Foundation/CPNumber.j +++ b/Foundation/CPNumber.j @@ -20,8 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" -import "CPObjJRuntime.j" +@import "CPObject.j" +@import "CPObjJRuntime.j" + var __placeholder = new Number(), _CPNumberHashes = { }; diff --git a/Foundation/CPObjJRuntime.j b/Foundation/CPObjJRuntime.j index fd789a6f9..76cfb8f76 100644 --- a/Foundation/CPObjJRuntime.j +++ b/Foundation/CPObjJRuntime.j @@ -20,7 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPLog.j" +@import "CPLog.j" + function CPStringFromSelector(aSelector) { diff --git a/Foundation/CPPropertyListSerialization.j b/Foundation/CPPropertyListSerialization.j index 0999ea4c3..19c71fa5c 100644 --- a/Foundation/CPPropertyListSerialization.j +++ b/Foundation/CPPropertyListSerialization.j @@ -20,6 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +@import "CPObject.j" + + CPPropertyListOpenStepFormat = kCFPropertyListOpenStepFormat; CPPropertyListXMLFormat_v1_0 = kCFPropertyListXMLFormat_v1_0; CPPropertyListBinaryFormat_v1_0 = kCFPropertyListBinaryFormat_v1_0; diff --git a/Foundation/CPRunLoop.j b/Foundation/CPRunLoop.j index 2ba71e5ee..ed3da7707 100644 --- a/Foundation/CPRunLoop.j +++ b/Foundation/CPRunLoop.j @@ -20,9 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" -import "CPArray.j" -import "CPString.j" +@import "CPObject.j" +@import "CPArray.j" +@import "CPString.j" /*! @global diff --git a/Foundation/CPSortDescriptor.j b/Foundation/CPSortDescriptor.j index b65e99ab2..b0bd518f5 100755 --- a/Foundation/CPSortDescriptor.j +++ b/Foundation/CPSortDescriptor.j @@ -20,8 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" -import "CPObjJRuntime.j" +@import "CPObject.j" +@import "CPObjJRuntime.j" + /*! The left operand is smaller than the right. diff --git a/Foundation/CPString.j b/Foundation/CPString.j index 693cb2edb..8929294fb 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -20,9 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" -import "CPException.j" -import "CPSortDescriptor.j" +@import "CPObject.j" +@import "CPException.j" +@import "CPSortDescriptor.j" + /*! A case insensitive search diff --git a/Foundation/CPURLConnection.j b/Foundation/CPURLConnection.j index 1ff52aab2..2e639d7f1 100644 --- a/Foundation/CPURLConnection.j +++ b/Foundation/CPURLConnection.j @@ -20,10 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" -import "CPRunLoop.j" -import "CPURLRequest.j" -import "CPURLResponse.j" +@import "CPObject.j" +@import "CPRunLoop.j" +@import "CPURLRequest.j" +@import "CPURLResponse.j" var XMLHTTPRequestUninitialized = 0, diff --git a/Foundation/CPURLRequest.j b/Foundation/CPURLRequest.j index fb46a9fbc..914fffa81 100644 --- a/Foundation/CPURLRequest.j +++ b/Foundation/CPURLRequest.j @@ -20,7 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" +@import "CPObject.j" + /*! @class CPURLRequest A helper object for CPURLConnection, that contains diff --git a/Foundation/CPURLResponse.j b/Foundation/CPURLResponse.j index 463ecc654..0f4a9cfa4 100644 --- a/Foundation/CPURLResponse.j +++ b/Foundation/CPURLResponse.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" +@import "CPObject.j" /* diff --git a/Foundation/CPUndoManager.j b/Foundation/CPUndoManager.j index ee3900b3a..e0f3be84e 100644 --- a/Foundation/CPUndoManager.j +++ b/Foundation/CPUndoManager.j @@ -20,8 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" -import "CPInvocation.j" +@import "CPObject.j" +@import "CPInvocation.j" + var CPUndoManagerNormal = 0, CPUndoManagerUndoing = 1, diff --git a/Foundation/CPUserSessionManager.j b/Foundation/CPUserSessionManager.j index 97fd32362..b15d1e916 100644 --- a/Foundation/CPUserSessionManager.j +++ b/Foundation/CPUserSessionManager.j @@ -20,8 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import -import +@import +@import CPUserSessionUndeterminedStatus = 0; diff --git a/Foundation/CPValue.j b/Foundation/CPValue.j index bf185e1af..bf7ce7c3f 100644 --- a/Foundation/CPValue.j +++ b/Foundation/CPValue.j @@ -20,8 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPObject.j" -import "CPCoder.j" +@import "CPObject.j" +@import "CPCoder.j" + /*! @class CPValue The class can be subclassed to hold different types of scalar values. diff --git a/Foundation/Foundation.j b/Foundation/Foundation.j index 352d06662..35e48c688 100755 --- a/Foundation/Foundation.j +++ b/Foundation/Foundation.j @@ -20,36 +20,36 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "CPArray.j" -import "CPBundle.j" -import "CPCoder.j" -import "CPData.j" -import "CPDate.j" -import "CPDictionary.j" -import "CPEnumerator.j" -import "CPException.j" -import "CPIndexSet.j" -import "CPInvocation.j" -import "CPJSONPConnection.j" -import "CPKeyedArchiver.j" -import "CPKeyedUnarchiver.j" -import "CPKeyValueCoding.j" -import "CPKeyValueObserving.j" -import "CPLog.j" -import "CPNotification.j" -import "CPNotificationCenter.j" -import "CPNull.j" -import "CPNumber.j" -import "CPObject.j" -import "CPObjJRuntime.j" -import "CPPropertyListSerialization.j" -import "CPRange.j" -import "CPRunLoop.j" -import "CPSortDescriptor.j" -import "CPString.j" -import "CPUndoManager.j" -import "CPURLConnection.j" -import "CPURLRequest.j" -import "CPURLResponse.j" -import "CPUserSessionManager.j" -import "CPValue.j" +@import "CPArray.j" +@import "CPBundle.j" +@import "CPCoder.j" +@import "CPData.j" +@import "CPDate.j" +@import "CPDictionary.j" +@import "CPEnumerator.j" +@import "CPException.j" +@import "CPIndexSet.j" +@import "CPInvocation.j" +@import "CPJSONPConnection.j" +@import "CPKeyedArchiver.j" +@import "CPKeyedUnarchiver.j" +@import "CPKeyValueCoding.j" +@import "CPKeyValueObserving.j" +@import "CPLog.j" +@import "CPNotification.j" +@import "CPNotificationCenter.j" +@import "CPNull.j" +@import "CPNumber.j" +@import "CPObject.j" +@import "CPObjJRuntime.j" +@import "CPPropertyListSerialization.j" +@import "CPRange.j" +@import "CPRunLoop.j" +@import "CPSortDescriptor.j" +@import "CPString.j" +@import "CPUndoManager.j" +@import "CPURLConnection.j" +@import "CPURLRequest.j" +@import "CPURLResponse.j" +@import "CPUserSessionManager.j" +@import "CPValue.j" diff --git a/Objective-J/constants.js b/Objective-J/constants.js index c0b97bd5f..747d5e04c 100644 --- a/Objective-J/constants.js +++ b/Objective-J/constants.js @@ -99,3 +99,15 @@ function objj_printf(string) { objj_fprintf(alert, string); } + +#if COMPILER +importPackage(java.lang); + +warning_stream = function (aString) { System.out.println(aString) }; + +#else +if (window.console && window.console.warn) + warning_stream = function(aString) { window.console.warn(aString); } +else + warning_stream = function(){}; +#endif diff --git a/Objective-J/preprocess.js b/Objective-J/preprocess.js index f13c9ee8a..d0656d7f4 100644 --- a/Objective-J/preprocess.js +++ b/Objective-J/preprocess.js @@ -1,5 +1,5 @@ /* - * preprocess.js + * preprocessor.js * Objective-J * * Created by Francisco Tolmasky. @@ -20,17 +20,34 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +function objj_preprocess(/*String*/ aString, /*objj_bundle*/ aBundle, /*objj_file*/ aSourceFile) +{ + try + { + OBJJ_CURRENT_BUNDLE = aBundle; + + return new objj_preprocessor(aString, aSourceFile).fragments(); + } + catch (anException) + { + objj_exception_report(anException, aSourceFile); + } + + return []; +} + OBJJParseException = "OBJJParseException"; OBJJClassNotFoundException = "OBJJClassNotFoundException"; -var TOKEN_CLASS = "class", +var TOKEN_ACCESSORS = "accessors", + TOKEN_CLASS = "class", + TOKEN_END = "end", TOKEN_FUNCTION = "function", TOKEN_IMPLEMENTATION = "implementation", TOKEN_IMPORT = "import", TOKEN_NEW = "new", TOKEN_SELECTOR = "selector", TOKEN_SUPER = "super", - TOKEN_SYNTHESIZE = "synthesize", TOKEN_EQUAL = '=', TOKEN_PLUS = '+', @@ -50,26 +67,23 @@ var TOKEN_CLASS = "class", TOKEN_CLOSE_BRACKET = ']', TOKEN_QUESTION_MARK = '?', TOKEN_OPEN_PARENTHESIS = '(', - TOKEN_CLOSE_PARENTHESIS = ')', - TOKEN_WORD = /^\w+$/; + TOKEN_CLOSE_PARENTHESIS = ')'; + +#define IS_WORD(token) /^\w+$/.test(token) -#define IS_WORD(token) TOKEN_WORD.test(token) +#define IS_NOT_EMPTY(buffer) buffer.atoms.length !== 0 +#define CONCAT(buffer, atom) buffer.atoms[buffer.atoms.length] = atom -// FIXME: This could break with static preinterpretation. -var SUPER_CLASSES = new objj_dictionary(), - CURRENT_SUPER_CLASS = NULL, - CURRENT_CLASS_NAME = NULL; +var SUPER_CLASSES = new objj_dictionary(); var OBJJ_CURRENT_BUNDLE = NULL; // FIXME: Used fixed regex -var objj_lexer = function(aString, aSourceFile) +var objj_lexer = function(aString) { this._index = 0; this._tokens = (aString + '\n').match(/\/\/.*(\r|\n)?|\/\*(?:.|\n|\r)*?\*\/|\w+\b|[+-]?\d+(([.]\d+)*([eE][+-]?\d+))?|"([^"\\]|\\[\s\S])*"|'[^'\\]*(\\.[^'\\]*)*'|\s+|./g); - this.file = aSourceFile; - return this; } @@ -99,248 +113,46 @@ objj_lexer.prototype.skip_whitespace= function() return token; } -var objj_preprocess_method = function(tokens, count, array_name) +var objj_stringBuffer = function() { - var token, - selector = "", - parameters = new Array(); - - while((token = tokens.skip_whitespace()) && token != TOKEN_OPEN_BRACE) - { - if (token == TOKEN_COLON) - { - // Colons are part of the selector name - selector += token; - - token = tokens.skip_whitespace(); - - if (token == TOKEN_OPEN_PARENTHESIS) - { - // Swallow parameter/return type. Perhaps later we can use this for debugging? - while((token = tokens.skip_whitespace()) && token != TOKEN_CLOSE_PARENTHESIS) ; - - token = tokens.skip_whitespace(); - } - - // Since this follows a colon, this must be the parameter name. - parameters[parameters.length] = token; - } - else if (token == TOKEN_OPEN_PARENTHESIS) - // Since :( is handled above, this must be the return type, just swallow it. - while((token = tokens.skip_whitespace()) && token != TOKEN_CLOSE_PARENTHESIS) ; - // Argument list ", ..." - else if (token == TOKEN_COMMA) - { - // At this point, "..." MUST follow. - if ((token = tokens.skip_whitespace()) != TOKEN_PERIOD || tokens.next() != TOKEN_PERIOD || tokens.next() != TOKEN_PERIOD) - objj_exception_throw(new objj_exception(OBJJParseException, "*** Argument list expected after ','.")); - - // FIXME: Shouldn't allow any more after this. - } - // Build selector name. - else - selector += token; - } - - var i= 0, - length = parameters.length, - selectorDisplayName = "$"+CURRENT_CLASS_NAME+"__"+selector.replace(/:/g, "_"), - preprocessed = array_name + "["+count+"] = new objj_method(sel_registerName(\""+selector+"\"), function "+selectorDisplayName+"(self, _cmd"; - - for(; i < length; ++i) - preprocessed += ", " + parameters[i]; - -#if FIREBUG - // FireBug auto expands and doesn't allow you to resize, so truncate it. - var truncatedSelector = "["+CURRENT_CLASS_NAME+" "+(selector.length > 60 ? selector.substring(0, 60) + "..." : selector)+"]"; - return preprocessed + ")\n{ \"__FIREBUG_FNAME__"+truncatedSelector+"\".length;\n with(self)\n{" + objj_preprocess_tokens(tokens, TOKEN_CLOSE_BRACE, TOKEN_OPEN_BRACE) + "}\n});\n"; -#else - return preprocessed + ")\n{ with(self)\n{" + objj_preprocess_tokens(tokens, TOKEN_CLOSE_BRACE, TOKEN_OPEN_BRACE) + "}\n});\n"; -#endif + this.atoms = []; } -var objj_preprocess_implementation= function(tokens) +objj_stringBuffer.prototype.toString = function() { - var token = "", - category = NO, - preprocessed = "", - class_name = tokens.skip_whitespace(), - superclass_name = "Nil", - - class_method_count = 0, - instance_method_count = 0, - methods_preprocessed = []; - - if (!(/^\w/).test(class_name)) - objj_exception_throw(new objj_exception(OBJJParseException, "*** Expected class name, found \"" + class_name + "\".")); - - CURRENT_SUPER_CLASS = NULL; - CURRENT_CLASS_NAME = class_name; - - // NOTE: This behavior is currently turned off. - // addWorkingClass(class_name); - - // If we reach an open parenthesis, we are declaring a category. - if((token = tokens.skip_whitespace()) == TOKEN_OPEN_PARENTHESIS) - { - token = tokens.skip_whitespace(); - - if(tokens.skip_whitespace() != TOKEN_CLOSE_PARENTHESIS) - objj_exception_throw(new objj_exception(OBJJParseException, "*** Improper Category Definition for class \""+class_name+"\".")); - - preprocessed += "{\nvar the_class = objj_getClass(\"" + class_name + "\")\n"; - preprocessed += "if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, \"*** Could not find definition for class \\\"" + class_name + "\\\"\"));\n"; - preprocessed += "var meta_class = the_class.isa;"; - - var superclass_name = dictionary_getValue(SUPER_CLASSES, class_name); - - // FIXME: We should have a better solution for this case, although it's actually not much slower than the real case. - if (!superclass_name) - CURRENT_SUPER_CLASS = "objj_getClass(\"" + class_name + "\").super_class"; - else - CURRENT_SUPER_CLASS = "objj_getClass(\"" + superclass_name + "\")"; - } - else - { - // If we reach a colon (':'), then a superclass is being declared. - if(token == TOKEN_COLON) - { - token = tokens.skip_whitespace(); - if (!(/^\w/).test(token)) - objj_exception_throw(new objj_exception(OBJJParseException, "*** Expected class name, found \"" + token + "\".")); - - superclass_name = token; - CURRENT_SUPER_CLASS = "objj_getClass(\"" + superclass_name + "\")"; - - dictionary_setValue(SUPER_CLASSES, class_name, superclass_name); - - token = tokens.skip_whitespace(); - } - - preprocessed += "{var the_class = objj_allocateClassPair(" + superclass_name + ", \"" + class_name + "\"),\nmeta_class = the_class.isa;"; - - // If we are at an opening curly brace ('{'), then we have an ivar declaration. - if (token == TOKEN_OPEN_BRACE) - { - var ivar_count = 0, - declaration = [], - - attributes, - synthesizes = {}; - - while((token = tokens.skip_whitespace()) && token != TOKEN_CLOSE_BRACE) - { - if (token == TOKEN_PREPROCESSOR) - { - token = tokens.next(); - - if (token == TOKEN_SYNTHESIZE) - attributes = objj_preprocess_declaration_synthesize(tokens); - else - objj_exception_throw(new objj_exception(OBJJParseException, "*** Expected 'synthesize', found '" + token + "'.")); - } - else if (token == TOKEN_SEMICOLON) - { - if (ivar_count++ == 0) - preprocessed += "class_addIvars(the_class, ["; - else - preprocessed += ", "; - - var name = declaration[declaration.length - 1]; - - preprocessed += "new objj_ivar(\"" + name + "\")"; - - declaration = []; - - if (attributes) - { - synthesizes[name] = attributes; - attributes = NULL; - } - } - else - declaration.push(token); - } - - // If we have objects in our declaration, the user forgot a ';'. - if (declaration.length) - objj_exception_throw(new objj_exception(OBJJParseException, "*** Expected ';' in ivar declaration, found '}'.")); - - if (ivar_count) - preprocessed += "]);\n"; - - if (!token) - objj_exception_throw(new objj_exception(OBJJParseException, "*** Expected '}'")); - - for (name in synthesizes) - { - var synthesized = synthesizes[name], - property = synthesized["property"] || name, - getterName = synthesized["getter"] || property, - getterCode = "(id)" + getterName + "\n{\nreturn " + name + ";\n}"; - - methods_preprocessed.push(objj_preprocess_method(new objj_lexer(getterCode, null), instance_method_count++, "instance_methods")); - - // setter - if (synthesized["readonly"]) - continue; - - var setterName = synthesized['setter'] || ("set" + property.substring(0,1).toUpperCase() + - property.substring(1) + ":"), - setterCode = "(void)" + setterName + "(id)newValue\n{\n" + - "if (newValue !== " + name + ")\n" + - name + "=" + (synthesized["copy"] ? "[newValue copy]" : "newValue") + ";\n}"; - - methods_preprocessed.push(objj_preprocess_method(new objj_lexer(setterCode, null), instance_method_count++, "instance_methods")); - } - } - else - tokens.previous(); - - // We must make a new class object for our class definition. - preprocessed += "objj_registerClassPair(the_class);\n"; - - // Add this class to the current bundle. - preprocessed += "objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));\n"; - } - - while((token = tokens.skip_whitespace())) - { - if(token == TOKEN_PLUS) - methods_preprocessed.push(objj_preprocess_method(tokens, class_method_count++, "class_methods")); - - else if(token == TOKEN_MINUS) - methods_preprocessed.push(objj_preprocess_method(tokens, instance_method_count++, "instance_methods")); - // Check if we've reached @end... - else if(token == TOKEN_PREPROCESSOR) - { - // The only preprocessor directive we should ever encounter at this point is @end. - if((token = tokens.next()) == "end") - break; - else - objj_exception_throw(new objj_exception(OBJJParseException, "*** Expected \"@end\", found \"@" + token + "\".")); - } - } - - if (instance_method_count) - preprocessed += "var instance_methods = [];\n"; - - if (class_method_count) - preprocessed += "var class_methods = [];\n"; - - preprocessed += methods_preprocessed.join(""); - - // Do the instance methods first because they could override the class methods if not. - if (instance_method_count) - preprocessed += "class_addMethods(the_class, instance_methods);\n"; - - if (class_method_count) - preprocessed += "class_addMethods(meta_class, class_methods);\n"; - - return preprocessed + '}'; + return this.atoms.join(""); } -var /*JSObject*/ objj_preprocess_declaration_synthesize = function(tokens) +objj_stringBuffer.prototype.clear = function() +{ + this.atoms = []; +} + +objj_stringBuffer.prototype.isEmpty = function() +{ + return (this.atoms.length === 0); +} + +var objj_preprocessor = function(aString, aSourceFile) +{ + this._currentClass = ""; + this._currentSuperClass = ""; + + this._file = aSourceFile; + this._fragments = []; + this._preprocessed = new objj_stringBuffer(); + this._tokens = new objj_lexer(aString); + + this.preprocess(this._tokens, this._preprocessed); + this.fragment(); +} + +objj_preprocessor.prototype.fragments = function() +{ + return this._fragments; +} + +objj_preprocessor.prototype.accessors = function(tokens) { var token = tokens.skip_whitespace(), attributes = {}; @@ -390,42 +202,21 @@ var /*JSObject*/ objj_preprocess_declaration_synthesize = function(tokens) return attributes; } -var objj_preprocess_directive = function(tokens) +objj_preprocessor.prototype.brackets = function(tokens, /*objj_stringBuffer*/ aStringBuffer) { - // Grab the next token, preprocessor directives follow '@' immediately. - token = tokens.next(); - - // To provide compatibility with Objective-C files, we convert NSString literals into - // toll-freed JavaScript/CPString strings. - if(token.charAt(0) == TOKEN_DOUBLE_QUOTE) return token; - // Currently we simply swallow forward declarations and only provide them to allow - // compatibility with Objective-C files. - else if(token == TOKEN_CLASS) { tokens.skip_whitespace(); return ""; } - // @implementation Class implementations - else if(token == TOKEN_IMPLEMENTATION) return objj_preprocess_implementation(tokens); - // @selector - else if(token == TOKEN_SELECTOR) - { - // Swallow open parenthesis. - if (tokens.skip_whitespace() != TOKEN_OPEN_PARENTHESIS) - objj_exception_throw(new objj_exception(OBJJParseException, "*** Expected ')'")); - return "sel_registerName(\"" + objj_preprocess_tokens(tokens, TOKEN_CLOSE_PARENTHESIS) +"\")"; - } + var buffer = aStringBuffer ? aStringBuffer : new objj_stringBuffer(); - return ""; -} - -var objj_preprocess_brackets = function(tokens) -{ // We maintain two parallel interpretations through the process, // One which assumes the brackets form a literal array, and // another that builds the possible message dispatch composed of // a receiver, a selector, and a number of marg_list. - var literal = '[', + var literal = new objj_stringBuffer(), + msgSend = "objj_msgSend", receiver = "", selector = "", - marg_list = new Array(), - preprocessed = "objj_msgSend"; + marg_list = []; + + CONCAT(literal, '['); // We keep track of the current iterative token, the previous // expression, tertiary operations, and parenthesis. @@ -449,29 +240,43 @@ var objj_preprocess_brackets = function(tokens) { if (!receiver.length) { - preprocessed = "objj_msgSendSuper"; - token = "{ receiver:self, super_class:" + CURRENT_SUPER_CLASS + " }"; + msgSend = "objj_msgSendSuper"; + token = "{ receiver:self, super_class:" + this._currentSuperClass + " }"; } else objj_exception_throw(new objj_exception(OBJJParseException, "*** Can't use 'super' in this context.")); } - else if (token == TOKEN_OPEN_BRACE) ++braces; - else if (token == TOKEN_CLOSE_BRACE) --braces; + + else if (token == TOKEN_OPEN_BRACE) + ++braces; + + else if (token == TOKEN_CLOSE_BRACE) + --braces; + // Tertiary expressions have the potential to confuse the preprocessor, // so keep track of them to avoid misidentifying a colon (':') for an // argument. - else if(token == TOKEN_QUESTION_MARK) ++tertiary; + else if(token == TOKEN_QUESTION_MARK) + ++tertiary; + // Keep track of expressions within parenthesis. - else if(token == TOKEN_OPEN_PARENTHESIS) ++parenthesis; - else if(token == TOKEN_CLOSE_PARENTHESIS) --parenthesis; + else if(token == TOKEN_OPEN_PARENTHESIS) + ++parenthesis; + + else if(token == TOKEN_CLOSE_PARENTHESIS) + --parenthesis; + // If we reach a nested bracket, preprocess it first and interpret // the result as the current token. - else if(token == TOKEN_OPEN_BRACKET) token = objj_preprocess_brackets(tokens); - else if(token == TOKEN_PREPROCESSOR) token = objj_preprocess_directive(tokens); + else if(token == TOKEN_OPEN_BRACKET) + token = this.brackets(tokens); + + else if(token == TOKEN_PREPROCESSOR) + token = this.directive(tokens); // Preprocess tokens only if we're not within parenthesis or in a // tertiary statement. - if(preprocess) + if (preprocess) { // If we ever reach a comma that is not in a sub expression, // and we haven't yet begun to construct a selector, then @@ -518,7 +323,7 @@ var objj_preprocess_brackets = function(tokens) else receiver += previous; - previous = token; + previous = token.toString(); } } // If not, add it to previous to be interpreted as one block. @@ -529,6 +334,7 @@ var objj_preprocess_brackets = function(tokens) // https://trac.280north.com/ticket/15 if(token == TOKEN_COLON && !braces) --tertiary; + previous += token; } @@ -536,13 +342,15 @@ var objj_preprocess_brackets = function(tokens) // manner, simply aggregate the tokens, unless we have a new token, // in which case we need to add back the whitespace we removed. if (token == TOKEN_NEW) - literal += "new "; + CONCAT(literal, "new "); else - literal += token; + CONCAT(literal, token); } // If we have a selector, then add the remaining string to the argument. - if (selector.length) marg_list[marg_list.length - 1] += previous; + if (selector.length) + marg_list[marg_list.length - 1] += previous; + // If not, check whether the final character of our proposed receiver // is an operator or the new keyword. Also check that the previous // expression does not begin with a parenthesis, since this means it @@ -555,10 +363,21 @@ var objj_preprocess_brackets = function(tokens) else if(!array && receiver.length && !((/[\:\+\-\*\/\=\<\>\&\|\!\.\%]/).test(receiver.charAt(receiver.length - 1))) && receiver != TOKEN_NEW && !(/[\+\-\*\/\=\<\>\&\|\!\.\[\^\(]/).test(previous.charAt(0))) selector = previous; + // If we did not build a selector through the parsing process, then we // are either a single entry literal array, or an array index, and so // we should simply return our literal string. - else return literal + ']'; + else + { + CONCAT(buffer, literal); + CONCAT(buffer, ']'); + + // Return no matter what! + if (!aStringBuffer) + return buffer; + else + return; + } // NOTE: For now, turn this behavior off. // Classes act much like keywords since they are not directly manipulatable. @@ -567,64 +386,403 @@ var objj_preprocess_brackets = function(tokens) // if (tokens.containsClass(receiver) || objj_getClass(receiver)) receiver = "objj_getClass(\"" + receiver + "\")"; // The first two arguments are always the receiver and the selector. - preprocessed += '(' + receiver + ", \"" + sel_registerName(selector) + "\""; + CONCAT(buffer, msgSend); + CONCAT(buffer, '(' + receiver + ", \"" + sel_getUid(selector) + "\""); // Populate the remaining parameters with the provided arguments. - var i = 0, - length = marg_list.length; + var index = 0, + count = marg_list.length; - for(; i < length; ++i) - preprocessed += ", " + marg_list[i]; + for(; index < count; ++index) + CONCAT(buffer, ", " + marg_list[index]); // Return the fully preprocessed message dispatch. - return preprocessed + ')'; + CONCAT(buffer, ')'); + + if (!aStringBuffer) + return buffer; } -function objj_preprocess_tokens(tokens, terminator, instigator, segment) -{//if (window.p) alert("objj_preprocess_tokens"); - var count = 0, + +objj_preprocessor.prototype.directive = function(tokens, aStringBuffer, allowedDirectivesFlags) +{ + // Grab the next token, preprocessor directives follow '@' immediately. + var buffer = aStringBuffer ? aStringBuffer : new objj_stringBuffer(), + token = tokens.next(); + + // To provide compatibility with Objective-C files, we convert NSString literals into + // toll-freed JavaScript/CPString strings. + if (token.charAt(0) == TOKEN_DOUBLE_QUOTE) + CONCAT(buffer, token); + + // Currently we simply swallow forward declarations and only provide them to allow + // compatibility with Objective-C files. + else if (token == TOKEN_CLASS) + { + tokens.skip_whitespace(); + + return; + } + + // @implementation Class implementations + else if (token == TOKEN_IMPLEMENTATION) + this.implementation(tokens, buffer); + + // @import + else if (token == TOKEN_IMPORT) + this._import(tokens); + + // @selector + else if (token == TOKEN_SELECTOR) + this.selector(tokens, buffer); + + else if (token == TOKEN_ACCESSORS) + return this.accessors(tokens); + + if (!aStringBuffer) + return buffer; +} + +objj_preprocessor.prototype.fragment = function() +{ + var preprocessed = this._preprocessed.toString(); + + // But make sure it's not just all whitespace! + if ((/[^\s]/).test(preprocessed)) + this._fragments.push(fragment_create_code(preprocessed, OBJJ_CURRENT_BUNDLE, this._file)); + + this._preprocessed.clear(); +} + +objj_preprocessor.prototype.implementation = function(tokens, /*objj_stringBuffer*/ aStringBuffer) +{ + var buffer = aStringBuffer, token = "", - fragments = [], - preprocessed = ""; + category = NO, + class_name = tokens.skip_whitespace(), + superclass_name = "Nil", + + instance_methods = new objj_stringBuffer(), + class_methods = new objj_stringBuffer(); + + if (!(/^\w/).test(class_name)) + objj_exception_throw(new objj_exception(OBJJParseException, "*** Expected class name, found \"" + class_name + "\".")); + + this._currentSuperClass = NULL; + this._currentClass = class_name; + + // If we reach an open parenthesis, we are declaring a category. + if((token = tokens.skip_whitespace()) == TOKEN_OPEN_PARENTHESIS) + { + token = tokens.skip_whitespace(); + + if (token == TOKEN_CLOSE_PARENTHESIS) + objj_exception_throw(new objj_exception(OBJJParseException, "*** Can't Have Empty Category Name for class \"" + class_name + "\".")); + + if (tokens.skip_whitespace() != TOKEN_CLOSE_PARENTHESIS) + objj_exception_throw(new objj_exception(OBJJParseException, "*** Improper Category Definition for class \"" + class_name + "\".")); + + CONCAT(buffer, "{\nvar the_class = objj_getClass(\"" + class_name + "\")\n"); + CONCAT(buffer, "if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, \"*** Could not find definition for class \\\"" + class_name + "\\\"\"));\n"); + CONCAT(buffer, "var meta_class = the_class.isa;"); + + var superclass_name = dictionary_getValue(SUPER_CLASSES, class_name); + + // FIXME: We should have a better solution for this case, although it's actually not much slower than the real case. + if (!superclass_name) + this._currentSuperClass = "objj_getClass(\"" + class_name + "\").super_class"; + else + this._currentSuperClass = "objj_getClass(\"" + superclass_name + "\")"; + } + else + { + // If we reach a colon (':'), then a superclass is being declared. + if(token == TOKEN_COLON) + { + token = tokens.skip_whitespace(); + + if (!(/^[a-zA-Z_$](\w|$)*$/).test(token)) + objj_exception_throw(new objj_exception(OBJJParseException, "*** Expected class name, found \"" + token + "\".")); + + superclass_name = token; + this._currentSuperClass = "objj_getClass(\"" + superclass_name + "\")"; + + dictionary_setValue(SUPER_CLASSES, class_name, superclass_name); + + token = tokens.skip_whitespace(); + } + + CONCAT(buffer, "{var the_class = objj_allocateClassPair(" + superclass_name + ", \"" + class_name + "\"),\nmeta_class = the_class.isa;"); + + // If we are at an opening curly brace ('{'), then we have an ivar declaration. + if (token == TOKEN_OPEN_BRACE) + { + var ivar_count = 0, + declaration = [], + + attributes, + accessors = {}; + + while((token = tokens.skip_whitespace()) && token != TOKEN_CLOSE_BRACE) + { + if (token == TOKEN_PREPROCESSOR) + attributes = this.directive(tokens); + + else if (token == TOKEN_SEMICOLON) + { + if (ivar_count++ == 0) + CONCAT(buffer, "class_addIvars(the_class, ["); + else + CONCAT(buffer, ", "); + + var name = declaration[declaration.length - 1]; + + CONCAT(buffer, "new objj_ivar(\"" + name + "\")"); + + declaration = []; + + if (attributes) + { + accessors[name] = attributes; + attributes = NULL; + } + } + else + declaration.push(token); + } + + // If we have objects in our declaration, the user forgot a ';'. + if (declaration.length) + objj_exception_throw(new objj_exception(OBJJParseException, "*** Expected ';' in ivar declaration, found '}'.")); + + if (ivar_count) + CONCAT(buffer, "]);\n"); + + if (!token) + objj_exception_throw(new objj_exception(OBJJParseException, "*** Expected '}'")); + + for (ivar_name in accessors) + { + var accessor = accessors[name], + property = accessor["property"] || name, + getterName = accessor["getter"] || property, + getterCode = "(id)" + getterName + "\n{\nreturn " + name + ";\n}"; + + if (IS_NOT_EMPTY(instance_methods)) + CONCAT(instance_methods, ",\n"); + + CONCAT(instance_methods, this.method(new objj_lexer(getterCode))); + + // setter + if (accessor["readonly"]) + continue; + + var setterName = accessor["setter"]; + + if (!setterName) + { + var start = property.charAt(0) == '_' ? 1 : 0; + + setterName = "set" + property.substr(start, 1).toUpperCase() + property.substring(start + 1) + ":"; + } + + var setterCode = "(void)" + setterName + "(id)newValue\n{\n"; + + if (accessor["copy"]) + setterCode += "if (" + name + " !== newValue)\n" + name + " = [newValue copy];\n}"; + else + setterCode += name + " = newValue;\n}"; + + if (IS_NOT_EMPTY(instance_methods)) + CONCAT(instance_methods, ",\n"); + + CONCAT(instance_methods, this.method(new objj_lexer(setterCode))); + } + } + else + tokens.previous(); + + // We must make a new class object for our class definition. + CONCAT(buffer, "objj_registerClassPair(the_class);\n"); + + // Add this class to the current bundle. + CONCAT(buffer, "objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));\n"); + } + + while ((token = tokens.skip_whitespace())) + { + if (token == TOKEN_PLUS) + { + if (IS_NOT_EMPTY(class_methods)) + CONCAT(class_methods, ", "); + + CONCAT(class_methods, this.method(tokens)); + } + + else if (token == TOKEN_MINUS) + { + if (IS_NOT_EMPTY(instance_methods)) + CONCAT(instance_methods, ", "); + + CONCAT(instance_methods, this.method(tokens)); + } + + // Check if we've reached @end... + else if (token == TOKEN_PREPROCESSOR) + { + // The only preprocessor directive we should ever encounter at this point is @end. + if ((token = tokens.next()) == TOKEN_END) + break; + + else + objj_exception_throw(new objj_exception(OBJJParseException, "*** Expected \"@end\", found \"@" + token + "\".")); + } + } + + if (IS_NOT_EMPTY(instance_methods)) + { + CONCAT(buffer, "class_addMethods(the_class, ["); + CONCAT(buffer, instance_methods); + CONCAT(buffer, "]);\n"); + } + + if (IS_NOT_EMPTY(class_methods)) + { + CONCAT(buffer, "class_addMethods(meta_class, ["); + CONCAT(buffer, class_methods); + CONCAT(buffer, "]);\n"); + } + + CONCAT(buffer, '}'); +} + +objj_preprocessor.prototype._import = function(tokens) +{ + // The introduction of an import statement forces the creation of a code fragment. + this.fragment(); + + var path = "", + token = tokens.skip_whitespace(), + isLocal = (token != TOKEN_LESS_THAN); + + if (token == TOKEN_LESS_THAN) + { + while((token = tokens.next()) && token != TOKEN_GREATER_THAN) + path += token; + + if(!token) + objj_exception_throw(new objj_exception(OBJJParseException, "*** Unterminated import statement.")); + } + + else if (token.charAt(0) == TOKEN_DOUBLE_QUOTE) + path = token.substr(1, token.length - 2); + + else + objj_exception_throw(new objj_exception(OBJJParseException, "*** Expecting '<' or '\"', found \"" + token + "\".")); + + this._fragments.push(fragment_create_file(path, NULL, isLocal, this._file)); +} + +objj_preprocessor.prototype.method = function(tokens) +{ + var buffer = new objj_stringBuffer(), + token, + selector = "", + parameters = []; + + while((token = tokens.skip_whitespace()) && token != TOKEN_OPEN_BRACE) + { + if (token == TOKEN_COLON) + { + // Colons are part of the selector name + selector += token; + + token = tokens.skip_whitespace(); + + if (token == TOKEN_OPEN_PARENTHESIS) + { + // Swallow parameter/return type. Perhaps later we can use this for debugging? + while((token = tokens.skip_whitespace()) && token != TOKEN_CLOSE_PARENTHESIS) ; + + token = tokens.skip_whitespace(); + } + + // Since this follows a colon, this must be the parameter name. + parameters[parameters.length] = token; + } + + else if (token == TOKEN_OPEN_PARENTHESIS) + // Since :( is handled above, this must be the return type, just swallow it. + while((token = tokens.skip_whitespace()) && token != TOKEN_CLOSE_PARENTHESIS) ; + + // Argument list ", ..." + else if (token == TOKEN_COMMA) + { + // At this point, "..." MUST follow. + if ((token = tokens.skip_whitespace()) != TOKEN_PERIOD || tokens.next() != TOKEN_PERIOD || tokens.next() != TOKEN_PERIOD) + objj_exception_throw(new objj_exception(OBJJParseException, "*** Argument list expected after ','.")); + + // FIXME: Shouldn't allow any more after this. + } + + // Build selector name. + else + selector += token; + } + + var index = 0, + count = parameters.length; + + CONCAT(buffer, "new objj_method(sel_getUid(\""); + CONCAT(buffer, selector); + CONCAT(buffer, "\"), function "); + CONCAT(buffer, "$" + this._currentClass + "__" + selector.replace(/:/g, "_")); + CONCAT(buffer, "(self, _cmd"); + + for(; index < count; ++index) + { + CONCAT(buffer, ", "); + CONCAT(buffer, parameters[index]); + } + + CONCAT(buffer, ")\n{ with(self)\n{"); + CONCAT(buffer, this.preprocess(tokens, NULL, TOKEN_CLOSE_BRACE, TOKEN_OPEN_BRACE)); + CONCAT(buffer, "}\n})"); + + return buffer; +} + +objj_preprocessor.prototype.preprocess = function(tokens, /*objj_stringBuffer*/ aStringBuffer, terminator, instigator) +{ + var buffer = aStringBuffer ? aStringBuffer : new objj_stringBuffer(), + count = 0, + token = ""; while((token = tokens.next()) && ((token != terminator) || count)) { if (instigator) { - if (token == instigator) ++count; - else if (token == terminator) --count; + if (token == instigator) + ++count; + + else if (token == terminator) + --count; } // We convert import statements into objj_request_import function calls, converting // the the file paths to use the proper search arguments. if(token == TOKEN_IMPORT) { - if ((/[^\s]/).test(preprocessed)) - fragments.push(fragment_create_code(preprocessed, OBJJ_CURRENT_BUNDLE, tokens.file)); - - preprocessed = ""; + objj_fprintf(warning_stream, "import keyword is deprecated, use @import instead."); - var path = "", - token = tokens.skip_whitespace(), - isLocal = token != TOKEN_LESS_THAN; - - if(token == TOKEN_LESS_THAN) - { - while((token= tokens.next()) && token != TOKEN_GREATER_THAN) path+= token; - if(!token) objj_throw("Parser Error - Unterminated import statement."); - } - else if(token.charAt(0) == TOKEN_DOUBLE_QUOTE) path= token.substr(1, token.length-2); - else - objj_exception_throw(new objj_exception(OBJJParseException, "*** Expecting '<' or '\"', found \"" + token + "\".")); - - fragments.push(fragment_create_file(path, NULL, isLocal, tokens.file)); + this._import(tokens); } // Safari can't handle function declarations of the form function [name]([arguments]) { } // in evals. It requires them to be in the form [name] = function([arguments]) { }. So we // need to find these and fix them. else if(token == TOKEN_FUNCTION) {//if (window.p) alert("function"); - var accumulator= ""; + var accumulator = ""; // Following the function identifier we can either have an open parenthesis or an identifier: while((token = tokens.next()) && token != TOKEN_OPEN_PARENTHESIS && !(/^\w/).test(token)) @@ -633,64 +791,92 @@ function objj_preprocess_tokens(tokens, terminator, instigator, segment) // If the next token is an open parenthesis, we have a standard function and we don't have to // change it: if(token == TOKEN_OPEN_PARENTHESIS) - preprocessed+= "function"+accumulator+'('; + CONCAT(buffer, "function" + accumulator + '('); + // If it's not a parenthesis, we know we have a non-supported function declaration, so fix it: else { - preprocessed += token + "= function"; + CONCAT(buffer, token + "= function"); #if FIREBUG var functionName = token; // Skip everything until the next close parenthesis. while((token = tokens.next()) && token != TOKEN_CLOSE_PARENTHESIS) - preprocessed += token; + CONCAT(buffer, token); // Don't forget the last token! - preprocessed += token; + CONCAT(buffer, token); // Skip everything until the next open curly brace. while((token = tokens.next()) && token != TOKEN_OPEN_BRACE) - preprocessed += token; + CONCAT(bfufer, token); // Place the open curly brace as well, and the function name - preprocessed += token + "\n \"__FIREBUG_FNAME__" + functionName + "\".length;\n"; + CONCAT(buffer, token + "\n \"__FIREBUG_FNAME__" + functionName + "\".length;\n"); #endif } } + // If we reach an @ symbol, we are at a preprocessor directive. - else if(token == TOKEN_PREPROCESSOR) - preprocessed+= objj_preprocess_directive(tokens); + else if (token == TOKEN_PREPROCESSOR) + this.directive(tokens, buffer); + // If we reach a bracket, we will either be preprocessing a message send, a literal // array, or an array index. - else if(token == TOKEN_OPEN_BRACKET) - preprocessed += objj_preprocess_brackets(tokens); + else if (token == TOKEN_OPEN_BRACKET) + this.brackets(tokens, buffer); + // If not simply append the token. else - preprocessed += token; + CONCAT(buffer, token); } - if (preprocessed.length && (/[^\s]/).test(preprocessed)) - fragments.push(fragment_create_code(preprocessed, OBJJ_CURRENT_BUNDLE, tokens.file)); - - if (!segment) - return fragments.length ? fragments[0].info : ""; - - return fragments; + if (!aStringBuffer) + return buffer; } -function objj_preprocess(aString, aBundle, aSourceFile) -{ - try - { - OBJJ_CURRENT_BUNDLE = aBundle; +objj_preprocessor.prototype.selector = function(tokens, aStringBuffer) +{ + var buffer = aStringBuffer ? aStringBuffer : new objj_stringBuffer(); - return objj_preprocess_tokens(new objj_lexer(aString, aSourceFile), nil, nil, YES); - } - catch (anException) + CONCAT(buffer, "sel_getUid(\""); + + // Swallow open parenthesis. + if (tokens.skip_whitespace() != TOKEN_OPEN_PARENTHESIS) + objj_exception_throw(new objj_exception(OBJJParseException, "*** Expected ')'")); + + // Eat leading whitespace + var selector = tokens.skip_whitespace(); + + if (selector == TOKEN_CLOSE_PARENTHESIS) + objj_exception_throw(new objj_exception(OBJJParseException, "*** Unexpected ')', can't have empty @selector()")); + + CONCAT(aStringBuffer, selector); + + var token, + starting = true; + + while ((token = tokens.next()) && token != TOKEN_CLOSE_PARENTHESIS) { - objj_exception_report(anException, aSourceFile); + if (starting && /^\d+$/.test(token) || !(/^(\w|$|\:)/.test(token))) + { + // Only allow tail whitespace + if (!(/\S/).test(token)) + if (tokens.skip_whitespace() == TOKEN_CLOSE_PARENTHESIS) + break; + else + objj_exception_throw(new objj_exception(OBJJParseException, "*** Unexpected whitespace in @selector().")); + else + objj_exception_throw(new objj_exception(OBJJParseException, "*** Illegal character '" + token + "' in @selector().")); + } + + CONCAT(buffer, token); + starting = (token == TOKEN_COLON); } - return []; + CONCAT(buffer, "\")"); + + if (!aStringBuffer) + return buffer; } diff --git a/Tools/nib2cib/NSAppKit.j b/Tools/nib2cib/NSAppKit.j index cec41a91d..fee18edab 100644 --- a/Tools/nib2cib/NSAppKit.j +++ b/Tools/nib2cib/NSAppKit.j @@ -20,25 +20,25 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "NSButton.j" -import "NSCell.j" -import "NSControl.j" -import "NSCustomObject.j" -import "NSCustomView.j" -import "NSFont.j" -import "NSIBObjectData.j" +@import "NSButton.j" +@import "NSCell.j" +@import "NSControl.j" +@import "NSCustomObject.j" +@import "NSCustomView.j" +@import "NSFont.j" +@import "NSIBObjectData.j" print("1"); -import "NSNibConnector.j" +@import "NSNibConnector.j" print("1"); -import "NSResponder.j" +@import "NSResponder.j" print("1"); -import "NSSlider.j" +@import "NSSlider.j" print("1"); -import "NSView.j" +@import "NSView.j" print("1"); -import "NSWindowTemplate.j" +@import "NSWindowTemplate.j" print("1"); -import "NSSplitView.j" +@import "NSSplitView.j" print("1"); function CP_NSMapClassName(aClassName) diff --git a/Tools/nib2cib/NSArray.j b/Tools/nib2cib/NSArray.j index 7bd5b312c..c66e9405f 100644 --- a/Tools/nib2cib/NSArray.j +++ b/Tools/nib2cib/NSArray.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import @implementation NSArray : CPObject diff --git a/Tools/nib2cib/NSButton.j b/Tools/nib2cib/NSButton.j index 60e408042..5f43079be 100644 --- a/Tools/nib2cib/NSButton.j +++ b/Tools/nib2cib/NSButton.j @@ -23,10 +23,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import -import "NSCell.j" -import "NSControl.j" +@import "NSCell.j" +@import "NSControl.j" @implementation CPButton (NSCoding) diff --git a/Tools/nib2cib/NSCell.j b/Tools/nib2cib/NSCell.j index 36eea53c4..8bd167989 100644 --- a/Tools/nib2cib/NSCell.j +++ b/Tools/nib2cib/NSCell.j @@ -23,9 +23,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import -import "NSFont.j" +@import "NSFont.j" @implementation NSCell : CPObject diff --git a/Tools/nib2cib/NSControl.j b/Tools/nib2cib/NSControl.j index 6714b5fd3..1068de6c2 100644 --- a/Tools/nib2cib/NSControl.j +++ b/Tools/nib2cib/NSControl.j @@ -20,10 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import -import "NSCell.j" -import "NSView.j" +@import "NSCell.j" +@import "NSView.j" @implementation CPControl (NSCoding) diff --git a/Tools/nib2cib/NSCustomObject.j b/Tools/nib2cib/NSCustomObject.j index a6ead1930..6724397fe 100644 --- a/Tools/nib2cib/NSCustomObject.j +++ b/Tools/nib2cib/NSCustomObject.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import @implementation _CPCibCustomObject (NSCoding) diff --git a/Tools/nib2cib/NSCustomView.j b/Tools/nib2cib/NSCustomView.j index 7fc9eab96..99248a4c1 100644 --- a/Tools/nib2cib/NSCustomView.j +++ b/Tools/nib2cib/NSCustomView.j @@ -20,9 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import -import "NSView.j" +@import "NSView.j" var _CPCibCustomViewClassNameKey = @"_CPCibCustomViewClassNameKey"; diff --git a/Tools/nib2cib/NSFont.j b/Tools/nib2cib/NSFont.j index d5aebd34c..7416e412d 100644 --- a/Tools/nib2cib/NSFont.j +++ b/Tools/nib2cib/NSFont.j @@ -20,7 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import + @implementation CPFont (NSCoding) diff --git a/Tools/nib2cib/NSFoundation.j b/Tools/nib2cib/NSFoundation.j index 4c8e7af2c..5a5155272 100644 --- a/Tools/nib2cib/NSFoundation.j +++ b/Tools/nib2cib/NSFoundation.j @@ -20,4 +20,4 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import "NSArray.j" +@import "NSArray.j" diff --git a/Tools/nib2cib/NSIBObjectData.j b/Tools/nib2cib/NSIBObjectData.j index 594e8ff79..11f81287f 100644 --- a/Tools/nib2cib/NSIBObjectData.j +++ b/Tools/nib2cib/NSIBObjectData.j @@ -32,9 +32,10 @@ #import #import */ -import +@import + +@import -import @implementation _CPCibObjectData (NSCoding) diff --git a/Tools/nib2cib/NSNibConnector.j b/Tools/nib2cib/NSNibConnector.j index 1ddba130a..0ce6ed7dd 100644 --- a/Tools/nib2cib/NSNibConnector.j +++ b/Tools/nib2cib/NSNibConnector.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import @implementation _CPCibConnector (NSCoding) diff --git a/Tools/nib2cib/NSResponder.j b/Tools/nib2cib/NSResponder.j index a9667feaf..0f9e20684 100644 --- a/Tools/nib2cib/NSResponder.j +++ b/Tools/nib2cib/NSResponder.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import @implementation CPResponder (NSCoding) diff --git a/Tools/nib2cib/NSSlider.j b/Tools/nib2cib/NSSlider.j index c9b6511cb..dacf40e2e 100644 --- a/Tools/nib2cib/NSSlider.j +++ b/Tools/nib2cib/NSSlider.j @@ -20,9 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import -import "NSSlider.j" +@import "NSSlider.j" @implementation CPSlider (CPCoding) diff --git a/Tools/nib2cib/NSSplitView.j b/Tools/nib2cib/NSSplitView.j index 8dc7d83ab..aaa706551 100644 --- a/Tools/nib2cib/NSSplitView.j +++ b/Tools/nib2cib/NSSplitView.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import @implementation CPSplitView (CPCoding) diff --git a/Tools/nib2cib/NSView.j b/Tools/nib2cib/NSView.j index dc8eb9058..2c54fbf14 100644 --- a/Tools/nib2cib/NSView.j +++ b/Tools/nib2cib/NSView.j @@ -23,7 +23,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import @implementation CPView (NSCoding) diff --git a/Tools/nib2cib/NSWindowTemplate.j b/Tools/nib2cib/NSWindowTemplate.j index c74339b20..42537c657 100644 --- a/Tools/nib2cib/NSWindowTemplate.j +++ b/Tools/nib2cib/NSWindowTemplate.j @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import @implementation _CPCibWindowTemplate (NSCoding) diff --git a/Tools/nib2cib/main.j b/Tools/nib2cib/main.j index 43866e029..727910e64 100644 --- a/Tools/nib2cib/main.j +++ b/Tools/nib2cib/main.j @@ -20,12 +20,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import +@import -import +@import -import "NSFoundation.j" -import "NSAppKit.j" +@import "NSFoundation.j" +@import "NSAppKit.j" importClass(java.io.FileWriter); importClass(java.io.BufferedWriter);