Add Null primitive data type

This commit is contained in:
Dan 2017-12-27 13:05:59 +01:00
parent 8a8e863598
commit ba0af8043c
4 changed files with 36 additions and 2 deletions

View File

@ -125,6 +125,7 @@ class Compiler:
f.write("\n 0xbc799737: \"core.BoolFalse\",") f.write("\n 0xbc799737: \"core.BoolFalse\",")
f.write("\n 0x997275b5: \"core.BoolTrue\",") f.write("\n 0x997275b5: \"core.BoolTrue\",")
f.write("\n 0x56730bcc: \"core.Null\",")
f.write("\n 0x1cb5c415: \"core.Vector\",") f.write("\n 0x1cb5c415: \"core.Vector\",")
f.write("\n 0x73f1f8dc: \"core.MsgContainer\",") f.write("\n 0x73f1f8dc: \"core.MsgContainer\",")
f.write("\n 0xae500895: \"core.FutureSalts\",") f.write("\n 0xae500895: \"core.FutureSalts\",")

View File

@ -7,7 +7,7 @@
---types--- ---types---
// boolFalse#bc799737 = Bool; // Parsed manually // boolFalse#bc799737 = Bool; // Parsed manually
// boolTrue#997275b5 = Bool; // parsed manually // boolTrue#997275b5 = Bool; // Parsed manually
// true#3fedd339 = True; // Not used // true#3fedd339 = True; // Not used
@ -15,7 +15,7 @@
// error#c4b9f9bb code:int text:string = Error; // Not used // error#c4b9f9bb code:int text:string = Error; // Not used
// null#56730bcc = Null; // Not used // null#56730bcc = Null; // Parsed manually
inputPeerEmpty#7f3b18ea = InputPeer; inputPeerEmpty#7f3b18ea = InputPeer;
inputPeerSelf#7da07ec9 = InputPeer; inputPeerSelf#7da07ec9 = InputPeer;

View File

@ -20,5 +20,6 @@ from .bool import Bool, BoolTrue, BoolFalse
from .bytes import Bytes from .bytes import Bytes
from .double import Double from .double import Double
from .int import Int, Long, Int128, Int256 from .int import Int, Long, Int128, Int256
from .null import Null
from .string import String from .string import String
from .vector import Vector from .vector import Vector

View File

@ -0,0 +1,32 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017 Dan Tès <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from io import BytesIO
from ..object import Object
class Null(Object):
ID = 0x56730bcc
@staticmethod
def read(b: BytesIO, *args) -> None:
return None
def __new__(cls) -> bytes:
return int.to_bytes(cls.ID, 4, "little")