[Groonga-commit] groonga/groonga at 16026f3 [master] build scan_info through ruby method

Back to archive index

wanabe null+****@clear*****
Sun Oct 6 00:39:25 JST 2013


wanabe	2013-10-06 00:39:25 +0900 (Sun, 06 Oct 2013)

  New Revision: 16026f38c445256cdaba3a928454d5b7e2cedfc0
  https://github.com/groonga/groonga/commit/16026f38c445256cdaba3a928454d5b7e2cedfc0

  Merged d127d05: Merge pull request #110 from wanabe/scaninfo-with-mruby

  Message:
    build scan_info through ruby method

  Modified files:
    lib/ctx_impl_mrb.c
    lib/mrb/mrb_expr.c

  Modified: lib/ctx_impl_mrb.c (+1 -0)
===================================================================
--- lib/ctx_impl_mrb.c    2013-10-05 09:36:59 +0900 (424d037)
+++ lib/ctx_impl_mrb.c    2013-10-06 00:39:25 +0900 (a18a94c)
@@ -28,6 +28,7 @@ grn_ctx_impl_mrb_init_bindings(grn_ctx *ctx)
 {
   mrb_state *mrb = ctx->impl->mrb.state;
 
+  mrb->ud = ctx;
   ctx->impl->mrb.module = mrb_define_module(mrb, "Groonga");
 
   grn_mrb_obj_init(ctx);

  Modified: lib/mrb/mrb_expr.c (+31 -1)
===================================================================
--- lib/mrb/mrb_expr.c    2013-10-05 09:36:59 +0900 (c01ae13)
+++ lib/mrb/mrb_expr.c    2013-10-06 00:39:25 +0900 (2d6a64d)
@@ -22,6 +22,7 @@
 #include <mruby.h>
 #include <mruby/class.h>
 
+#include "../expr.h"
 #include "../util.h"
 #include "mrb_expr.h"
 
@@ -319,17 +320,46 @@ scan_info_build(grn_ctx *ctx, grn_obj *expr, int *n,
   return sis;
 }
 
+static mrb_value
+mrb_grn_expr_build(mrb_state *mrb, mrb_value self)
+{
+  int *n;
+  uint32_t size;
+  scan_info ***psis;
+  grn_operator op;
+  grn_obj *expr;
+  grn_ctx *ctx = (grn_ctx *)mrb->ud;
+  mrb_value mexpr, mpsis, mn;
+
+  mrb_get_args(mrb, "oooii", &mexpr, &mpsis, &mn, &op, &size);
+  expr = mrb_cptr(mexpr);
+  psis = mrb_cptr(mpsis);
+  n = mrb_cptr(mn);
+
+  *psis = scan_info_build(ctx, expr, n, op, size);
+  return self;
+}
+
 void
 grn_mrb_expr_init(grn_ctx *ctx)
 {
   mrb_state *mrb = ctx->impl->mrb.state;
   struct RClass *module = ctx->impl->mrb.module;
+
+  mrb_define_class_method(mrb, module, "build", mrb_grn_expr_build, MRB_ARGS_REQ(4));
 }
 
 scan_info **
 grn_mrb_scan_info_build(grn_ctx *ctx, grn_obj *expr, int *n,
                         grn_operator op, uint32_t size)
 {
-  return scan_info_build(ctx, expr, n, op, size);
+  scan_info **sis;
+  mrb_state *mrb = ctx->impl->mrb.state;
+
+  mrb_funcall(mrb, mrb_obj_value(ctx->impl->mrb.module), "build", 5,
+              mrb_cptr_value(mrb, expr), mrb_cptr_value(mrb, &sis),
+              mrb_cptr_value(mrb, n), mrb_fixnum_value(op),
+              mrb_fixnum_value(size));
+  return sis;
 }
 #endif
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index