Changeset c3437d9 in mainline for uspace/app/bithenge/transform.c


Ignore:
Timestamp:
2012-08-04T03:51:15Z (12 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0ce0103
Parents:
e3f2765
Message:

Bithenge: add do{}while() transforms

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bithenge/transform.c

    re3f2765 rc3437d9  
    201201        for (int i = 0; i < out->num_params; i++)
    202202                bithenge_node_inc_ref(out->params[i]);
     203        bithenge_node_dec_ref(out->current_node);
    203204        out->current_node = scope->current_node;
    204205        if (out->current_node)
     
    474475bithenge_transform_t bithenge_known_length_transform = {
    475476        &known_length_ops, 1, 1
     477};
     478
     479static int nonzero_boolean_apply(bithenge_transform_t *self,
     480    bithenge_scope_t *scope, bithenge_node_t *in, bithenge_node_t **out)
     481{
     482        if (bithenge_node_type(in) != BITHENGE_NODE_INTEGER)
     483                return EINVAL;
     484        bool value = bithenge_integer_node_value(in) != 0;
     485        return bithenge_new_boolean_node(out, value);
     486}
     487
     488static const bithenge_transform_ops_t nonzero_boolean_ops = {
     489        .apply = nonzero_boolean_apply,
     490        .destroy = transform_indestructible,
     491};
     492
     493/** A transform that converts integers to booleans, true if nonzero. */
     494bithenge_transform_t bithenge_nonzero_boolean_transform = {
     495        &nonzero_boolean_ops, 1, 0
    476496};
    477497
     
    602622        {"ascii", &bithenge_ascii_transform},
    603623        {"known_length", &bithenge_known_length_transform},
     624        {"nonzero_boolean", &bithenge_nonzero_boolean_transform},
    604625        {"uint8", &bithenge_uint8_transform},
    605626        {"uint16le", &bithenge_uint16le_transform},
Note: See TracChangeset for help on using the changeset viewer.