Skip to content

Commit

Permalink
Merge pull request #2 from segiddins/segiddins/support-running-on-tru…
Browse files Browse the repository at this point in the history
…ffleruby-jruby

Support running on truffleruby & jruby
  • Loading branch information
segiddins authored Apr 30, 2024
2 parents 70917d9 + 4abd7c2 commit cd0b0ec
Show file tree
Hide file tree
Showing 8 changed files with 270 additions and 70 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
- "3.2.3"
- "3.1.4"
- "3.0.5"
# - "truffleruby-23.1.2"
- "jruby-9.4.6.0"
allow_failures:
- ruby: "truffleruby-23.1.2"

steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Style/StringLiteralsInInterpolation:
Enabled: true
EnforcedStyle: double_quotes

Style/EndlessMethod:
EnforcedStyle: disallow # truffleruby does not support endless method syntax on 23.x

Layout/LineLength:
Max: 120

Expand Down
11 changes: 10 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ GEM
docile (1.4.0)
forwardable (1.3.3)
json (2.7.1)
json (2.7.1-java)
language_server-protocol (3.17.0.3)
minitest (5.22.3)
parallel (1.24.0)
Expand All @@ -65,6 +66,7 @@ GEM
racc
prettier_print (1.2.1)
racc (1.7.3)
racc (1.7.3-java)
rainbow (3.1.1)
rake (13.1.0)
regexp_parser (2.9.0)
Expand Down Expand Up @@ -118,8 +120,15 @@ GEM
unicode-display_width (2.5.0)

PLATFORMS
arm64-darwin-22
arm64-darwin-23
ruby
arm64-linux
java
universal-java-19
x64-mingw-ucrt
x64-mingw32
x86_64-darwin-22
x86_64-linux

DEPENDENCIES
minitest (~> 5.22)
Expand Down
13 changes: 12 additions & 1 deletion lib/protobug/binary_encoding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,18 @@ def encode_varint(value, outbuf)
break
end
end
out.pack("c*", buffer: outbuf)
pack(out, "c*", buffer: outbuf)
end

if RUBY_ENGINE == "truffleruby"
# see https://github.com/oracle/truffleruby/issues/3559
def pack(ary, format, buffer:)
buffer.concat ary.pack(format)
end
else
def pack(ary, format, buffer:)
ary.pack(format, buffer: buffer)
end
end

def encode_zigzag(size, value, outbuf)
Expand Down
Loading

0 comments on commit cd0b0ec

Please sign in to comment.