1 // Protocol Buffers - Google's data interchange format 2 // Copyright 2008 Google Inc. All rights reserved. 3 // 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file or at 6 // https://developers.google.com/open-source/licenses/bsd 7 8 #ifndef RUBY_PROTOBUF_REPEATED_FIELD_H_ 9 #define RUBY_PROTOBUF_REPEATED_FIELD_H_ 10 11 #include "protobuf.h" 12 #include "ruby-upb.h" 13 14 // Returns a frozen sentinel Ruby wrapper object for an empty upb_Array of the 15 // type specified by the field. Creates one if it doesn't exist. 16 VALUE RepeatedField_EmptyFrozen(const upb_FieldDef* f); 17 18 // Returns a Ruby wrapper object for the given upb_Array, which will be created 19 // if one does not exist already. 20 VALUE RepeatedField_GetRubyWrapper(const upb_Array* msg, TypeInfo type_info, 21 VALUE arena); 22 23 // Gets the underlying upb_Array for this Ruby RepeatedField object, which must 24 // have a type that matches |f|. If this is not a repeated field or the type 25 // doesn't match, raises an exception. 26 const upb_Array* RepeatedField_GetUpbArray(VALUE value, const upb_FieldDef* f, 27 upb_Arena* arena); 28 29 // Implements #inspect for this repeated field by appending its contents to |b|. 30 void RepeatedField_Inspect(StringBuilder* b, const upb_Array* array, 31 TypeInfo info); 32 33 // Returns a deep copy of this RepeatedField object. 34 VALUE RepeatedField_deep_copy(VALUE obj); 35 36 // Ruby class of Google::Protobuf::RepeatedField. 37 extern VALUE cRepeatedField; 38 39 // Call at startup to register all types in this module. 40 void RepeatedField_register(VALUE module); 41 42 // Recursively freeze RepeatedField. 43 VALUE RepeatedField_freeze(VALUE _self); 44 45 #endif // RUBY_PROTOBUF_REPEATED_FIELD_H_ 46