nullable reference inlining

This commit is contained in:
AF 2022-07-26 03:03:53 +03:00
parent 455ffd6063
commit 2f2ba19f2c
2 changed files with 9 additions and 4 deletions

View File

@ -19,7 +19,8 @@ class BinaryTree(RecursiveMentionable, Generic[TreeKeyType]):
def __init__(
self,
treel: NullableReference['BinaryTree[TreeKeyType]'], treer: NullableReference['BinaryTree[TreeKeyType]'],
treel: NullableReference['BinaryTree[TreeKeyType]'],
treer: NullableReference['BinaryTree[TreeKeyType]'],
key: HashPoint[TreeKeyType]
):
assert isinstance(treel, NullableReference)

View File

@ -1,6 +1,7 @@
from typing import Generic, Iterable, TypeVar
from typing import Generic, Iterable, Optional, TypeVar
from rainbowadn.core import *
from rainbowadn.inlining import *
from .notnull import *
from .null import *
from .nullable import *
@ -69,11 +70,14 @@ class NullableReference(RecursiveMentionable, Generic[Referenced]):
return await self.hashpoint().resolve()
class NullableReferenceFactory(RainbowFactory[NullableReference[Referenced]], Generic[Referenced]):
class NullableReferenceFactory(Inlining[NullableReference[Referenced]], Generic[Referenced]):
def __init__(self, factory: RainbowFactory[Referenced]):
assert isinstance(factory, RainbowFactory)
self.factory = factory
def size(self) -> Optional[int]:
return HashPoint.HASH_LENGTH
def from_bytes(self, source: bytes, resolver: HashResolver) -> NullableReference[Referenced]:
assert isinstance(source, bytes)
assert isinstance(resolver, HashResolver)
@ -81,7 +85,7 @@ class NullableReferenceFactory(RainbowFactory[NullableReference[Referenced]], Ge
return NullableReference(Null(), self.factory)
else:
return NullableReference.of(
ResolverOrigin(self.factory, source, resolver).hash_point()
ResolverMetaOrigin(resolver).hash_point(self.factory, source)
)
def loose(self) -> RainbowFactory[NullableReference[Referenced]]: