Sha256: fa048985c06b1a9e7deb0753c8e0ce34c1c800aa08af82cdbfef3c87ee85525b

Contents?: true

Size: 1.81 KB

Versions: 80

Compression:

Stored size: 1.81 KB

Contents

# Protocol Buffers - Google's data interchange format
# Copyright 2023 Google Inc.  All rights reserved.
#
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd

require 'ffi-compiler/loader'
require 'google/protobuf/ffi/ffi'
require 'google/protobuf/ffi/internal/type_safety'
require 'google/protobuf/ffi/internal/pointer_helper'
require 'google/protobuf/ffi/internal/arena'
require 'google/protobuf/ffi/internal/convert'
require 'google/protobuf/ffi/descriptor'
require 'google/protobuf/ffi/enum_descriptor'
require 'google/protobuf/ffi/field_descriptor'
require 'google/protobuf/ffi/oneof_descriptor'
require 'google/protobuf/ffi/descriptor_pool'
require 'google/protobuf/ffi/file_descriptor'
require 'google/protobuf/ffi/map'
require 'google/protobuf/ffi/object_cache'
require 'google/protobuf/ffi/repeated_field'
require 'google/protobuf/ffi/message'
require 'google/protobuf/descriptor_dsl'

module Google
  module Protobuf
    def self.deep_copy(object)
      case object
      when RepeatedField
        RepeatedField.send(:deep_copy, object)
      when Google::Protobuf::Map
        Google::Protobuf::Map.deep_copy(object)
      when Google::Protobuf::MessageExts
        object.class.send(:deep_copy, object.instance_variable_get(:@msg))
      else
        raise NotImplementedError
      end
    end

    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)
        raise RuntimeError.new "Messages nested too deeply."
      end
      nil
    end
  end
end

Version data entries

80 entries across 80 versions & 1 rubygems

Version Path
google-protobuf-3.25.5-java lib/google/protobuf_ffi.rb
google-protobuf-3.25.5 lib/google/protobuf_ffi.rb
google-protobuf-3.25.5-x86_64-linux lib/google/protobuf_ffi.rb
google-protobuf-3.25.5-x86_64-darwin lib/google/protobuf_ffi.rb
google-protobuf-3.25.5-x86-mingw32 lib/google/protobuf_ffi.rb
google-protobuf-3.25.5-x86-linux lib/google/protobuf_ffi.rb
google-protobuf-3.25.5-x64-mingw32 lib/google/protobuf_ffi.rb
google-protobuf-3.25.5-x64-mingw-ucrt lib/google/protobuf_ffi.rb
google-protobuf-3.25.5-arm64-darwin lib/google/protobuf_ffi.rb
google-protobuf-3.25.5-aarch64-linux lib/google/protobuf_ffi.rb
google-protobuf-3.25.4-java lib/google/protobuf_ffi.rb
google-protobuf-3.25.4 lib/google/protobuf_ffi.rb
google-protobuf-3.25.4-x86_64-linux lib/google/protobuf_ffi.rb
google-protobuf-3.25.4-x86_64-darwin lib/google/protobuf_ffi.rb
google-protobuf-3.25.4-x86-mingw32 lib/google/protobuf_ffi.rb
google-protobuf-3.25.4-x86-linux lib/google/protobuf_ffi.rb
google-protobuf-3.25.4-x64-mingw32 lib/google/protobuf_ffi.rb
google-protobuf-3.25.4-x64-mingw-ucrt lib/google/protobuf_ffi.rb
google-protobuf-3.25.4-arm64-darwin lib/google/protobuf_ffi.rb
google-protobuf-3.25.4-aarch64-linux lib/google/protobuf_ffi.rb