Commit Graph
952 Commits
Author SHA1 Message Date
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
Aparajita Fishman af142a5ccc Merge branch 'refs/heads/cpdictionary_throw_on_nil' into temp 2013-03-05 15:50:41 -05:00
Alexander Ljungberg f4b08a9ce2 New: - CPObject performSelector:withObject:afterDelay:.
Also - CPObject cancelPreviousPerformWithTarget: and other related methods.
2013-03-05 18:52:06 +00:00
Martin Carlberg e686fbc0a8 Fixed: Handle deprecated setObject:forKey: calls with nil object on CPDictionary 2013-03-01 10:50:00 +01:00
Martin Carlberg 64fb0934a4 Fixed: Do not setObject: forKey: when object or key is nil 2013-02-28 22:59:11 +01:00
Martin Carlberg 6ee3a395fb Fixed: CPDictionary setObject: forKey: will log deprecated warning when passing nil object or key.
This should be replaced by throwing exception after release of next stable version. Code included for this.
2013-02-28 22:58:42 +01:00
Aparajita Fishman 07f9b94548 Fixed: initializer did not allow programmers to pass arbitrary types
Originally the initializer had coerced the parameter to a string, even though it is clearly documented that it should be a string. A later commit removed that coercion.

This commit reinstates the type coercion and thus saves the world from those who would pass non-string types in a parameter that says "withString".
2013-02-27 15:17:17 -05:00
Aparajita Fishman ae2ed8bf94 Fixed: empty strings and indexes out of range were not handled
Previously CPAttributedString did not provide an -init method,
with the result that an attributed string created with [[CPAttributedString alloc] init]
would not be correctly initialized.

Also, some methods that took indexes into the string were not checking for an invalid index and were not raising exceptions when the documentation said they should.

Finally, some methods that were supposed to return empty dictionaries were returning nil.

This commit fixes all of these problems. Empty strings should no longer cause errors.

Closes #533
2013-02-26 20:15:15 -05:00
Aparajita Fishman 471641c228 Fixed: subviews in cib did not receive view(Will/Did)MoveToSuperview:
In Cocoa, viewWillMoveToSuperview: and viewDidMoveToSuperview: are called when views are instantiated from code or from a nib.

Previously in Cappuccino, when a view was instantiated from a cib, the _subviews of the view were directly set from the decoded subview array. This short-circuited all of the normal notifications a view receives when added to a superview, including viewWillMoveToSuperview: and viewDidMoveToSuperview:. As a result, some views that override these methods, such as CPSearchField, were not set up correctly when instantiated from a cib.

With this commit, subviews instantiated from a cib are manually added to their superview, thus ensuring they go through the same cycle as views instantiated from code, and ensuring that viewWillMoveToSuperview: and viewDidMoveToSuperview: are called.

Closes #1699
2013-02-25 20:09:18 -05:00
Alexander Ljungberg 5b05dc92a1 More dictionary literals. 2013-02-25 18:27:44 +00:00
Alexander Ljungberg 8bcbeb0aa9 Improve code readability with dictionary literals. 2013-02-25 17:02:36 +00:00
Alexander Ljungberg 6d1c4a9570 Fixed: - CPMutableArray removeObjectIdenticalTo did not remove all instances, was documented incorrectly.
Contrary to what the previous documentation said, removeObjectIdenticalTo: should remove all instances of the argument from the receiver, not just the first one.
2013-02-24 23:51:48 +00:00
Alexander Ljungberg be4a168601 Make 30268f9865c compatible with Internet Explorer 8-. 2013-02-24 23:50:09 +00:00
Alexander Ljungberg c4370240f8 Fixed: subclasses of CPMutableArray had broken removeObject:.
The `removeObject:` default provided in CPMutableArray would not work in subclasses because it relied on the class having a .length property.
2013-02-24 23:43:20 +00:00
Alexander Ljungberg 0268f9865c Faster CPMutableArray removeObjectIdenticalTo:.
About 6-8X speedup by skipping all the `indexOfObjectIdenticalTo:` calls and going straight to JS `indexOf`.
2013-02-24 15:19:00 +00:00
Aparajita Fishman b6f0a29f8f Merge branch 'CPURLConnection-sendSynchronousRequest' of https://github.com/cacaodev/cappuccino 2013-02-19 09:47:40 -05:00
Aparajita Fishman abaa1e81f2 Support for multiple-value bindings
- CPView and subclasses support multiple-value hidden bindings.
- CPControl and subclasses support multiple-value enabled bindings.
- CPWindow and CPBox support multiple-value title with pattern bindings.
- CPButton supports multiple argument + target bindings.
- CPImageView and CPTextField support multiple-value editable bindings.
- CPMenuItem supports multiple-value enabled bindings.
- Fixed bugs in CPObjectController with simple collection operators.
- CPColorWell uses black as the placeholder color.
- Runtime object attributes from a cib are applied as they are read, not deferred.
- NSNumberFormatter now reads the number style from the xib.
- Normalized some parameter names.
- Formatting.
- Test app for all binding types.
2013-02-15 12:21:13 -05:00
aparajita 2425c8c5d3 Merge pull request #1614 from cacaodev/CPDictionary-initWithObjectsAndKeys
CPDictionary -initWithObjectsAndKeys: do not treat a nil value as a final value
2013-02-14 11:39:21 -08:00