# Path: pyoptix/mixins/destroyable.py
# class DestroyableObject(object):
#     def __init__(self, native):
#         self._native = native
# 
#     @property
#     def _safe_native(self):
#         if not self._native.is_destroyed:
#             return self._native
#         else:
#             raise RuntimeError('Underlying OptiX object was destroyed before.')


from pyoptix.mixins.destroyable import DestroyableObject
        from pyoptix.variable import Variable


class ScopedObject(DestroyableObject):
    def __init__(self, native):
        DestroyableObject.__init__(self, native)
        self._variables = {}

    def __setitem__(self, key, value):

        variable_wrapper = self._safe_native.query_variable(key)
        declared = False

        if variable_wrapper is None:
            variable_wrapper = self._safe_native.declare_variable(key)
            declared = True

        try:
            optix_variable = Variable(variable_wrapper)
            optix_variable.value = value
            self._variables[key] = optix_variable

# Path: pyoptix/mixins/destroyable.py
# class DestroyableObject(object):
#     def __init__(self, native):
#         self._native = native
# 
#     @property
#     def _safe_native(self):
#         if not self._native.is_destroyed:
#             return self._native
#         else:
#             raise RuntimeError('Underlying OptiX object was destroyed before.')


# Path: pyoptix/mixins/scoped.py
from pyoptix.mixins.destroyable import DestroyableObject
        from pyoptix.variable import Variable



class ScopedObject(DestroyableObject):
    def __init__(self, native):
        DestroyableObject.__init__(self, native)
        self._variables = {}

    def __setitem__(self, key, value):

        variable_wrapper = self._safe_native.query_variable(key)
        declared = False

        if variable_wrapper is None:
            variable_wrapper = self._safe_native.declare_variable(key)
            declared = True

        try:
            optix_variable = Variable(variable_wrapper)
            optix_variable.value = value
            self._variables[key] = optix_variable

        except Exception as e: