[Groonga-commit] groonga/groonga at ac3049d [master] mrb: add accessor for ctx->impl->outbuf

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Jul 16 18:05:53 JST 2015


Kouhei Sutou	2015-07-16 18:05:53 +0900 (Thu, 16 Jul 2015)

  New Revision: ac3049db2288d7e79b56b6fa55089df496865aaa
  https://github.com/groonga/groonga/commit/ac3049db2288d7e79b56b6fa55089df496865aaa

  Message:
    mrb: add accessor for ctx->impl->outbuf
    
    It's only for internal use.

  Modified files:
    lib/mrb/mrb_ctx.c

  Modified: lib/mrb/mrb_ctx.c (+28 -0)
===================================================================
--- lib/mrb/mrb_ctx.c    2015-07-16 17:43:18 +0900 (1acabad)
+++ lib/mrb/mrb_ctx.c    2015-07-16 18:05:53 +0900 (eef70ca)
@@ -27,6 +27,7 @@
 
 #include "../grn_mrb.h"
 #include "mrb_ctx.h"
+#include "mrb_bulk.h"
 #include "mrb_converter.h"
 
 static mrb_value
@@ -222,6 +223,28 @@ ctx_set_command_version(mrb_state *mrb, mrb_value self)
 }
 
 static mrb_value
+ctx_get_output(mrb_state *mrb, mrb_value self)
+{
+  grn_ctx *ctx = (grn_ctx *)mrb->ud;
+
+  return grn_mrb_value_from_bulk(mrb, ctx->impl->outbuf);
+}
+
+static mrb_value
+ctx_set_output(mrb_state *mrb, mrb_value self)
+{
+  grn_ctx *ctx = (grn_ctx *)mrb->ud;
+  mrb_value mrb_value_;
+
+  mrb_get_args(mrb, "S", &mrb_value_);
+  GRN_TEXT_SET(ctx, ctx->impl->outbuf,
+               RSTRING_PTR(mrb_value_),
+               RSTRING_LEN(mrb_value_));
+
+  return mrb_value_;
+}
+
+static mrb_value
 ctx_get_database(mrb_state *mrb, mrb_value self)
 {
   grn_ctx *ctx = (grn_ctx *)mrb->ud;
@@ -736,6 +759,11 @@ grn_mrb_ctx_init(grn_ctx *ctx)
   mrb_define_method(mrb, klass, "command_version=",
                     ctx_set_command_version, MRB_ARGS_REQ(1));
 
+  mrb_define_method(mrb, klass, "output",
+                    ctx_get_output, MRB_ARGS_NONE());
+  mrb_define_method(mrb, klass, "output=",
+                    ctx_set_output, MRB_ARGS_REQ(1));
+
   mrb_define_method(mrb, klass, "database", ctx_get_database,
                     MRB_ARGS_NONE());
 }
-------------- next part --------------
HTML����������������������������...
Télécharger 



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