Created
December 19, 2015 00:53
-
-
Save agoose77/745996fa1477fd9b7e07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hive | |
from hive.classes import Method | |
from ..event import BindEvent | |
class BindCls: | |
def __init__(self): | |
pass | |
def build_bind_class(i, ex, args): | |
pass | |
class InstantiatorCls: | |
def __init__(self): | |
self._bind_hive_bases = [] | |
self._bind_hive = None | |
self._sockets = [] | |
self._plugins = [] | |
self.last_created = None | |
def register_bind_cls(self, bind_cls): | |
if self._bind_hive is not None: | |
raise ValueError("Bind class is already registered") | |
self._bind_hive_bases.append(bind_cls) | |
def register_plugin(self, identifier, plugin): | |
self._plugins.append((identifier, plugin)) | |
def register_socket(self, identifier, socket): | |
self._sockets.append((identifier, socket)) | |
def instantiate(self): | |
if self._bind_hive is None: | |
self._bind_hive = hive.hive("BindClass", builder=build_bind_class, cls=BindCls, | |
bases=tuple(self._bind_hive_bases)) | |
self.last_created = self._bind_hive() | |
def declare_instantiator(meta_args): | |
meta_args.cls_import_path = hive.parameter("str") | |
def build_instantiator(cls, i, ex, args, meta_args): | |
i.do_instantiate = hive.triggerable(cls.instantiate) | |
ex.create = hive.entry(i.do_instantiate) | |
ex.register_bind_cls = hive.plugin(cls.register_bind_cls, identifier=("bind", "register_class")) | |
Instantiator = hive.dyna_hive("Instantiator", builder=build_instantiator, declarator=declare_instantiator, | |
cls=InstantiatorCls, bases=(BindEvent,)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment