Update ruby ffi for upb_Message_DiscardUnknown.

#test-continuous

PiperOrigin-RevId: 713376224
pull/19925/head
Hong Shin 2 months ago committed by Copybara-Service
parent 9e2d1b9ad3
commit af9292b7ec
  1. 2
      ruby/lib/google/protobuf/ffi/message.rb
  2. 3
      ruby/lib/google/protobuf_ffi.rb

@ -22,7 +22,7 @@ module Google
attach_function :decode_message, :upb_Decode, [:binary_string, :size_t, :Message, MiniTable.by_ref, :ExtensionRegistry, :int, Internal::Arena], DecodeStatus
attach_function :get_mutable_message, :upb_Message_Mutable, [:Message, FieldDescriptor, Internal::Arena], MutableMessageValue.by_value
attach_function :get_message_which_oneof, :upb_Message_WhichOneofByDef, [:Message, OneofDescriptor], FieldDescriptor
attach_function :message_discard_unknown, :upb_Message_DiscardUnknown, [:Message, Descriptor, :int], :bool
attach_function :message_discard_unknown, :upb_Message_DiscardUnknown, [:Message, Descriptor, :DefPool, :int], :bool
attach_function :message_next, :upb_Message_Next, [:Message, Descriptor, :DefPool, :FieldDefPointer, MessageValue.by_ref, :pointer], :bool
attach_function :message_freeze, :upb_Message_Freeze, [:Message, MiniTable.by_ref], :void
attach_function :message_frozen?, :upb_Message_IsFrozen, [:Message], :bool

@ -42,7 +42,8 @@ module Google
def self.discard_unknown(message)
raise FrozenError if message.frozen?
raise ArgumentError.new "Expected message, got #{message.class} instead." if message.instance_variable_get(:@msg).nil?
unless Google::Protobuf::FFI.message_discard_unknown(message.instance_variable_get(:@msg), message.class.descriptor, 128)
pool_def = message.class.descriptor.instance_variable_get(:@descriptor_pool).descriptor_pool
unless Google::Protobuf::FFI.message_discard_unknown(message.instance_variable_get(:@msg), message.class.descriptor, pool_def, 128)
raise RuntimeError.new "Messages nested too deeply."
end
nil

Loading…
Cancel
Save