[Groonga-commit] groonga/groonga at aed2767 [master] Export grn_obj_cast

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Sep 26 12:43:53 JST 2015


Kouhei Sutou	2015-09-26 12:43:53 +0900 (Sat, 26 Sep 2015)

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

  Message:
    Export grn_obj_cast

  Modified files:
    include/groonga/obj.h
    lib/db.c
    lib/grn_db.h

  Modified: include/groonga/obj.h (+5 -0)
===================================================================
--- include/groonga/obj.h    2015-09-25 18:18:42 +0900 (9ff892c)
+++ include/groonga/obj.h    2015-09-26 12:43:53 +0900 (f1053d2)
@@ -31,6 +31,11 @@ GRN_API grn_bool grn_obj_is_selector_proc(grn_ctx *ctx, grn_obj *obj);
 GRN_API grn_bool grn_obj_is_selector_only_proc(grn_ctx *ctx, grn_obj *obj);
 GRN_API grn_bool grn_obj_is_scorer_proc(grn_ctx *ctx, grn_obj *obj);
 
+GRN_API grn_rc grn_obj_cast(grn_ctx *ctx,
+                            grn_obj *src,
+                            grn_obj *dest,
+                            grn_bool add_record_if_not_exist);
+
 #ifdef __cplusplus
 }
 #endif

  Modified: lib/db.c (+11 -6)
===================================================================
--- lib/db.c    2015-09-25 18:18:42 +0900 (c3c9ee0)
+++ lib/db.c    2015-09-26 12:43:53 +0900 (5edcfdc)
@@ -5551,8 +5551,11 @@ grn_obj_is_persistent(grn_ctx *ctx, grn_obj *obj)
         p_key = &key;\
       }\
       if (GRN_BULK_VSIZE(p_key)) {\
-        id = addp ? grn_table_add_by_key(ctx, table, p_key, NULL)\
-                  : grn_table_get_by_key(ctx, table, p_key);\
+        if (add_record_if_not_exist) {\
+          id = grn_table_add_by_key(ctx, table, p_key, NULL);\
+        } else {\
+          id = grn_table_get_by_key(ctx, table, p_key);\
+        }\
         if (id) {\
           GRN_RECORD_SET(ctx, dest, id);\
         } else {\
@@ -5579,7 +5582,8 @@ grn_obj_is_persistent(grn_ctx *ctx, grn_obj *obj)
 } while (0)
 
 inline static grn_rc
-grn_obj_cast_bool(grn_ctx *ctx, grn_obj *src, grn_obj *dest, grn_bool addp)
+grn_obj_cast_bool(grn_ctx *ctx, grn_obj *src, grn_obj *dest,
+                  grn_bool add_record_if_not_exist)
 {
   grn_rc rc = GRN_SUCCESS;
 
@@ -5698,7 +5702,7 @@ grn_obj_cast_bool(grn_ctx *ctx, grn_obj *src, grn_obj *dest, grn_bool addp)
     GRN_VOID_INIT(&buf);\
     rc = grn_aton(ctx, str, str_end, &rest, &buf);\
     if (!rc) {\
-      rc = grn_obj_cast(ctx, &buf, dest, addp);\
+      rc = grn_obj_cast(ctx, &buf, dest, add_record_if_not_exist);\
     }\
     GRN_OBJ_FIN(ctx, &buf);\
   } else {\
@@ -5727,12 +5731,13 @@ grn_obj_cast_bool(grn_ctx *ctx, grn_obj *src, grn_obj *dest, grn_bool addp)
   GRN_FLOAT_SET(ctx, dest, value);
 
 grn_rc
-grn_obj_cast(grn_ctx *ctx, grn_obj *src, grn_obj *dest, grn_bool addp)
+grn_obj_cast(grn_ctx *ctx, grn_obj *src, grn_obj *dest,
+             grn_bool add_record_if_not_exist)
 {
   grn_rc rc = GRN_SUCCESS;
   switch (src->header.domain) {
   case GRN_DB_BOOL :
-    rc = grn_obj_cast_bool(ctx, src, dest, addp);
+    rc = grn_obj_cast_bool(ctx, src, dest, add_record_if_not_exist);
     break;
   case GRN_DB_INT8 :
     NUM2DEST(GRN_INT8_VALUE, grn_text_itoa, NUM2BOOL, NUM2TIME, NUM2FLOAT);

  Modified: lib/grn_db.h (+0 -1)
===================================================================
--- lib/grn_db.h    2015-09-25 18:18:42 +0900 (5b534b2)
+++ lib/grn_db.h    2015-09-26 12:43:53 +0900 (57dae16)
@@ -316,7 +316,6 @@ struct _grn_expr {
 };
 
 grn_rc grn_expr_parser_close(grn_ctx *ctx);
-GRN_API grn_rc grn_obj_cast(grn_ctx *ctx, grn_obj *src, grn_obj *dest, grn_bool addp);
 
 /**
  * grn_table_open:
-------------- next part --------------
HTML����������������������������...
Download 



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