Skip to content

Commit

Permalink
prop/nf: Propagate PROP_REQ_MOVE_CHILD thru nodefilter
Browse files Browse the repository at this point in the history
  • Loading branch information
andoma committed Oct 2, 2012
1 parent 8b9bb17 commit e394dea
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/prop/prop_core.c
Expand Up @@ -1181,7 +1181,7 @@ prop_build_notify_child2(prop_sub_t *s, prop_t *p, prop_t *extra,
/**
*
*/
static void
void
prop_notify_child2(prop_t *child, prop_t *parent, prop_t *sibling,
prop_event_t event, prop_sub_t *skipme, int flags)
{
Expand Down Expand Up @@ -1892,6 +1892,9 @@ prop_move0(prop_t *p, prop_t *before, prop_sub_t *skipme)

assert(p != before);

if(before && p->hp_parent != before->hp_parent)
return;

if(TAILQ_NEXT(p, hp_parent_link) != before) {

parent = p->hp_parent;
Expand Down
3 changes: 3 additions & 0 deletions src/prop/prop_i.h
Expand Up @@ -336,6 +336,9 @@ int prop_destroy0(prop_t *p);

void prop_unsubscribe0(prop_sub_t *s);

void prop_notify_child2(prop_t *child, prop_t *parent, prop_t *sibling,
prop_event_t event, prop_sub_t *skipme, int flags);

void prop_notify_childv(prop_vec_t *childv, prop_t *parent, prop_event_t event,
prop_sub_t *skipme, prop_t *p2);

Expand Down
34 changes: 32 additions & 2 deletions src/prop/prop_nodefilter.c
Expand Up @@ -1058,10 +1058,10 @@ prop_nf_src_cb(void *opaque, prop_event_t event, ...)
prop_have_more_childs0(nf->dst);
else
nf->pending_have_more = 1;

break;

case PROP_WANT_MORE_CHILDS:
case PROP_REQ_MOVE_CHILD:
break;

default:
Expand Down Expand Up @@ -1093,14 +1093,38 @@ nf_translate_del_multi(prop_nf_t *nf, prop_vec_t *in)
}



/**
*
*/
static void
nf_translate_req_move_child(prop_nf_t *nf, prop_t *p, prop_t *before)
{
if(nf->sortkey[0] || nf->sortkey[1] || nf->sortkey[2] || nf->sortkey[3])
return;

if(nf->filter != NULL)
return;

prop_nf_pred_t *pnp;
LIST_FOREACH(pnp, &nf->preds, pnp_link)
if(pnp->pnp_enabled)
return;

p = p->hp_originator;
before = before ? before->hp_originator : NULL;
prop_notify_child2(p, nf->src, before, PROP_REQ_MOVE_CHILD, nf->srcsub, 0);
}


/**
*
*/
static void
prop_nf_dst_cb(void *opaque, prop_event_t event, ...)
{
prop_nf_t *nf = opaque;

prop_t *p1, *p2;
va_list ap;
va_start(ap, event);

Expand All @@ -1113,6 +1137,12 @@ prop_nf_dst_cb(void *opaque, prop_event_t event, ...)
abort();
break;

case PROP_REQ_MOVE_CHILD:
p1 = va_arg(ap, prop_t *);
p2 = va_arg(ap, prop_t *);
nf_translate_req_move_child(nf, p1, p2);
break;

case PROP_WANT_MORE_CHILDS:
if(nf->srcsub != NULL)
prop_want_more_childs0(nf->srcsub);
Expand Down

0 comments on commit e394dea

Please sign in to comment.