Changeset 03cad47 in mainline


Ignore:
Timestamp:
2012-07-28T00:20:31Z (12 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4056ad0
Parents:
6e34bd0
Message:

Bithenge: make num_params more dynamic

Location:
uspace/app/bithenge
Files:
3 edited

Legend:

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

    r6e34bd0 r03cad47  
    271271        .prefix_length = param_wrapper_prefix_length,
    272272        .destroy = param_wrapper_destroy,
    273         .num_params = 0, /* This transform should not be used inside another
    274                             param_wrapper or explicitly in a script, so this
    275                             number doesn't matter. */
    276273};
    277274
     
    295292
    296293        rc = bithenge_init_transform(param_wrapper_as_transform(self),
    297             &param_wrapper_ops);
     294            &param_wrapper_ops, 0);
    298295        if (rc != EOK)
    299296                goto error;
  • uspace/app/bithenge/transform.c

    r6e34bd0 r03cad47  
    4444 * @param[out] self Transform to initialize.
    4545 * @param[in] ops Operations provided by the transform.
     46 * @param num_params The number of parameters required. If this is nonzero, the
     47 * transform will get its own context with parameters, probably provided by a
     48 * param_wrapper. If this is zero, the existing outer context will be used with
     49 * whatever parameters it has.
    4650 * @return EOK or an error code from errno.h. */
    4751int bithenge_init_transform(bithenge_transform_t *self,
    48     const bithenge_transform_ops_t *ops)
     52    const bithenge_transform_ops_t *ops, int num_params)
    4953{
    5054        assert(ops);
     
    5357        self->ops = ops;
    5458        self->refs = 1;
     59        self->num_params = num_params;
    5560        return EOK;
    5661}
     
    99104/** The ASCII text transform. */
    100105bithenge_transform_t bithenge_ascii_transform = {
    101         &ascii_ops, 1
     106        &ascii_ops, 1, 0
    102107};
    103108
     
    159164                                                                               \
    160165        bithenge_transform_t bithenge_##NAME##_transform = {                   \
    161                 &NAME##_ops, 1                                                 \
     166                &NAME##_ops, 1, 0                                              \
    162167        }
    163168
     
    222227/** The zero-terminated data transform. */
    223228bithenge_transform_t bithenge_zero_terminated_transform = {
    224         &zero_terminated_ops, 1
     229        &zero_terminated_ops, 1, 0
    225230};
    226231
     
    480485        }
    481486        rc = bithenge_init_transform(struct_as_transform(self),
    482             &struct_transform_ops);
     487            &struct_transform_ops, 0);
    483488        if (rc != EOK)
    484489                goto error;
     
    579584        }
    580585        rc = bithenge_init_transform(compose_as_transform(self),
    581             &compose_transform_ops);
     586            &compose_transform_ops, 0);
    582587        if (rc != EOK)
    583588                goto error;
  • uspace/app/bithenge/transform.h

    r6e34bd0 r03cad47  
    4646        const struct bithenge_transform_ops *ops;
    4747        unsigned int refs;
     48        int num_params;
    4849} bithenge_transform_t;
    4950
     
    6667         * @param self The transform. */
    6768        void (*destroy)(bithenge_transform_t *self);
    68         /** The number of parameters required. */
    69         int num_params;
    7069} bithenge_transform_ops_t;
    7170
     
    136135}
    137136
    138 /** Get the number of parameters required by a transform. Takes ownership of
    139  * nothing.
     137/** Get the number of parameters required by a transform. This number is used
     138 * by the parser and param-wrapper. Takes ownership of nothing.
    140139 * @param self The transform.
    141140 * @return The number of parameters required. */
     
    143142{
    144143        assert(self);
    145         assert(self->ops);
    146         return self->ops->num_params;
     144        return self->num_params;
    147145}
    148146
     
    220218
    221219int bithenge_init_transform(bithenge_transform_t *self,
    222     const bithenge_transform_ops_t *ops);
     220    const bithenge_transform_ops_t *ops, int num_params);
    223221int bithenge_new_struct(bithenge_transform_t **out,
    224222    bithenge_named_transform_t *subtransforms);
Note: See TracChangeset for help on using the changeset viewer.