Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ ruby-head, '3.0', '2.7', '2.6' ]
ruby: [ '3.2', '3.3', '3.4' ]
env:
W_ERROR: '1'
steps:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
mkmf.log
/ext/mruby_engine/mruby-mpdecimal/tests/runtest
/ext/mruby_engine/mruby-mpdecimal/tests/runtest_alloc

mruby_config.rb.lock
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "ext/mruby_engine/mruby"]
path = ext/mruby_engine/mruby
url = https://github.com/Shopify/mruby.git
branch = mruby-engine-submodule
branch = jringer/better-distinguish-clang
2 changes: 1 addition & 1 deletion ext/mruby_engine/dlmalloc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define MRUBY_ENGINE_DLMALLOC_CONFIG_H

#define ONLY_MSPACES 1
#define HAVE_MREMAP 0

//#define FOOTERS 1

#include "host.h"
Expand Down
1 change: 1 addition & 0 deletions ext/mruby_engine/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <libunwind.h>
#include <ruby.h>
#include <ruby/thread.h>
#include <stdio.h>
#include <string.h>

const intptr_t ME_HOST_NIL = Qnil;
Expand Down
2 changes: 1 addition & 1 deletion ext/mruby_engine/mruby
4 changes: 2 additions & 2 deletions ext/mruby_engine/mruby-mpdecimal/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ LD = gcc
AR = ar

MPD_WARN = -Wall -W -Wno-unknown-pragmas -std=c99 -pedantic
MPD_CONFIG = -DCONFIG_64 -DASM
MPD_CONFIG = -DCONFIG_64 -DANSI -DHAVE_UINT128_T

CONFIGURE_CFLAGS = -ggdb -Wall -W -Wno-unknown-pragmas -std=c99 -pedantic -DCONFIG_64 -DASM -O0
CONFIGURE_CFLAGS = -ggdb -Wall -W -Wno-unknown-pragmas -std=c99 -pedantic -DCONFIG_64 -DANSI -DHAVE_UINT128_T -O0
CFLAGS ?= $(CONFIGURE_CFLAGS)

HEADERS = $(wildcard $(SRCDIR)/*.h)
Expand Down
8 changes: 4 additions & 4 deletions ext/mruby_engine/mruby_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ me_host_exception_t me_mruby_engine_get_exception(struct me_mruby_engine *self)

intptr_t host_backtrace = me_host_backtrace_new();
mrb_value backtrace = mrb_exc_backtrace(self->state, exception);
mrb_int backtrace_len = mrb_ary_len(self->state, backtrace);
mrb_int backtrace_len = RARRAY_LEN(backtrace);
for (int i = 0; i < backtrace_len; ++i) {
mrb_value location = mrb_ary_entry(backtrace, i);
me_host_backtrace_push_location(host_backtrace, mrb_string_value_cstr(self->state, &location));
Expand Down Expand Up @@ -139,7 +139,7 @@ static void mruby_engine_check_stack(
static void mruby_engine_code_fetch_hook(
struct mrb_state* mrb,
struct mrb_irep *irep,
mrb_code *pc,
const mrb_code *pc,
mrb_value *regs)
{
(void)irep;
Expand Down Expand Up @@ -244,7 +244,7 @@ static struct RProc *generate_code(

if (parser_state->nerr > 0) {
*err = me_host_syntax_error_new(
parser_state->filename,
mrb_sym_name(state, parser_state->filename_sym),
parser_state->error_buffer[0].lineno,
parser_state->error_buffer[0].column,
parser_state->error_buffer[0].message);
Expand Down Expand Up @@ -393,7 +393,7 @@ struct me_iseq *me_iseq_new(
int status = mrb_dump_irep(
engine->state,
irep,
DUMP_DEBUG_INFO | DUMP_ENDIAN_NAT,
DUMP_DEBUG_INFO,
&irep_data,
&irep_data_size);
if (status == MRB_DUMP_OK) {
Expand Down
15 changes: 7 additions & 8 deletions ext/mruby_engine/value_guest.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static me_host_value_t me_value_to_host_r(
return ME_HOST_NIL;
}

for (mrb_int i = 0, f = mrb_ary_len(self->state, value); i < f; ++i) {
for (mrb_int i = 0, f = RARRAY_LEN(value); i < f; ++i) {
me_host_value_t element = me_value_to_host_r(
self, mrb_ary_ref(self->state, value, i), depth + 1, err);
if (err->type != ME_VALUE_NO_ERR) {
Expand All @@ -69,20 +69,19 @@ static me_host_value_t me_value_to_host_r(
return ME_HOST_NIL;
}

struct kh_ht *kh = mrb_hash_tbl(self->state, value);
for (int i = kh_begin(kh), f = kh_end(kh); i < f; ++i) {
if (!kh_exist(kh, i)) {
continue;
}
mrb_value keys = mrb_hash_keys(self->state, value);
mrb_int len = RARRAY_LEN(keys);
for (mrb_int i = 0; i < len; ++i) {
mrb_value k = mrb_ary_ref(self->state, keys, i);

me_host_value_t key = me_value_to_host_r(
self, kh_key(kh, i), depth + 1, err);
self, k, depth + 1, err);
if (err->type != ME_VALUE_NO_ERR) {
return ME_HOST_NIL;
}

me_host_value_t element = me_value_to_host_r(
self, kh_value(kh, i).v, depth + 1, err);
self, mrb_hash_get(self->state, value, k), depth + 1, err);
if (err->type != ME_VALUE_NO_ERR) {
return ME_HOST_NIL;
}
Expand Down
5 changes: 3 additions & 2 deletions mruby_engine.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ Gem::Specification.new do |spec|

spec.add_runtime_dependency "getoptlong"

spec.add_development_dependency "bigdecimal"
spec.add_development_dependency "bundler", ">= 1.6"
spec.add_development_dependency "rake", "~> 10.4"
spec.add_development_dependency "rake-compiler", "~> 0.9"
spec.add_development_dependency "rake", ">= 12.0"
spec.add_development_dependency "rake-compiler", ">= 1.2"
spec.add_development_dependency "rspec", "~> 3.3"
spec.add_development_dependency "pry", "~> 0.10.0"
spec.add_development_dependency "pry-byebug", "~> 3.1"
Expand Down
6 changes: 3 additions & 3 deletions spec/arbitrary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "securerandom"

module Arbitrary
refine Fixnum.singleton_class do
refine Integer.singleton_class do
def arbitrary
lambda do
if SecureRandom.random_number(2) == 0
Expand All @@ -21,7 +21,7 @@ def arbitrary_natural
end
end

refine Fixnum do
refine Integer do
def shrink
if self > 2 || -2 < self
[(self / 2).to_i]
Expand All @@ -34,7 +34,7 @@ def shrink
refine BigDecimal.singleton_class do
def arbitrary
lambda do
"#{Fixnum.arbitrary.call}.#{Fixnum.arbitrary_natural.call}".to_d
"#{Integer.arbitrary.call}.#{Integer.arbitrary_natural.call}".to_d
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/mruby_engine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def bar
SOURCE
}.to raise_error(MRubyEngine::EngineRuntimeError) do |e|
expect(e.guest_backtrace).to eq([
"backtrace.rb:2:in Object.foo",
"backtrace.rb:6:in Object.bar",
"backtrace.rb:2:in foo",
"backtrace.rb:6:in bar",
"backtrace.rb:9",
])
end
Expand Down Expand Up @@ -183,7 +183,7 @@ def self.to_s
raise(TransmogrificationError, "This looks bad.")
SOURCE
}.to raise_error(MRubyEngine::EngineRuntimeError) do |e|
expect(e.type).to match(/\A#<Class:0x\h+>\z/)
expect(e.type).to match(/\ATransmogrificationError\z|\A#<Class:0x\h+>\z/)
end
end

Expand Down Expand Up @@ -508,7 +508,7 @@ def initialize
it "returns the compiled instructions" do
iseq = MRubyEngine::InstructionSequence.new([["sample.rb", "@foo = 42"]])
expect(iseq.data.encoding).to eq(Encoding::ASCII_8BIT)
expect(iseq.data.size).to eq(127)
expect(iseq.data.size).to eq(136)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/time_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def eval_test(source)

it "raises if time is out of range" do
eval_test(<<-SOURCE)
assert_raises(ArgumentError, "9.3674872249306e+17 out of Time range") do
assert_raises(ArgumentError, "9.367487224930632e+17 out of Time range") do
Time.at(0xd00000000000000)
end
SOURCE
Expand Down
Loading