implemented bitfield and void types

This commit is contained in:
əlemi 2021-12-10 13:38:24 +01:00
parent e642debd15
commit d21a37c28b
2 changed files with 14 additions and 0 deletions

View file

@ -20,6 +20,17 @@ class Type(object):
"""Check if this type exists in this context""" """Check if this type exists in this context"""
return True return True
class VoidType(Type):
pytype : type = type(None)
def write(self, v:None, buffer:io.BytesIO, ctx:object=None):
pass
def read(self, buffer:io.BytesIO, ctx:object=None) -> None:
return None
Void = VoidType()
class UnimplementedDataType(Type): class UnimplementedDataType(Type):
pytype : type = bytes pytype : type = bytes

View file

@ -72,6 +72,7 @@ TYPE_MAP = {
"position": Ref('Position'), "position": Ref('Position'),
"entityMetadataItem": Ref('EntityMetadataItem'), "entityMetadataItem": Ref('EntityMetadataItem'),
"entityMetadata": Ref('EntityMetadata'), "entityMetadata": Ref('EntityMetadata'),
"void": Ref('Void'),
} }
HINT_MAP = { HINT_MAP = {
@ -138,6 +139,8 @@ def mctype(slot_type:Any) -> Ref:
v["default"] if "default" in v and v['default'] != 'void' else None, v["default"] if "default" in v and v['default'] != 'void' else None,
) )
# return SwitchType(mctype(v)) # TODO # return SwitchType(mctype(v)) # TODO
elif t == "bitfield":
return Ref('Int')
# elif t == "mapper": # ???? # elif t == "mapper": # ????
# return TrailingData # return TrailingData
else: else: