Skip to content

Commit

Permalink
Update ruby ffi for upb_Message_DiscardUnknown.
Browse files Browse the repository at this point in the history
#test-continuous

PiperOrigin-RevId: 713376224
  • Loading branch information
honglooker authored and copybara-github committed Jan 8, 2025
1 parent 9e2d1b9 commit af9292b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ruby/lib/google/protobuf/ffi/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class FFI
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
Expand Down
3 changes: 2 additions & 1 deletion ruby/lib/google/protobuf_ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def self.deep_copy(object)
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
Expand Down

0 comments on commit af9292b

Please sign in to comment.