summaryrefslogtreecommitdiff
path: root/vendor/bundle/ruby/3.4.0/gems/google-protobuf-4.35.1-arm64-darwin/lib/google/protobuf.rb
diff options
context:
space:
mode:
authorBen Sanders <ben@sanders.life>2026-08-02 09:49:25 -0400
committerBen Sanders <ben@sanders.life>2026-08-02 09:49:25 -0400
commitb41479c91e6685511c1f8ba8586106b322073b62 (patch)
treec9f1345999d754ae0a533849966427e792d9e68d /vendor/bundle/ruby/3.4.0/gems/google-protobuf-4.35.1-arm64-darwin/lib/google/protobuf.rb
parentcfaceeb9a6d1295f5754be211858155cd309acc2 (diff)
added statscounter code
Diffstat (limited to 'vendor/bundle/ruby/3.4.0/gems/google-protobuf-4.35.1-arm64-darwin/lib/google/protobuf.rb')
-rwxr-xr-xvendor/bundle/ruby/3.4.0/gems/google-protobuf-4.35.1-arm64-darwin/lib/google/protobuf.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/vendor/bundle/ruby/3.4.0/gems/google-protobuf-4.35.1-arm64-darwin/lib/google/protobuf.rb b/vendor/bundle/ruby/3.4.0/gems/google-protobuf-4.35.1-arm64-darwin/lib/google/protobuf.rb
new file mode 100755
index 0000000..fdfa9b6
--- /dev/null
+++ b/vendor/bundle/ruby/3.4.0/gems/google-protobuf-4.35.1-arm64-darwin/lib/google/protobuf.rb
@@ -0,0 +1,61 @@
+# Protocol Buffers - Google's data interchange format
+# Copyright 2008 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 mixins before we hook them into the java & c code
+require 'google/protobuf/message_exts'
+require 'google/protobuf/internal/object_cache'
+
+# We define these before requiring the platform-specific modules.
+# That way the module init can grab references to these.
+module Google
+ module Protobuf
+ class Error < StandardError; end
+ class ParseError < Error; end
+ class TypeError < ::TypeError; end
+
+ PREFER_FFI = case ENV['PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION']
+ when nil, "", /^native$/i
+ false
+ when /^ffi$/i
+ true
+ else
+ warn "Unexpected value `#{ENV['PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION']}` for environment variable `PROTOCOL_BUFFERS_RUBY_IMPLEMENTATION`. Should be either \"FFI\", \"NATIVE\"."
+ false
+ end
+
+ def self.encode(msg, options = {})
+ msg.to_proto(options)
+ end
+
+ def self.encode_json(msg, options = {})
+ msg.to_json(options)
+ end
+
+ def self.decode(klass, proto, options = {})
+ klass.decode(proto, options)
+ end
+
+ def self.decode_json(klass, json, options = {})
+ klass.decode_json(json, options)
+ end
+
+ IMPLEMENTATION = if PREFER_FFI
+ begin
+ require 'google/protobuf_ffi'
+ :FFI
+ rescue LoadError
+ warn "Caught exception `#{$!.message}` while loading FFI implementation of google/protobuf."
+ warn "Falling back to native implementation."
+ require 'google/protobuf_native'
+ :NATIVE
+ end
+ else
+ require 'google/protobuf_native'
+ :NATIVE
+ end
+ end
+end