Commit Graph
969 Commits
Author SHA1 Message Date
Aparajita Fishman 42ad40d10d New: sort the keys in CPDictionary -description.
This makes it easier to find an item in a large dictionary.
2013-08-09 08:28:37 -04:00
Aparajita Fishman 2da6c88fad Fixed: constant name was misleading.
Previously CPTimerMinTimeInterval was used as a constant for the *default* time interval used when a timer was initialized with an interval <= 0. It isn't the minimum, it is possible to create a timer with an interval less than that constant's value.

The name has been changed to CPTimerDefaultTimeInterval to make it clearer what it's purpose is. It has also been changed to a #define, that will result in smaller generated code.
2013-07-26 02:08:14 -04:00
Alexandre Wilhelm 56963d65f3 Fixed: CPTimer don't allow to put timeInterval below 0.1
Previously it wasn't possible to set the timeInterval below 0.1.
Now you can do it and the timeInterval will set to 0.1 if the timeInterval is less or equal to 0 as in cocoa.

Cocoa specs here:
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/Reference/NSTimer.html
2013-07-22 15:20:10 -07:00
Aparajita Fishman 0bd670b2a3 Fixed: extraneous colon in https scheme test.
And whitespace formatting.
2013-07-20 13:23:05 -04:00
Aparajita Fishman e0af5d0573 Fixed: changed magic number to constant, add missing space after comma. 2013-07-20 12:05:53 -04:00
Blair Duncan 3419f6fbb4 Fixed: CPTimer number of seconds interval set to 0.1 if less than or equal to 0.0
Cocoa specs here:
 https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/Reference/NSTimer.html
...
"Parameters
seconds
The number of seconds between firings of the timer. If seconds is less than or equal to 0.0, this method chooses the nonnegative value of 0.1 milliseconds instead."
2013-07-18 09:33:12 -04:00
Alexander Ljungberg 0f53ceda30 Fixed: comparing a CPNumber vs nil or CPNull didn't throw an exception.
In Objective-C, both `[@34 compare:nil]` and `[@34 compare:[CPNull null]]` throw invalid argument exceptions.

This fix makes the same true in Objective-J.

Refs #1959.
2013-07-15 10:47:38 +01:00
Alexander Ljungberg 315e3fccf3 Formatting.
Refs #1959.
2013-07-15 10:36:48 +01:00
Martin Carlberg f52f11899a New: Sort using descriptors handles nil and CPNull in correct way
This is the same way as Cocoa works.
Also added test case.
2013-07-09 13:38:13 +02:00
Martin Carlberg fc403d679c New: CPString 'compare:' method handles nil and CPNull in correct way
This is the same way as Cocoa works.
Also added test case.
2013-07-09 13:37:12 +02:00
Alexander Ljungberg 85985add3c Fixed: objects without a superclass. 2013-06-15 17:53:54 +01:00
Alexander Ljungberg e59389b0dd Fixed: crash in - CPArray/CPDictionary description containing self referential JS object.
Without this fix, certain JS contents could cause `- CPDictionary description` and `- CPArray description` to crash.

This change limits how deeply the description code will recurse before returning a default "…" description.
2013-06-13 20:14:22 +01:00
Alexander Ljungberg 22905745f1 Fixed: crash on -CPArray/CPDictionary description if a value was the window object.
Without this fix, code like `[@{ "a": window } description]` would crash with a "Maximum call stack size exceeded" exception.

Now`CPDescriptionOfObject()` function simply describes the window object as `window` rather than trying to serialise it into a huge description string.
2013-06-13 19:19:22 +01:00
Alexander Ljungberg bf94dd3a6e New: KVC setValue:forKey: now automatically unwraps CPValue.
This corresponds to the same KVC behaviour in Cocoa and is key when decoding cibs with certain properties set to struct values (such as NSSize).
2013-06-13 13:20:22 +01:00
Alexander Ljungberg fe79628034 Fixed: CGRectFromString made bad CGSizeFromString call.
Without this fix, CGRectFromString would call CGSizeFromString with a value like "{1, 2}}" (not the extra trailing "}"). Although CGSizeFromString didn't complain, it wasn't correct either.
2013-06-13 12:46:08 +01:00
Alexander Ljungberg 563300a16f Test: CGGeometry "string from" for point, size and rect. 2013-06-13 12:43:48 +01:00
Aparajita Fishman 391ff7279d Fixed: capp_lint errors. 2013-05-16 15:02:45 -04:00
Alexander Ljungberg 3fb0dd725a Fixed: CPLocale for English, United Kingdom had the wrong identifier. 2013-05-14 13:06:53 -07:00
Alexander Ljungberg a324cb3306 Fixed: CPLocale detection didn't work.
Previously, if the browser provided a language string such as "en-US", CPLocale would try to look up the locale for "en_EN", which wouldn't exist so it'd always select the default language.

This fix uses the browser provided language string fully to select the appropriate locale.
2013-05-14 13:03:31 -07:00
Alexander Ljungberg 2a9f3deb0e Merge pull request #1930 from mrcarlberg/cplocal_cant_handle_unknown_country_codes
Fixed: CPLocal can't handle unknown language codes
2013-05-14 12:00:39 -07:00
Alexander Ljungberg b4fb4ba941 Formatting: CPLocale.
Tabs to spaces and other whitespace changes.
2013-05-14 11:59:17 -07:00
Martin Carlberg 9d86391bdb Fixed: CPLocal can't handle unknown language codes
When the language code is not known it still sets the current language code
to the unknown code instead of the defualt 'en_US' code.
This makes the test cases for CPDateFormatter fail when run on a foreign system.
2013-05-14 13:30:30 +02:00
Alexander Ljungberg d7c676893d Merge pull request #1914 from mrcarlberg/predicate_expression_equals_nil
CPExpression and CPPredicate can't handle nil as argument in method isEqual:
2013-05-13 22:21:05 -07:00
Aparajita Fishman 01291591b7 Fixed: missing self. in call to _delegate.
Small formatting and code tweaks as well.
2013-05-09 07:31:11 -04:00
Aparajita Fishman 1f280b3985 New: CPNumberFormatter -localizedStringFromNumber:numberStyle:
Added unit test as well.
2013-05-06 17:45:16 -04:00
Antoine Mercadal f8513eae26 Merge pull request #1903 from Dogild/CPDateFormatterSupport
New: Added support for CPTimeZone and CPDateFormatter
2013-05-06 13:11:36 -07:00
Martin Carlberg ffdee8c3d7 Fixed: Method isEqual: can handle nil as an argument for CPExpression and CPPredicate including sub classes. 2013-04-23 12:58:07 +02:00
Alexander Ljungberg fe26e6cfe0 New: + CPException raise:format:.
This method allows the exception reason to be a formatted string with parameter replacement.
2013-04-21 14:56:57 +01:00
Alexandre Wilhelm 98a59c4700 Fixed small bus about timeZone 2013-04-15 16:20:02 -07:00
Alexandre Wilhelm 3497e36f23 Fixed bunch of bugs in CPDateFormatter with TimeZone 2013-04-15 14:25:30 -07:00
Alexandre Wilhelm 0bbaec0829 New: Added support for CPTimeZone and CPDateFormatter
- Added support for CPDateFormatter in Foundation
- Added support for CPTimeZone in Foundation
- Added support fo CPDateFormatter in nib2cib

Test app in Tests/Manual/CPDateFormatter
UnitTest in Tests/Foundation/CPTimeZoneTest.j
UnitTest in Tests/Foundation/CPDateFormatterTest.j
2013-04-12 11:15:10 -07:00
Aparajita Fishman d64ea284fb Fixed: CPBundle -bundleWithIdentifier did not create CPBundle when necessary.
Previously, if a CFBundle with the given identifier had been loaded, but no CPBundle had yet been created with the given identifier, -bundleWithIdentifier would return nil instead of a newly constructed CPBundle with the CFBundle's URL.

This commit correctly returns a newly constructed CPBundle when a CFBundle is found.
2013-04-06 16:20:21 -04:00
Aparajita Fishman 0193632673 New: use a more compact representation of CGSize/CGPoint/CGRect in description. 2013-04-05 23:18:56 -04:00
Aparajita Fishman a3730812bc New: CFBundle.identifier, CFBundle.bundleWithIdentifier, CPBundle -bundleWithIdentifier.
Finding a bundle by identifier is theoretically better than using a class.
2013-04-05 23:16:05 -04:00
Antoine Mercadal d268013bf0 Fixed: Make build under rhino to work
Previously, rhino build was failing
2013-03-26 18:03:38 -07:00
Alexandre Wilhelm 1649ea64cc New: CPDatePicker Support
- Added CPDatePicker
- Added CPLocale
- nib2cib for CPDatePicker

Test app in Tests/Manual/CPDatePickerTest
2013-03-26 16:52:46 -07:00
Aparajita Fishman 097d8e9b97 Fixed: adding object to CPArrayController generated warning.
Previously, if properties were bound to table columns in a cell-based table, and an object was added/inserted using CPArrayController, a warning was generated about a missing observer.

This commit is a temporary fix, the real fix is to implement more granular notifications during didChangeValueForKey:, which will eliminate the source of this problem.

Fixes #1781.
2013-03-24 20:12:22 -04:00
Aparajita Fishman 05fa505bb6 Fixed: CPArray did not allow binding to @count.
Previously, CPArray did not allow binding to the collection operator @count. In Cocoa this is allowed.

This commit allow the key path @count to be observed, so that @count can be bound to.

Formatting fixes as well.
2013-03-23 15:21:50 -04:00
Tim Lewis bd6d2e71e7 Fixed: stringByTrimmingCharactersInSet not removing characters at end
If a string had characters from the set at both the start and end,
the end trim was one character less than required.
2013-03-21 13:44:00 +00:00
Aparajita Fishman afd5925499 Fixed: _CG and _CP macros were confusing and could degrade performance
Previously, Cappuccino was using preprocessor macros internally for the CGPoint/Size/Rect/Inset/Affine functions, as well as for CPRange. These macros had the same name as the corresponding function, but began with _. The functions were actually defined using the macros.

The motivation behind using macros was to increase performance by reducing function calls. However, there were a number of problems with this approach:

- There was an artificial dichotomy between _CG macros and the corresponding CG functions. We never completely replaced CG function calls with _CG macros. In fact, they were often mixed up in the same file. There was an extra burden on the programmer to remember to use the macro instead of the function.
- If a method call was passed as an argument to a macro, performance could actually be significantly *worse* than a function call. For example, _CGGetRectMakeCopy([view frame]) would expand to `{ origin:{ x:[view frame].origin.x, y:[view frame].origin.y }, size:{ width:[view frame].size.width, height:[view frame].size.height } }`. So instead of a single objj_msgSend and a single simple function call, we ended up with 4 objj_msgSend calls, which are way more expensive than simple function calls.
- Because of this expansion problem, to use macros efficiently required us to remember to use variables for all macro parameters. This didn't happen, and shouldn't have to happen.
- Finally, with modern Javascript engines, function call overhead is so small that it really isn't worth using the macros.

This commit eliminates the _CGGeometry, CGAffineTransformation and CPRange macros and replaces them with function calls.

BREAKING CHANGE:
The macros are no longer available. They could only be used with compiled code, but if there is any user code that used them, they will have to be replaced with the corresponding functions.
2013-03-13 12:22:10 -04:00
cacaodev cd96f78228 CPPredicate: use @ref instead of custom function 2013-03-10 19:56:07 +01:00
Alexander Ljungberg 39b49d47f9 Fixed: CPNumberFormatter formatted @"" as any number.
Without this fix, `- CPNumberFormatter getObjectValue:forString:errorDescription:` would return `YES` for string @"", like if it was properly converted to an object value, but then actually leave object value unchanged.

With this fix object value is set to nil like in Cocoa.

Refs #1829.
2013-03-10 13:30:35 +00:00
Alexander Ljungberg c550cd7afb New: optimise CPArray enumerateObjectsWithOptions:usingBlock:. 2013-03-10 13:09:24 +00:00
Alexander Ljungberg f4096b94a7 New: use @ref and @deref instead of Ref.h throughout Cappuccino. 2013-03-10 13:08:34 +00:00
Andrew HankinsonandAparajita Fishman 5fac631f6f New: minimum/maximum support for CPNumberFormatter
Previously, minimum and maximum were not supported in CPNumberFormatter.

This commit adds support for these in IB and via code. Updated unit tests included.

Fixes #1829
2013-03-08 09:30:31 -05:00
Blair Duncan 62670a4fa4 improved as per aparajita 2013-03-07 22:18:59 -05:00
Blair Duncan 7d51a34d11 fix for undoManager isUndoRegistrationEnabled 2013-03-07 16:21:37 -05:00
Andrew Hankinson 7bef84e4e9 Allow CPDecimal to handle decimal numbers with leading zeros
Without this fix, CPDecimal will return NaN for numbers that have leading zeros, e.g., 0123.

This fix changes the matching regex to allow leading zeros to pass. This is then converted to a proper number later on, e.g., "0123" => 123. This is in line with Cocoa behaviour.

This commit also includes updated unit tests.
2013-03-07 00:26:02 -05:00
Aparajita Fishman e2580bda05 Fixed: objj_backtrace_print is not available in release frameworks
objj_backtrace_print is only available in debug frameworks. Previously we were not ensuring that objj_backtrace_print was available, which caused an error when running with release frameworks.

Now objj_backtrace_print is checked for availability.
2013-03-06 10:30:54 -05:00
Aparajita Fishman 4b0b19aec7 Formatting, refactoring, use separate message for nil key 2013-03-06 07:49:18 -05:00