# Path: ggame/mathapp.py
# class _MathDynamic(metaclass=ABCMeta):
#     def __init__(self):
#         self._dynamic = False  # not switched on, by default!
# 
#     def destroy(self):
#         """
#         Destroy resources, if any and remove from global lists.
#         """
#         MathApp.removeDynamic(self)
# 
#     def step(self):
#         """
#         Override in your child class to perform periodic processing.
#         """
# 
#     def eval(self, val):
#         """
#         Evaluate a potentially callable argument, returning a callable
#         object.
# 
#         :param val: A simple variable or function reference that can be
#             called without any argument, returning a value.
#         :rtype: function
#         :returns: A function that can be called to retrieve the value passed
#             in.
#         """
#         if callable(val):
#             self._setDynamic()  # dynamically defined .. must step
#             return val
#         return lambda: val
# 
#     def _setDynamic(self):
#         MathApp.addDynamic(self)
#         self._dynamic = True


from abc import ABCMeta, abstractmethod
from ggame.mathapp import _MathDynamic
"""
These MathApp-based digital logic classes are experimental.
"""



# decorator for _getvalue or any value handler that may experience recursion
def _recursiontrap(handler):
    def trapmagic(self):
        """
        An attempt to catch recursion (doesn't work).
        """
        if not self.ingetvalue:
            self.ingetvalue = True
            self.lastget = handler(self)
            self.ingetvalue = False
            return self.lastget
        self.ingetvalue = False
        return self.lastget

    return trapmagic



# Path: ggame/mathapp.py
# class _MathDynamic(metaclass=ABCMeta):
#     def __init__(self):
#         self._dynamic = False  # not switched on, by default!
# 
#     def destroy(self):
#         """
#         Destroy resources, if any and remove from global lists.
#         """
#         MathApp.removeDynamic(self)
# 
#     def step(self):
#         """
#         Override in your child class to perform periodic processing.
#         """
# 
#     def eval(self, val):
#         """
#         Evaluate a potentially callable argument, returning a callable
#         object.
# 
#         :param val: A simple variable or function reference that can be
#             called without any argument, returning a value.
#         :rtype: function
#         :returns: A function that can be called to retrieve the value passed
#             in.
#         """
#         if callable(val):
#             self._setDynamic()  # dynamically defined .. must step
#             return val
#         return lambda: val
# 
#     def _setDynamic(self):
#         MathApp.addDynamic(self)
#         self._dynamic = True


# Path: ggame/logic.py
from abc import ABCMeta, abstractmethod
from ggame.mathapp import _MathDynamic

"""
These MathApp-based digital logic classes are experimental.
"""



# decorator for _getvalue or any value handler that may experience recursion
def _recursiontrap(handler):
    def trapmagic(self):
        """
        An attempt to catch recursion (doesn't work).
        """
        if not self.ingetvalue:
            self.ingetvalue = True
            self.lastget = handler(self)
            self.ingetvalue = False
            return self.lastget
        self.ingetvalue = False
        return self.lastget

    return trapmagic



class _BoolDevice(_MathDynamic, metaclass=ABCMeta):