From 51c5ff889ccd3836c25f40baafb350f92c9ee103 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Tue, 25 Oct 2016 17:27:05 -0700 Subject: Fix pure php implementation for 32-bit machine. (#2282) --- php/src/Google/Protobuf/Internal/Type.php | 175 ------------------------------ 1 file changed, 175 deletions(-) delete mode 100644 php/src/Google/Protobuf/Internal/Type.php (limited to 'php/src/Google/Protobuf/Internal/Type.php') diff --git a/php/src/Google/Protobuf/Internal/Type.php b/php/src/Google/Protobuf/Internal/Type.php deleted file mode 100644 index 088f0e0c..00000000 --- a/php/src/Google/Protobuf/Internal/Type.php +++ /dev/null @@ -1,175 +0,0 @@ -low = $value & 0xFFFFFFFF; - if (PHP_INT_SIZE === 8) { - $this->high = ($value >> 32) & 0xFFFFFFFF; - } - } - - // Return 0 for unsigned integers and 1 for signed integers. - protected function sign() - { - trigger_error("Not implemented", E_ERROR); - } - - public function leftShift($count) - { - if ($count > 63) { - $this->low = 0; - $this->high = 0; - return; - } - if ($count > 32) { - $this->high = $this->low; - $this->low = 0; - $count -= 32; - } - $mask = (1 << $count) - 1; - $this->high = (($this->high << $count) & 0xFFFFFFFF) | - (($this->low >> (32 - $count)) & $mask); - $this->low = ($this->low << $count) & 0xFFFFFFFF; - - $this->high &= 0xFFFFFFFF; - $this->low &= 0xFFFFFFFF; - return $this; - } - - public function rightShift($count) - { - $sign = (($this->high & 0x80000000) >> 31) & $this->sign(); - if ($count > 63) { - $this->low = -$sign; - $this->high = -$sign; - return; - } - if ($count > 32) { - $this->low = $this->high; - $this->high = -$sign; - $count -= 32; - } - $this->low = (($this->low >> $count) & 0xFFFFFFFF) | - (($this->high << (32 - $count)) & 0xFFFFFFFF); - $this->high = (($this->high >> $count) | (-$sign << $count)); - - $this->high &= 0xFFFFFFFF; - $this->low &= 0xFFFFFFFF; - - return $this; - } - - public function bitOr($var) - { - $this->high |= $var->high; - $this->low |= $var->low; - return $this; - } - - public function bitXor($var) - { - $this->high ^= $var->high; - $this->low ^= $var->low; - return $this; - } - - public function bitAnd($var) - { - $this->high &= $var->high; - $this->low &= $var->low; - return $this; - } - - // Even: all zero; Odd: all one. - public function oddMask() - { - $low = (-($this->low & 1)) & 0xFFFFFFFF; - $high = $low; - return UInt64::newValue($high, $low); - } - - public function toInteger() - { - if (PHP_INT_SIZE === 8) { - return ($this->high << 32) | $this->low; - } else { - return $this->low; - } - } - - public function copy() - { - return static::newValue($this->high, $this->low); - } -} - -class Uint64 extends GPBInteger -{ - - public static function newValue($high, $low) - { - $uint64 = new Uint64(0); - $uint64->high = $high; - $uint64->low = $low; - return $uint64; - } - - protected function sign() - { - return 0; - } -} - -class Int64 extends GPBInteger -{ - - public static function newValue($high, $low) - { - $int64 = new Int64(0); - $int64->high = $high; - $int64->low = $low; - return $int64; - } - - protected function sign() - { - return 1; - } -} -- cgit v1.2.3