@@ -73,7 +73,7 @@ def apply(self, obj: Perspective) -> None:
7373
7474 # Identify the function that was decorated.
7575 try :
76- decorated_func = decorated_func_mapping [(type (obj ), type (self ))]
76+ decorated_func = decorated_funcs [(type (obj ), type (self ))]
7777 except KeyError :
7878 return
7979
@@ -112,6 +112,8 @@ def __init__(
112112
113113 topic_prefix = construct_topic (cls ) + "."
114114
115+ cls .projected_types : list [type [Mutates ]] = []
116+
115117 # Find the event decorators on this class.
116118 func_decorators = [
117119 decorator
@@ -153,7 +155,9 @@ def __init__(
153155 decorated_func_callers [decorator ] = func_caller
154156
155157 # Remember which decorated func to call.
156- decorated_func_mapping [(cls , func_caller )] = decorator .decorated_func
158+ decorated_funcs [(cls , func_caller )] = decorator .decorated_func
159+
160+ cls .projected_types .append (func_caller )
157161
158162 def _insert_decorator_func_caller (
159163 cls , given_event_class : type [Mutates ], topic_prefix : str
@@ -220,7 +224,7 @@ def cb(self) -> list[Selector]:
220224
221225
222226given_event_class_mapping : dict [type [Mutates ], type [DecoratedFuncCaller ]] = {}
223- decorated_func_mapping : dict [tuple [MetaPerspective , type [Mutates ]], CallableType ] = {}
227+ decorated_funcs : dict [tuple [MetaPerspective , type [Mutates ]], CallableType ] = {}
224228
225229
226230class MetaEnduringObject (SupportsEventDecorator ):
@@ -366,58 +370,6 @@ class Selector:
366370
367371class MetaSlice (SupportsEventDecorator ):
368372 pass
369- # def __init__(
370- # cls, name: str, bases: tuple[type, ...], namespace: dict[str, Any]
371- # ) -> None:
372- # super().__init__(name, bases, namespace)
373- #
374- # # Find the event decorators.
375- # topic_prefix = construct_topic(cls) + "."
376- #
377- # my_func_decorators = cls._filter_event_decorators(topic_prefix)
378- #
379- # for decorator in my_func_decorators:
380- # given_event_class = decorator.given_event_cls
381- # # Keep things simple by only supporting given classes (not names).
382- # # TODO: Maybe support event name strings, maybe not....
383- # assert given_event_class is not None, "Event class not given"
384- # # Make sure event decorator has a Mutates class.
385- # assert issubclass(given_event_class, Mutates)
386- #
387- # # Decorator never has an original event class that has been subclassed.
388- # assert given_event_class not in given_event_subclasses
389- # if issubclass(given_event_class, DecoratedFuncCaller):
390- # # Decorator has a subclass of an original class.
391- # assert given_event_class in given_event_subclasses.values()
392- # event_subclass = given_event_class
393- # else:
394- # event_class_qual = given_event_class.__qualname__
395- # assert (
396- # "." not in event_class_qual
397- # ), "Nested cross-cutting classes aren't supported"
398- #
399- # # Get the global namespace for the event class.
400- # globalns = getattr(
401- # sys.modules.get(given_event_class.__module__, None),
402- # "__dict__",
403- # {},
404- # )
405- # # Check the given event class is in the globalns.
406- # assert given_event_class.__name__ in globalns
407- # assert globalns[given_event_class.__name__] is given_event_class
408- #
409- # # Define a subclass of the given event class.
410- # event_subclass = cls._define_decorator_func_caller(given_event_class)
411- # # Remember which subclass for given event class.
412- # given_event_subclasses[given_event_class] = event_subclass
413- #
414- # # Replace the given event class in its namespace.
415- # globalns[event_class_qual] = event_subclass
416- #
417- # # Register decorated func for event class / enduring object class.
418- # cross_cutting_decorated_funcs[(cls, event_subclass)] = (
419- # decorator.decorated_func
420- # )
421373
422374
423375class Slice (Perspective , metaclass = MetaSlice ):
0 commit comments