Navigation Menu

Skip to content

Commit

Permalink
Extract table key inspection code
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 19, 2013
1 parent ae673a7 commit 0fe069d
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions lib/util.c
Expand Up @@ -500,22 +500,11 @@ grn_table_type_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
}

static grn_rc
grn_table_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
grn_table_key_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
{
grn_hash *cols;
grn_id range_id;
grn_obj *range;

GRN_TEXT_PUTS(ctx, buf, "#<table:");
grn_table_type_inspect(ctx, buf, obj);
GRN_TEXT_PUTS(ctx, buf, " ");

grn_inspect_name(ctx, buf, obj);

if (obj->header.type != GRN_TABLE_NO_KEY) {
grn_obj *domain;
grn_id domain_id;
GRN_TEXT_PUTS(ctx, buf, " key:");
GRN_TEXT_PUTS(ctx, buf, "key:");
domain_id = obj->header.domain;
domain = grn_ctx_at(ctx, domain_id);
if (domain) {
Expand All @@ -526,6 +515,26 @@ grn_table_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
} else {
GRN_TEXT_PUTS(ctx, buf, "(nil)");
}

return GRN_SUCCESS;
}

static grn_rc
grn_table_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
{
grn_hash *cols;
grn_id range_id;
grn_obj *range;

GRN_TEXT_PUTS(ctx, buf, "#<table:");
grn_table_type_inspect(ctx, buf, obj);
GRN_TEXT_PUTS(ctx, buf, " ");

grn_inspect_name(ctx, buf, obj);

if (obj->header.type != GRN_TABLE_NO_KEY) {
GRN_TEXT_PUTS(ctx, buf, " ");
grn_table_key_inspect(ctx, buf, obj);
}

GRN_TEXT_PUTS(ctx, buf, " value:");
Expand Down

0 comments on commit 0fe069d

Please sign in to comment.