746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
|
# File 'ext/json_scanner/json_scanner.c', line 746
static VALUE selector_m_inspect(VALUE self)
{
scan_ctx *ctx;
VALUE res;
TypedData_Get_Struct(self, scan_ctx, &selector_type, ctx);
res = rb_sprintf("#<%" PRIsVALUE " [", rb_class_name(CLASS_OF(self)));
for (int i = 0; ctx->paths && i < ctx->paths_len; i++)
{
rb_str_buf_cat_ascii(res, "[");
for (int j = 0; j < ctx->paths[i].len; j++)
{
switch (ctx->paths[i].elems[j].type)
{
case MATCHER_KEY:
rb_str_catf(res, "'%.*s'", (int)ctx->paths[i].elems[j].value.key.len, ctx->paths[i].elems[j].value.key.val);
break;
case MATCHER_INDEX:
rb_str_catf(res, "%ld", ctx->paths[i].elems[j].value.index);
break;
case MATCHER_INDEX_RANGE:
rb_str_catf(res, "(%ld..%ld)", ctx->paths[i].elems[j].value.range.start, ctx->paths[i].elems[j].value.range.end == LONG_MAX ? -1L : ctx->paths[i].elems[j].value.range.end);
break;
case MATCHER_ANY_KEY:
rb_str_buf_cat_ascii(res, "('*'..'*')");
break;
}
if (j < ctx->paths[i].len - 1)
rb_str_buf_cat_ascii(res, ", ");
}
rb_str_buf_cat_ascii(res, "]");
if (i < ctx->paths_len - 1)
rb_str_buf_cat_ascii(res, ", ");
}
rb_str_buf_cat_ascii(res, "]>");
return res;
}
|