protobuf/php/ext/google/protobuf/def.h
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #ifndef PHP_PROTOBUF_DEF_H_
32 #define PHP_PROTOBUF_DEF_H_
33 
34 #include <php.h>
35 
36 #include "php-upb.h"
37 
38 // Initializes the Def module, which defines all of the descriptor classes.
39 void Def_ModuleInit();
40 
41 // Creates a new DescriptorPool to wrap the given symtab, which must not be
42 // NULL.
44 
46 
47 // Returns true if the global descriptor pool already has the given filename.
48 bool DescriptorPool_HasFile(const char *filename);
49 
50 // Adds the given descriptor with the given filename to the global pool.
51 void DescriptorPool_AddDescriptor(const char *filename, const char *data, int size);
52 
53 typedef struct Descriptor {
54  zend_object std;
55  const upb_msgdef *msgdef;
56  zend_class_entry *class_entry;
57 } Descriptor;
58 
59 // Gets or creates a Descriptor* for the given class entry, upb_msgdef, or
60 // upb_fielddef. The returned Descriptor* will live for the entire request,
61 // so no ref is necessary to keep it alive. The caller does *not* own a ref
62 // on the returned object.
63 Descriptor* Descriptor_GetFromClassEntry(zend_class_entry *ce);
66 
67 // Packages up a upb_fieldtype_t with a Descriptor, since many functions need
68 // both.
69 typedef struct {
71  const Descriptor *desc; // When type == UPB_TYPE_MESSAGE.
72 } TypeInfo;
73 
74 static inline TypeInfo TypeInfo_Get(const upb_fielddef *f) {
76  return ret;
77 }
78 
80  TypeInfo ret = {type};
81  return ret;
82 }
83 
84 static inline bool TypeInfo_Eq(TypeInfo a, TypeInfo b) {
85  if (a.type != b.type) return false;
86  if (a.type == UPB_TYPE_MESSAGE && a.desc != b.desc) return false;
87  return true;
88 }
89 
90 #endif // PHP_PROTOBUF_DEF_H_
Descriptor_GetFromFieldDef
Descriptor * Descriptor_GetFromFieldDef(const upb_fielddef *f)
Definition: protobuf/php/ext/google/protobuf/def.c:590
filename
const char * filename
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:135
Descriptor::class_entry
zend_class_entry * class_entry
Definition: protobuf/php/ext/google/protobuf/def.h:56
DescriptorPool_AddDescriptor
void DescriptorPool_AddDescriptor(const char *filename, const char *data, int size)
Definition: protobuf/php/ext/google/protobuf/def.c:954
upb_fieldtype_t
upb_fieldtype_t
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:472
Descriptor::msgdef
const upb_msgdef * msgdef
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:122
TypeInfo_Get
static TypeInfo TypeInfo_Get(const upb_fielddef *f)
Definition: protobuf/php/ext/google/protobuf/def.h:74
TypeInfo
Definition: protobuf/php/ext/google/protobuf/def.h:69
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
Descriptor_GetFromClassEntry
Descriptor * Descriptor_GetFromClassEntry(zend_class_entry *ce)
Definition: protobuf/php/ext/google/protobuf/def.c:578
Descriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:121
Descriptor::std
zend_object std
Definition: protobuf/php/ext/google/protobuf/def.h:54
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
TypeInfo_FromType
static TypeInfo TypeInfo_FromType(upb_fieldtype_t type)
Definition: protobuf/php/ext/google/protobuf/def.h:79
upb_symtab
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3018
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
upb_fielddef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2934
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
TypeInfo_Eq
static bool TypeInfo_Eq(TypeInfo a, TypeInfo b)
Definition: protobuf/php/ext/google/protobuf/def.h:84
symtab
upb_symtab * symtab
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:774
DescriptorPool_GetSymbolTable
upb_symtab * DescriptorPool_GetSymbolTable()
Definition: protobuf/php/ext/google/protobuf/def.c:755
DescriptorPool_CreateWithSymbolTable
void DescriptorPool_CreateWithSymbolTable(zval *zv, upb_symtab *symtab)
Definition: protobuf/php/ext/google/protobuf/def.c:746
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
Descriptor
struct Descriptor Descriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:836
UPB_TYPE_MESSAGE
@ UPB_TYPE_MESSAGE
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:483
TypeInfo::type
upb_fieldtype_t type
Definition: protobuf/php/ext/google/protobuf/def.h:70
php-upb.h
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
regress.m
m
Definition: regress/regress.py:25
Descriptor_GetFromMessageDef
Descriptor * Descriptor_GetFromMessageDef(const upb_msgdef *m)
Definition: protobuf/php/ext/google/protobuf/def.c:584
DescriptorPool_HasFile
bool DescriptorPool_HasFile(const char *filename)
Definition: protobuf/php/ext/google/protobuf/def.c:949
TypeInfo::desc
const Descriptor * desc
Definition: protobuf/php/ext/google/protobuf/def.h:71
upb_msgdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2962
Def_ModuleInit
void Def_ModuleInit()
Definition: protobuf/php/ext/google/protobuf/def.c:1051
upb_fielddef_type
upb_fieldtype_t upb_fielddef_type(const upb_fielddef *f)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:3304


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:09