Sha256: 143612e33a4becff14f77e85fc37c09b37854eedbbe67d35590b4ea4406daaaf

Contents?: true

Size: 1.43 KB

Versions: 50

Compression:

Stored size: 1.43 KB

Contents

# Protocol Buffers - Google's data interchange format
# Copyright 2022 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

module Google
  module Protobuf
    class FFI
      # FileDescriptor
      attach_function :file_def_name,   :upb_FileDef_Name,   [:FileDef], :string
      attach_function :file_def_pool,   :upb_FileDef_Pool,   [:FileDef], :DefPool
      attach_function :file_options,    :FileDescriptor_serialized_options,  [:FileDef, :pointer, Internal::Arena], :pointer
    end

    class FileDescriptor
      attr :descriptor_pool, :file_def

      def initialize(file_def, descriptor_pool)
        @descriptor_pool = descriptor_pool
        @file_def = file_def
      end

      def to_s
        inspect
      end

      def inspect
        "#{self.class.name}: #{name}"
      end

      def name
        Google::Protobuf::FFI.file_def_name(@file_def)
      end

      def options
        @options ||= begin
          size_ptr = ::FFI::MemoryPointer.new(:size_t, 1)
          temporary_arena = Google::Protobuf::FFI.create_arena
          buffer = Google::Protobuf::FFI.file_options(@file_def, size_ptr, temporary_arena)
          Google::Protobuf::FileOptions.decode(buffer.read_string_length(size_ptr.read(:size_t)).force_encoding("ASCII-8BIT").freeze).freeze
        end
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
google-protobuf-4.26.1-java lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.1 lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.1-x86_64-linux lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.1-x86_64-darwin lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.1-x86-mingw32 lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.1-x86-linux lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.1-x64-mingw32 lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.1-x64-mingw-ucrt lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.1-arm64-darwin lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.1-aarch64-linux lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.0-java lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.0 lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.0-x86_64-linux lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.0-x86_64-darwin lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.0-x86-mingw32 lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.0-x86-linux lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.0-x64-mingw32 lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.0-x64-mingw-ucrt lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.0-arm64-darwin lib/google/protobuf/ffi/file_descriptor.rb
google-protobuf-4.26.0-aarch64-linux lib/google/protobuf/ffi/file_descriptor.rb