Navigation Menu

Skip to content

Commit

Permalink
mrb: upgrade to the latest mruby
Browse files Browse the repository at this point in the history
You need to get mruby source by `git submodule update --init`.
  • Loading branch information
kou committed Jun 8, 2014
1 parent f53a728 commit 55be3d0
Show file tree
Hide file tree
Showing 261 changed files with 236 additions and 62,031 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -38,6 +38,10 @@
/data/scripts/groonga-httpd-restart
/vendor/nginx-*/objs
/vendor/mruby/parse.c
/vendor/mruby/mrblib.c
/vendor/mruby/mrbgems_init.c
/vendor/mruby/mruby-build.timestamp
/vendor/mruby-build/
/vendor/plugins/*/
/groonga.spec
/stamp-h1
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "vendor/mruby-source"]
path = vendor/mruby-source
url = https://github.com/mruby/mruby.git
3 changes: 1 addition & 2 deletions CMakeLists.txt
Expand Up @@ -442,15 +442,14 @@ else()
endif()

option(GRN_WITH_MRUBY "use mruby" OFF)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/mruby_version" MRUBY_VERSION)
if(GRN_WITH_MRUBY)
if(CMAKE_VERSION VERSION_LESS "2.8.8")
message(FATAL_ERROR
"Your CMake (${CMAKE_VERSION}) is old. "
"CMake 2.8.8 or later is required for mruby supported build")
endif()
set(MRUBY_INCLUDE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/mruby-${MRUBY_VERSION}/include")
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/mruby-source/include")
set(MRUBY_LIBS "$<TARGET_OBJECTS:mruby>")
else()
set(MRUBY_INCLUDE_DIRS "")
Expand Down
9 changes: 4 additions & 5 deletions configure.ac
Expand Up @@ -1342,13 +1342,12 @@ if test "x$enable_mruby" != "xyes"; then
fi
AC_MSG_RESULT($enable_mruby)

m4_define([mruby_version], m4_include(mruby_version))
MRUBY_VERSION=mruby_version
AC_SUBST(MRUBY_VERSION)

if test "$enable_mruby" = "yes"; then
if test "$ac_cv_ruby_available" != "yes"; then
AC_MSG_ERROR(--enable-ruby requires --with-ruby)
fi
AC_DEFINE(GRN_WITH_MRUBY, [1], [Define to 1 if mruby is enabled.])
MRUBY_CFLAGS="-I\$(top_srcdir)/vendor/mruby-${MRUBY_VERSION}/include"
MRUBY_CFLAGS="-I\$(top_srcdir)/vendor/mruby-source/include"
MRUBY_LIBS="\$(top_builddir)/vendor/mruby/libmruby.la"
else
MRUBY_CFLAGS=
Expand Down
2 changes: 0 additions & 2 deletions lib/ctx_impl_mrb.c
Expand Up @@ -20,7 +20,6 @@
#include "ctx_impl.h"

#include "mrb.h"
#include "mrb/mrb_kernel.h"
#include "mrb/mrb_ctx.h"
#include "mrb/mrb_bulk.h"
#include "mrb/mrb_obj.h"
Expand All @@ -41,7 +40,6 @@ grn_ctx_impl_mrb_init_bindings(grn_ctx *ctx)
mrb->ud = ctx;
ctx->impl->mrb.module = mrb_define_module(mrb, "Groonga");

grn_mrb_kernel_init(ctx);
grn_mrb_ctx_init(ctx);
grn_mrb_bulk_init(ctx);
grn_mrb_obj_init(ctx);
Expand Down
20 changes: 10 additions & 10 deletions lib/mrb.c
Expand Up @@ -110,7 +110,6 @@ grn_mrb_load(grn_ctx *ctx, const char *path)
{
grn_mrb_data *data = &(ctx->impl->mrb);
mrb_state *mrb = data->state;
int n;
FILE *file;
mrb_value result;
struct mrb_parser_state *parser;
Expand All @@ -131,10 +130,12 @@ grn_mrb_load(grn_ctx *ctx, const char *path)
parser = mrb_parse_file(mrb, file, NULL);
fclose(file);

n = mrb_generate_code(mrb, parser);
result = mrb_run(mrb,
mrb_proc_new(mrb, mrb->irep[n]),
mrb_top_self(mrb));
{
struct RProc *proc;
proc = mrb_generate_code(mrb, parser);
result = mrb_run(mrb, proc, mrb_top_self(mrb));
mrb_irep_decref(mrb, proc->body.irep);
}
mrb_parser_free(parser);

return result;
Expand All @@ -145,7 +146,6 @@ grn_mrb_eval(grn_ctx *ctx, const char *script, int script_length)
{
grn_mrb_data *data = &(ctx->impl->mrb);
mrb_state *mrb = data->state;
int n;
mrb_value result;
struct mrb_parser_state *parser;

Expand All @@ -157,16 +157,16 @@ grn_mrb_eval(grn_ctx *ctx, const char *script, int script_length)
script_length = strlen(script);
}
parser = mrb_parse_nstring(mrb, script, script_length, NULL);
n = mrb_generate_code(mrb, parser);
{
struct RProc *proc;
struct RClass *eval_context_class;
mrb_value eval_context;

proc = mrb_generate_code(mrb, parser);
eval_context_class = mrb_class_get_under(mrb, data->module, "EvalContext");
eval_context = mrb_obj_new(mrb, eval_context_class, 0, NULL);
result = mrb_run(mrb,
mrb_proc_new(mrb, mrb->irep[n]),
eval_context);
result = mrb_run(mrb, proc, eval_context);
mrb_irep_decref(mrb, proc->body.irep);
}
mrb_parser_free(parser);

Expand Down
6 changes: 2 additions & 4 deletions lib/mrb/mrb_expr.c
Expand Up @@ -49,8 +49,7 @@ mrb_grn_scan_info_new(mrb_state *mrb, scan_info *scan_info)
mrb_value mrb_scan_info;

mrb_scan_info = mrb_cptr_value(mrb, scan_info);
klass = mrb_class_ptr(mrb_const_get(mrb, mrb_obj_value(module),
mrb_intern(mrb, "ScanInfo")));
klass = mrb_class_get_under(mrb, module, "ScanInfo");
return mrb_obj_new(mrb, klass, 1, &mrb_scan_info);
}

Expand All @@ -63,8 +62,7 @@ mrb_grn_expr_code_new(mrb_state *mrb, grn_expr_code *code)
mrb_value mrb_code;

mrb_code = mrb_cptr_value(mrb, code);
klass = mrb_class_ptr(mrb_const_get(mrb, mrb_obj_value(module),
mrb_intern(mrb, "ExpressionCode")));
klass = mrb_class_get_under(mrb, module, "ExpressionCode");
return mrb_obj_new(mrb, klass, 1, &mrb_code);
}

Expand Down
50 changes: 0 additions & 50 deletions lib/mrb/mrb_kernel.c

This file was deleted.

34 changes: 0 additions & 34 deletions lib/mrb/mrb_kernel.h

This file was deleted.

25 changes: 0 additions & 25 deletions lib/mrb/scripts/kernel.rb

This file was deleted.

1 change: 0 additions & 1 deletion lib/mrb/scripts/sources.am
Expand Up @@ -2,5 +2,4 @@ RUBY_SCRIPT_FILES = \
eval_context.rb \
expression.rb \
index_info.rb \
kernel.rb \
scan_info.rb
2 changes: 0 additions & 2 deletions lib/mrb/sources.am
Expand Up @@ -15,8 +15,6 @@ libgrnmrb_la_SOURCES = \
mrb_fixed_size_column.h \
mrb_index_column.c \
mrb_index_column.h \
mrb_kernel.c \
mrb_kernel.h \
mrb_obj.c \
mrb_obj.h \
mrb_procedure.c \
Expand Down
1 change: 0 additions & 1 deletion mruby_version

This file was deleted.

4 changes: 3 additions & 1 deletion tools/travis-before-script.sh
Expand Up @@ -2,6 +2,8 @@

set -e

git submodule update --init --depth 1

case "${BUILD_TOOL}" in
autotools)
./autogen.sh
Expand All @@ -11,7 +13,7 @@ case "${BUILD_TOOL}" in
configure_args="${configure_args} --enable-debug"
#fi
if [ "$ENABLE_MRUBY" = "yes" ]; then
configure_args="${configure_args} --enable-mruby"
configure_args="${configure_args} --with-ruby --enable-mruby"
fi

./configure --with-ruby ${configure_args}
Expand Down
19 changes: 0 additions & 19 deletions vendor/mruby-eeac4be/.gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions vendor/mruby-eeac4be/.travis.yml

This file was deleted.

19 changes: 0 additions & 19 deletions vendor/mruby-eeac4be/AUTHORS

This file was deleted.

0 comments on commit 55be3d0

Please sign in to comment.