Commit Graph
90 Commits
Author SHA1 Message Date
David Richardson a240d312d0 Deconstruct _CPSet monolithic layout and relocate KVO proxies
•	Refactor @implementation _CPKVCSet and CPObject (CPSetKVO) from _CPSet.j to the tail of CPMutableSet.j.
•	Fix legacy compiler parse failures by ensuring the CPMutableSet superclass symbol is fully resolved within the translation unit prior to proxy evaluation.
•	Maintain strict DAG compliance across the modern toolchain pipeline topology.
•	Embed explicit #pragma mark navigation landmarks and enforce Allman brace layout to improve human structural ergonomics.
2026-07-08 17:35:33 -06:00
daboe01 0e5f3b1697 fixed caching 2026-04-03 13:49:33 +02:00
daboe01 043029cf41 new: _CPKVOCollectionOperatorObserver 2026-04-03 13:30:13 +02:00
Martin CarlbergandGitHub 7dc77ed609 Fixed: Make sure we handle undefined when testing for nil values (#2862) 2020-01-31 13:43:58 +01:00
Martin CarlbergandGitHub fed0703ecf New: Allow lazy loading control for combined observer key paths (#2854)
This pull request adds a kvoValueForKey: method used by _CPKVOForwardingObserver for getting values.
The default action is to just return the valueForKey value.
Override this method if you want any other behavior.
It can be used to just return nil if you are implementing a lazy load behavior on a class.
It can allow a combined binding to observe this object without trigger any lazy loading.
2019-11-28 09:38:55 +01:00
daboe01 25c8b2d631 fixed: typo in call to replaceObjectsAtIndexes 2018-02-24 14:59:27 +01:00
Martin Carlbergandcacaodev ae5d31746e Dependent key paths use a relationship (#2431)
Fixed: When dependent key paths use a relationship, only the first added observer will observe the attribute for the relationship object.

Also, an optimisation on when the willChange… chain is running, there is no need to replace the observers as no new values are set yet. That will be done when the didChange… chain is running.
2016-05-09 22:14:20 +02:00
Martin Carlberg 758ad3eb06 Fixed: Method types was not copied into new KVO implementation of a class that is observed with KVO.
Some test cases are also added for this.
2015-11-20 12:43:53 +01:00
Martin Carlberg e5e50c2220 Fixed: Use the faster objj_msgSend instead of the old slower objj_msgSend
In some places the objj_msgSend function is called directly. Most of the times the old slower version is called. This commit will use the never faster version instead.
2015-10-01 22:17:13 +02:00
Martin Carlberg 643566bbfd Honor options when creating KVO change dictionary 2014-10-09 19:27:57 +02:00
Martin Carlberg bb58a206a8 Fixed: Removed all warnings of conflicting return and parameter types caused by the new compiler 2013-08-12 16:46:14 +02:00
Alexander Ljungberg 85985add3c Fixed: objects without a superclass. 2013-06-15 17:53:54 +01: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
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
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 Fishman 12b2bd2c52 Wrong filename in header 2013-02-11 19:46:06 -05:00
Aparajita Fishman 64a0fb278b Objj2 compiler fixes
Compiled all files individually:

- Added missing imports.
- Added @class/@global declarations to break circular dependencies.
- Fixed broken code in CPCharacterSet -hasMemberInPlane:
- Misc. code cleanup.
2013-01-23 15:45:08 +07:00
Ilya Kulakov 3886f27acd Fix crash if an observer is set between willChange…/didChange…
When you add an observer to an object first time, its class is
implicitly changed to a KVO_originalClassName (subclass of original
class). This subclass adds willChange…/didChange… methods for
observable properties.
If you send willChange… before you add an observer, it does nothing.
But if you send didChange… just after, the app will crash, because
new KVO_originalClassName nerver receives willChange…

The idea is to maintain counter of all received willChange… messages
(per key) and decrease it in didChange…
When KVO_originalClassName is created and didChange… is received
(without opening willChange… to new class), exception is not thrown
immediately, but the counter is checked first.
If it's greater than 0, then didChange… just closes
an unboserved willChange… Otherwise exception is thrown, as expected.
2012-07-14 19:32:25 +07:00
Alexander Ljungberg cff29904d7 Refs #1599. Format code. 2012-07-06 15:53:03 +01:00
Ilya Kulakov 4094a1f826 Fix wrong change is sent to observer when top level object is changed.
When you change the top level object, observer MUST receive value
for the key path of the previous top level object as old and
value for the key path of the new top level object as new.
2012-07-05 17:59:29 +07:00
Aparajita Fishman e2ead56256 Collection KVC fixes, nextObject correctness
- Moved common CPArray/CPSet collection KVC operators to _CPCollectionKVCOperators.
- Implemented KVC operator dispatch using Objective-J.
- Fixed infinite loop with empty  collection in @min, @max and @sum operators.
- Correctly return valueForUndefinedKey when necessary.
- valueForUndefinedKey reason uses raw description for consistency, class' overridden description may not helpful at all.
- Don't create a forwarder for @ operators with property paths.
- Fixed CPSet -valueForKeyPath to correctly deal with nil/undefined/empty values.
- Added tests for collection  KVC operators.
- enumerator -nextObject should always compare against nil for clarity, correctness, and consistency.
2012-04-03 22:16:55 -07:00
Alexander Ljungberg d2f3ceaf67 Documentation. 2012-03-27 23:45:18 +01:00
Alexander Ljungberg 271b935ba2 + (BOOL)automaticallyNotifiesObserversOf<Key> support. 2012-03-27 23:42:17 +01:00
Aparajita Fishman 1c2a304ee5 Assignment of function is a statement and should be semicolon terminated. Some miscellaneous linting as well. 2012-01-05 17:51:37 -10:00
Alexander Ljungberg 78b9c5b576 Fixes #1343. Support nested willChange… didChange… calls.
When multiple calls are nested, only the first willChange… and the last didChange… will notify observers, avoiding duplicate notifications for the same change.
2011-09-07 16:14:01 +01:00
Klaas Pieter Annema 03e7d81ffa fail more gracefully when attempting to remove the same observer twice
Before this commit we would fail gracefully for single keys. For key paths an application would crash because we would try to get the forwarder property of an undefined object. This commit makes sure we don't attempt any removal and logs a warning (just like Cocoa) about the attempt to remove an unregistered observer.
2011-04-26 11:34:40 +02:00
Alexander Ljungberg ccf9225773 Minor KVO optimisation. 2011-04-02 18:10:13 -04:00
Ross Boucher 6435372fd9 We weren't actually keeping track of replaced methods, and thus were replacing every time you call addObserver: 2011-02-25 17:59:54 -08:00
Stephen Ierodiaconou 6a942630e4 Fixing spelling mistakes 2011-01-24 11:05:48 +02:00
Stephen Ierodiaconou 494f615aaa Merge branch 'master' into imports
Conflicts:
	Foundation/CPScanner.j
2011-01-15 09:11:46 +02:00
Francisco Ryan Tolmasky I e39fa44cdb Fix for typo in new KVC code.
Reviewed by me.
2010-12-27 10:40:27 -08:00
Francisco Ryan Tolmasky I 06b8636817 Removed remaining references to isKeyObserved.
Reviewed by me.
2010-12-27 10:38:10 -08:00
Francisco Ryan Tolmasky I 6ff21692f1 Fix for incorrectly installing KVO if all the mutation methods aren't implemented.
Reviewed by me.
2010-12-27 02:18:52 -08:00
Francisco Ryan Tolmasky I 67ac778d4c Sight improvement to applyChange: in KVO.
Reviewed by me.
2010-12-26 00:31:14 -08:00
Stephen Ierodiaconou b70018bd80 Import fixes and lint 2010-12-26 01:34:37 +02:00
Francisco Ryan Tolmasky I d23bf7b927 Some KVC cleanup:
1. Added class_getInstanceVariable to runtime.
2. Changed KVC to rely on class-defined variables vs prototypal ones.
3. Modified KVO code to use public APIs.

Reviewed by me.
2010-12-23 23:46:23 -08:00
Alexander Ljungberg 8edee4e755 Fix accidental globals, cleanup. 2010-12-15 16:02:50 +01:00
Daniel Stolzenberg 29ed8f3116 fixed issues with "CPKeyValueObservingOptionPrior" and "CPKeyValueObservingOptionOld" on dependent keys caused by improper wrapped observation messages 2010-12-09 14:56:55 +01:00
Daniel Stolzenberg 4a142b5c02 implemented missing features of KVO for unordered to-many relationships in CPKeyValueCoding.j 2010-10-27 19:08:34 +02:00
Daniel Stolzenberg 6483ea233c imported new implementation for unordered to-many relationships in CPKeyValueObserving.j/CPSet+KVO.j 2010-10-26 14:23:24 +02:00
Daniel Stolzenberg 895ed4f6ff implemented missing replacement methods for accessor patterns in CPKeyValueObserving.j 2010-10-26 14:20:54 +02:00
Daniel Stolzenberg 5ff7e66981 implemented "will/didChangeValueForKey:withSetMutation:usingObjects:" in _CPKVOModelSubclass in CPKeyValueObserving.j 2010-10-26 14:17:39 +02:00
Daniel Stolzenberg a2ff814796 added missing accessor patterns in "_replaceSetterForKey:" in CPKeyValueObserving.j 2010-10-26 14:13:21 +02:00
Daniel Stolzenberg c1e42a2f3e refactored duplicated method copying implementation 2010-10-26 14:11:47 +02:00
Daniel Stolzenberg 9e1c07b195 added "CPKeyValueSetMutationKind" definitions to CPKeyValueObserving.j 2010-10-26 14:08:56 +02:00
Daniel Stolzenberg c71c732fc0 added "will/didChangeValueForKey:withSetMutation:usingObjects:" stubs to CPObject in CPKeyValueObserving.j 2010-10-26 14:06:56 +02:00
Klaas Pieter Annema 5074938437 implement KVO dependent key path support 2010-10-07 21:17:28 +02:00
Brian Donovan 0ce115bc9c Ensure observeValueForKeyPath:ofObject:change:context is called consistently.
During the "normal" callback for new and old values, the ofObject:
parameter passed to the observer is the original receiver of the
addObserver:forKeyPath:options:context: call, but that isn't the case
with the call caused by the CPKeyValueObservingOptionInitial option.
This commit uses _targetObject, the receiver of the addObserver:...
call, rather than self, the _CPKVOProxy.
2010-10-05 07:45:43 -07:00
Alexander Ljungberg febdf4092e New implementation of change notifications from CPArrayController.
It is crucial that we send notification only before and after complete changes. In the middle notifications might cause observers to see or react to inconsistent data (e.g. selection indexes pointing to rows no longer present). Added some unit tests - more might be needed in the future. Fixed: before and after values when observing array controller key paths during content changes or rearranges were wrong. Fixed: the array controller sent out multiple redundant change notifications.
2010-08-23 18:53:29 -04:00