function longlongWriteAndRead($v) { $w = new AMQPWriter(); $w->write_longlong($v); $r = new AMQPReader($w->getvalue()); $this->assertEqual($r->read_longlong(), $v); }
/** * serialize the 'properties' attribute (a dictionary) into the * raw bytes making up a set of property flags and a property * list, suitable for putting into a content frame header. */ public function serialize_properties() { $shift = 15; $flag_bits = 0; $flags = array(); $raw_bytes = new AMQPWriter(); foreach ($this->prop_types as $key => $proptype) { if (array_key_exists($key, $this->properties)) { $val = $this->properties[$key]; } else { $val = NULL; } if ($val != NULL) { if ($shift == 0) { array_push($flags, $flag_bits); $flag_bits = 0; $shift = 15; } $flag_bits |= 1 << $shift; if ($proptype != "bit") { call_user_func(array($raw_bytes, "write_" . $proptype), $val); } } $shift -= 1; } array_push($flags, $flag_bits); $result = new AMQPWriter(); foreach ($flags as $flag_bits) { $result->write_short($flag_bits); } $result->write($raw_bytes->getvalue()); return $result->getvalue(); }
/** * serialize the 'properties' attribute (a dictionary) into the * raw bytes making up a set of property flags and a property * list, suitable for putting into a content frame header. */ public function serialize_properties() { $shift = 15; $flag_bits = 0; $flags = array(); $raw_bytes = new AMQPWriter(); foreach ($this->prop_types as $key => $proptype) { if (isset($this->properties[$key])) { $val = $this->properties[$key]; } else { $val = NULL; } if ($val != NULL) { if ($shift == 0) { $flags[] = $flag_bits; $flag_bits = 0; $shift = 15; } $flag_bits |= 1 << $shift; if ($proptype != "bit") { $raw_bytes->{'write_' . $proptype}($val); } } $shift -= 1; } $flags[] = $flag_bits; $result = new AMQPWriter(); foreach ($flags as $flag_bits) { $result->write_short($flag_bits); } $result->write($raw_bytes->getvalue()); return $result->getvalue(); }