def stateful(cls):
"""
class decorator for creating stateful class
"""
func = cls()
get_signature(func)
module_name = func.__module__.split(".")[-2]
props = {}
for name, prop in getattr(cls, 'properties', {}).items():
if isinstance(prop, SvRxBaseTypeP):
props[name] = prop.get_prop()
else:
props[name] = prop
props.update(func.properties)
class InnerStateful(cls, Stateful):
category = module_name
inputs_template = func.inputs_template.copy()
outputs_template = func.outputs_template.copy()
properties = props.copy()
parameters = func.parameters.copy()
returns = func.returns.copy()
func_new = InnerStateful()
class_factory(func_new)
InnerStateful.node_cls = func_new.cls
NodeStateful.add_cls(cls.bl_idname, InnerStateful)
return InnerStateful
评论列表
文章目录