#include "message.h"
#include <inttypes.h>
#include <php.h>
#include <stdlib.h>
#include <Zend/zend_exceptions.h>
#include <Zend/zend_inheritance.h>
#include "arena.h"
#include "array.h"
#include "convert.h"
#include "def.h"
#include "map.h"
#include "php-upb.h"
#include "protobuf.h"
#include "wkt.inc"
Go to the source code of this file.
Classes | |
struct | Message |
Variables | |
zend_class_entry * | message_ce |
static zend_function_entry | Message_methods [] |
static zend_object_handlers | message_object_handlers |
static const char | TYPE_URL_PREFIX [] = "type.googleapis.com/" |
|
static |
Helper function to look up a field given a member name (as a string).
Definition at line 113 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Object handler for cloning an object in PHP. Called when PHP code does:
$msg2 = clone $msg;
Definition at line 410 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Object handler for comparing two message objects. Called whenever PHP code does:
$m1 == $m2
Definition at line 239 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
PHP class entry function to allocate and initialize a new Message object.
Definition at line 85 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Object handler to destroy a Message. This releases all resources associated with the message. Note that it is possible to access a destroyed object from PHP in rare cases.
Definition at line 101 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Definition at line 126 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Object handler for the get_properties event in PHP. This returns a HashTable of our internal properties. We don't support this, so we return NULL.
Definition at line 428 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Message_get_property_ptr_ptr()
Object handler for the get_property_ptr_ptr event in PHP. This returns a reference to our internal properties. We don't support this, so we return NULL.
Definition at line 397 of file protobuf/php/ext/google/protobuf/message.c.
void Message_GetPhpWrapper | ( | zval * | val, |
const Descriptor * | desc, | ||
upb_msg * | msg, | ||
zval * | arena | ||
) |
Definition at line 436 of file protobuf/php/ext/google/protobuf/message.c.
bool Message_GetUpbMessage | ( | zval * | val, |
const Descriptor * | desc, | ||
upb_arena * | arena, | ||
upb_msg ** | msg | ||
) |
Definition at line 456 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Definition at line 1111 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Object handler for testing whether a property exists. Called when PHP code does any of:
isset($message->foobar); property_exists($message->foobar);
Note that all properties of generated messages are private, so this should only be possible to invoke from generated code, which has accessors like this (if the field has presence):
public function hasOptionalInt32() { return isset($this->optional_int32); }
Definition at line 267 of file protobuf/php/ext/google/protobuf/message.c.
bool Message_InitFromPhp | ( | upb_msg * | msg, |
const upb_msgdef * | m, | ||
zval * | init, | ||
upb_arena * | arena | ||
) |
Helper method to handle the initialization of a message from a PHP value, eg.
$m = new TestMessage([ 'optional_int32' => -42, 'optional_bool' => true, 'optional_string' => 'a', 'optional_enum' => TestEnum::ONE, 'optional_message' => new Sub([ 'a' => 33 ]), 'repeated_int32' => [-42, -52], 'repeated_enum' => [TestEnum::ZERO, TestEnum::ONE], 'repeated_message' => [new Sub(['a' => 34]), new Sub(['a' => 35])], 'map_int32_int32' => [-62 => -62], 'map_int32_enum' => [1 => TestEnum::ONE], 'map_int32_message' => [1 => new Sub(['a' => 36])], ]);
The initializer must be an array.
Definition at line 504 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Definition at line 563 of file protobuf/php/ext/google/protobuf/message.c.
void Message_ModuleInit | ( | ) |
Called when the C extension is loaded to register all types.
Definition at line 1368 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Object handler for reading a property in PHP. Called when PHP code does:
$x = $message->foobar;
Note that all properties of generated messages are private, so this should only be possible to invoke from generated code, which has accessors like:
public function getOptionalInt32() { return $this->optional_int32; }
We lookup the field and return the scalar, RepeatedField, or MapField for this field.
Definition at line 339 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Definition at line 146 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Definition at line 1117 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Definition at line 63 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Object handler for unsetting a property. Called when PHP code calls:
unset($message->foobar);
Note that all properties of generated messages are private, so this should only be possible to invoke from generated code, which has accessors like this (if the field has presence):
public function clearOptionalInt32() { unset($this->optional_int32); }
Definition at line 302 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Object handler for writing a property in PHP. Called when PHP code does:
$message->foobar = $x;
Note that all properties of generated messages are private, so this should only be possible to invoke from generated code, which has accessors like:
public function setOptionalInt32($var) { GPBUtil::checkInt32($var); $this->optional_int32 = $var;
return $this; }
The C extension version of checkInt32() doesn't actually check anything, so we perform all checking and conversion in this function.
Definition at line 370 of file protobuf/php/ext/google/protobuf/message.c.
Definition at line 201 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | google_protobuf_Any | , |
is | |||
) |
Definition at line 1229 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | google_protobuf_Any | , |
pack | |||
) |
Definition at line 1192 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | google_protobuf_Any | , |
unpack | |||
) |
Definition at line 1145 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | google_protobuf_Timestamp | , |
fromDateTime | |||
) |
Definition at line 1250 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | google_protobuf_Timestamp | , |
toDateTime | |||
) |
Definition at line 1323 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | Message | , |
__construct | |||
) |
Message::__construct()
Constructor for Message.
array | Map of initial values ['k' = val] |
Definition at line 575 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | Message | , |
clear | |||
) |
Message::clear()
Clears all fields of this message.
Definition at line 628 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | Message | , |
discardUnknownFields | |||
) |
Message::discardUnknownFields()
Discards any unknown fields for this message or any submessages.
Definition at line 618 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | Message | , |
hasOneof | |||
) |
Message::hasOneof()
Returns the presence of the given oneof field, given a field number. Called from generated code methods such as:
public function hasDoubleValueOneof() { return $this->hasOneof(10); }
Definition at line 959 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | Message | , |
mergeFrom | |||
) |
Message::mergeFrom()
Merges from the given message, which must be of the same class as us.
object | Message to merge from. |
Definition at line 639 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | Message | , |
mergeFromJsonString | |||
) |
Message::mergeFromJsonString()
Merges the JSON data parsed from the given string.
string | Serialized JSON data. |
Definition at line 733 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | Message | , |
mergeFromString | |||
) |
Message::mergeFromString()
Merges from the given string.
string | Binary protobuf data to merge. |
Definition at line 679 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | Message | , |
readOneof | |||
) |
Message::readOneof()
Returns the contents of the given oneof field, given a field number. Called from generated code methods such as:
public function getDoubleValueOneof() { return $this->readOneof(10); }
Definition at line 992 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | Message | , |
readWrapperValue | |||
) |
Message::readWrapperValue()
Returns an unboxed value for the given field. This is called from generated methods for wrapper fields, eg.
public function getDoubleValueUnwrapped() { return $this->readWrapperValue("double_value"); }
Definition at line 827 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | Message | , |
serializeToJsonString | |||
) |
Message::serializeToJsonString()
Serializes this object to JSON.
Definition at line 773 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | Message | , |
serializeToString | |||
) |
Message::serializeToString()
Serializes this message instance to protobuf data.
Definition at line 708 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | Message | , |
whichOneof | |||
) |
Message::whichOneof()
Given a oneof name, returns the name of the field that is set for this oneof, or otherwise the empty string.
Definition at line 923 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | Message | , |
writeOneof | |||
) |
Message::writeOneof()
Sets the contents of the given oneof field, given a field number. Called from generated code methods such as:
public function setDoubleValueOneof($var) { GPBUtil::checkMessage($var, \Google\Protobuf\DoubleValue::class); $this->writeOneof(10, $var);
return $this; }
The C extension version of GPBUtil::check*() does nothing, so we perform all type checking and conversion here.
integer | The field number we are setting. |
object | The field value we want to set. |
Definition at line 1042 of file protobuf/php/ext/google/protobuf/message.c.
PHP_METHOD | ( | Message | , |
writeWrapperValue | |||
) |
Message::writeWrapperValue()
Sets the given wrapper field to the given unboxed value. This is called from generated methods for wrapper fields, eg.
public function setDoubleValueUnwrapped($var) { $this->writeWrapperValue("double_value", $var); return $this; }
Unwrapped | field value or null. |
Definition at line 873 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Definition at line 1124 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Definition at line 1140 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Definition at line 1130 of file protobuf/php/ext/google/protobuf/message.c.
bool ValueEq | ( | upb_msgval | val1, |
upb_msgval | val2, | ||
TypeInfo | type | ||
) |
Definition at line 172 of file protobuf/php/ext/google/protobuf/message.c.
zend_class_entry* message_ce |
Definition at line 60 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Definition at line 1089 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Definition at line 61 of file protobuf/php/ext/google/protobuf/message.c.
|
static |
Definition at line 1109 of file protobuf/php/ext/google/protobuf/message.c.