Exemplo n.º 1
0
SV *
srl_iterator_hash_key_sv(pTHX_ srl_iterator_t *iter)
{
    STRLEN length;
    const char *str = srl_iterator_hash_key(aTHX_ iter, &length);
    return sv_2mortal(newSVpvn(str, length));
}
Exemplo n.º 2
0
SRL_STATIC_INLINE void
srl_parse_hash_all(pTHX_ srl_path_t *path, int expr_idx, SV *route)
{
    srl_iterator_ptr iter = path->iter;
    srl_iterator_stack_ptr stack_ptr = srl_iterator_stack(aTHX_ iter);
    IV depth = srl_iterator_stack_depth(aTHX_ iter);
    U32 length = stack_ptr->length;
    const char *item = NULL;
    STRLEN item_len;
    U32 idx;

    SRL_PATH_TRACE("parse all items in hash of size=%d at depth=%"IVdf, length, depth);

    for (idx = 0; idx < length; idx += 2) {
        srl_iterator_until(aTHX_ iter, depth, idx);
        assert(srl_iterator_stack_index(aTHX_ iter) == idx);
        assert(srl_iterator_stack_depth(aTHX_ iter) == depth);

        item = srl_iterator_hash_key(aTHX_ iter, &item_len);
        SRL_PATH_TRACE("walk over item=%.*s in hash at depth=%"IVdf,
                       (int) item_len, item, srl_iterator_stack_depth(aTHX_ iter));

        srl_iterator_next(aTHX_ iter, 1);
        srl_parse_next_int(aTHX_ path, expr_idx + 1, route, idx);
    }
}