protobuf/ruby/ext/google/protobuf_c/message.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 RUBY_PROTOBUF_MESSAGE_H_
32 #define RUBY_PROTOBUF_MESSAGE_H_
33 
34 #include <ruby/ruby.h>
35 
36 #include "protobuf.h"
37 #include "ruby-upb.h"
38 
39 // Gets the underlying upb_msg* and upb_msgdef for the given Ruby message
40 // wrapper. Requires that |value| is indeed a message object.
41 const upb_msg *Message_Get(VALUE value, const upb_msgdef **m);
42 
43 // Like Message_Get(), but checks that the object is not frozen and returns a
44 // mutable pointer.
46 
47 // Returns the Arena object for this message.
48 VALUE Message_GetArena(VALUE value);
49 
50 // Converts |value| into a upb_msg value of the expected upb_msgdef type,
51 // raising an error if this is not possible. Used when assigning |value| to a
52 // field of another message, which means the message must be of a particular
53 // type.
54 //
55 // This will perform automatic conversions in some cases (for example, Time ->
56 // Google::Protobuf::Timestamp). If any new message is created, it will be
57 // created on |arena|, and any existing message will have its arena fused with
58 // |arena|.
59 const upb_msg* Message_GetUpbMessage(VALUE value, const upb_msgdef* m,
60  const char* name, upb_arena* arena);
61 
62 // Gets or constructs a Ruby wrapper object for the given message. The wrapper
63 // object will reference |arena| and ensure that it outlives this object.
64 VALUE Message_GetRubyWrapper(upb_msg* msg, const upb_msgdef* m, VALUE arena);
65 
66 // Gets the given field from this message.
67 VALUE Message_getfield(VALUE _self, const upb_fielddef* f);
68 
69 // Implements #inspect for this message, printing the text to |b|.
71  const upb_msgdef* m);
72 
73 // Returns a hash value for the given message.
75 
76 // Returns a deep copy of the given message.
78  upb_arena *arena);
79 
80 // Returns true if these two messages are equal.
81 bool Message_Equal(const upb_msg *m1, const upb_msg *m2, const upb_msgdef *m);
82 
83 // Checks that this Ruby object is a message, and raises an exception if not.
84 void Message_CheckClass(VALUE klass);
85 
86 // Returns a new Hash object containing the contents of this message.
87 VALUE Scalar_CreateHash(upb_msgval val, TypeInfo type_info);
88 
89 // Creates a message class or enum module for this descriptor, respectively.
91 VALUE build_module_from_enumdesc(VALUE _enumdesc);
92 
93 // Returns the Descriptor/EnumDescriptor for the given message class or enum
94 // module, respectively. Returns nil if this is not a message class or enum
95 // module.
97 
98 // Call at startup to register all types in this module.
99 void Message_register(VALUE protobuf);
100 
101 #endif // RUBY_PROTOBUF_MESSAGE_H_
upb_arena
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2252
Message_getfield
VALUE Message_getfield(VALUE _self, const upb_fielddef *f)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:294
StringBuilder
Definition: protobuf/ruby/ext/google/protobuf_c/protobuf.c:57
Message_deep_copy
upb_msg * Message_deep_copy(const upb_msg *msg, const upb_msgdef *m, upb_arena *arena)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:1240
build_class_from_descriptor
VALUE build_class_from_descriptor(VALUE descriptor)
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/message.c:699
seed
static const uint8_t seed[20]
Definition: dsa_test.cc:79
TypeInfo
Definition: protobuf/php/ext/google/protobuf/def.h:69
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
setup.name
name
Definition: setup.py:542
Message_Equal
bool Message_Equal(const upb_msg *m1, const upb_msg *m2, const upb_msgdef *m)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:667
Message_Hash
uint64_t Message_Hash(const upb_msg *msg, const upb_msgdef *m, uint64_t seed)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:708
Message_GetUpbMessage
const upb_msg * Message_GetUpbMessage(VALUE value, const upb_msgdef *m, const char *name, upb_arena *arena)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:1259
upb_msg
void upb_msg
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:548
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
Message_GetRubyWrapper
VALUE Message_GetRubyWrapper(upb_msg *msg, const upb_msgdef *m, VALUE arena)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:122
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
Message_register
void Message_register(VALUE protobuf)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:1322
ruby-upb.h
Message_Get
const upb_msg * Message_Get(VALUE value, const upb_msgdef **m)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:92
protobuf.h
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
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
Message_CheckClass
void Message_CheckClass(VALUE klass)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:115
Message_PrintMessage
void Message_PrintMessage(StringBuilder *b, const upb_msg *msg, const upb_msgdef *m)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:136
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
MessageOrEnum_GetDescriptor
VALUE MessageOrEnum_GetDescriptor(VALUE klass)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:46
value
const char * value
Definition: hpack_parser_table.cc:165
Message_GetMutable
upb_msg * Message_GetMutable(VALUE value, const upb_msgdef **m)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:98
upb_msgval
Definition: php-upb.h:4612
Scalar_CreateHash
VALUE Scalar_CreateHash(upb_msgval val, TypeInfo type_info)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:837
Message_GetArena
VALUE Message_GetArena(VALUE value)
Definition: protobuf/ruby/ext/google/protobuf_c/message.c:110
build_module_from_enumdesc
VALUE build_module_from_enumdesc(VALUE _enumdesc)
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/message.c:798
regress.m
m
Definition: regress/regress.py:25
klass
zend_class_entry * klass
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:810
descriptor
static const char descriptor[1336]
Definition: certs.upbdefs.c:16
upb_msgdef
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2962


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:25