Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 5a7c0e6 in mainline for uspace/app/bithenge/transform.c


Ignore:
Timestamp:
2012-07-27T01:09:05Z (10 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master
Children:
6e34bd0
Parents:
43788b2
Message:

Bithenge: rename transform parameters "scopes" and add room for parameters

File:
1 edited

Legend:

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

    r43788b2 r5a7c0e6  
    6161}
    6262
    63 static int ascii_apply(bithenge_transform_t *self,
    64     bithenge_transform_context_t *context, bithenge_node_t *in,
    65     bithenge_node_t **out)
     63static int ascii_apply(bithenge_transform_t *self, bithenge_scope_t *scope,
     64    bithenge_node_t *in, bithenge_node_t **out)
    6665{
    6766        int rc;
     
    103102};
    104103
    105 static int prefix_length_1(bithenge_transform_t *self,
    106     bithenge_transform_context_t *context, bithenge_blob_t *blob,
    107     aoff64_t *out)
     104static int prefix_length_1(bithenge_transform_t *self, bithenge_scope_t *scope,
     105    bithenge_blob_t *blob, aoff64_t *out)
    108106{
    109107        *out = 1;
     
    111109}
    112110
    113 static int prefix_length_2(bithenge_transform_t *self,
    114     bithenge_transform_context_t *context, bithenge_blob_t *blob,
    115     aoff64_t *out)
     111static int prefix_length_2(bithenge_transform_t *self, bithenge_scope_t *scope,
     112    bithenge_blob_t *blob, aoff64_t *out)
    116113{
    117114        *out = 2;
     
    119116}
    120117
    121 static int prefix_length_4(bithenge_transform_t *self,
    122     bithenge_transform_context_t *context, bithenge_blob_t *blob,
    123     aoff64_t *out)
     118static int prefix_length_4(bithenge_transform_t *self, bithenge_scope_t *scope,
     119    bithenge_blob_t *blob, aoff64_t *out)
    124120{
    125121        *out = 4;
     
    127123}
    128124
    129 static int prefix_length_8(bithenge_transform_t *self,
    130     bithenge_transform_context_t *context, bithenge_blob_t *blob,
    131     aoff64_t *out)
     125static int prefix_length_8(bithenge_transform_t *self, bithenge_scope_t *scope,
     126    bithenge_blob_t *blob, aoff64_t *out)
    132127{
    133128        *out = 8;
     
    137132#define MAKE_UINT_TRANSFORM(NAME, TYPE, ENDIAN, PREFIX_LENGTH_FUNC)            \
    138133        static int NAME##_apply(bithenge_transform_t *self,                    \
    139             bithenge_transform_context_t *context, bithenge_node_t *in,        \
     134            bithenge_scope_t *scope, bithenge_node_t *in,                      \
    140135            bithenge_node_t **out)                                             \
    141136        {                                                                      \
     
    176171
    177172static int zero_terminated_apply(bithenge_transform_t *self,
    178     bithenge_transform_context_t *context, bithenge_node_t *in,
    179     bithenge_node_t **out)
     173    bithenge_scope_t *scope, bithenge_node_t *in, bithenge_node_t **out)
    180174{
    181175        int rc;
     
    201195
    202196static int zero_terminated_prefix_length(bithenge_transform_t *self,
    203     bithenge_transform_context_t *context, bithenge_blob_t *blob,
    204     aoff64_t *out)
     197    bithenge_scope_t *scope, bithenge_blob_t *blob, aoff64_t *out)
    205198{
    206199        int rc;
     
    251244        bithenge_node_t base;
    252245        struct struct_transform *transform;
    253         bithenge_transform_context_t *context;
     246        bithenge_scope_t *scope;
    254247        bithenge_blob_t *blob;
    255248} struct_node_t;
     
    281274
    282275static int struct_node_for_one(const char *name,
    283     bithenge_transform_t *subxform, bithenge_transform_context_t *context,
     276    bithenge_transform_t *subxform, bithenge_scope_t *scope,
    284277    bithenge_blob_t **blob, bithenge_for_each_func_t func, void *data)
    285278{
     
    288281
    289282        aoff64_t sub_size;
    290         rc = bithenge_transform_prefix_length(subxform, context, *blob,
     283        rc = bithenge_transform_prefix_length(subxform, scope, *blob,
    291284            &sub_size);
    292285        if (rc != EOK)
     
    299292                goto error;
    300293
    301         rc = bithenge_transform_apply(subxform, context, subblob_node,
     294        rc = bithenge_transform_apply(subxform, scope, subblob_node,
    302295            &subxform_result);
    303296        bithenge_node_dec_ref(subblob_node);
     
    357350        for (size_t i = 0; subxforms[i].transform; i++) {
    358351                rc = struct_node_for_one(subxforms[i].name,
    359                     subxforms[i].transform, struct_node->context, &blob, func,
     352                    subxforms[i].transform, struct_node->scope, &blob, func,
    360353                    data);
    361354                if (rc != EOK)
     
    391384
    392385static int struct_transform_apply(bithenge_transform_t *base,
    393     bithenge_transform_context_t *context, bithenge_node_t *in,
    394     bithenge_node_t **out)
     386    bithenge_scope_t *scope, bithenge_node_t *in, bithenge_node_t **out)
    395387{
    396388        struct_transform_t *self = transform_as_struct(base);
     
    409401        node->transform = self;
    410402        bithenge_node_inc_ref(in);
    411         node->context = context;
     403        node->scope = scope;
    412404        node->blob = bithenge_node_as_blob(in);
    413405        *out = struct_as_node(node);
     
    416408
    417409static int struct_transform_prefix_length(bithenge_transform_t *base,
    418     bithenge_transform_context_t *context, bithenge_blob_t *blob,
    419     aoff64_t *out)
     410    bithenge_scope_t *scope, bithenge_blob_t *blob, aoff64_t *out)
    420411{
    421412        struct_transform_t *self = transform_as_struct(base);
     
    433424                    self->subtransforms[i].transform;
    434425                aoff64_t sub_size;
    435                 rc = bithenge_transform_prefix_length(subxform, context, blob,
     426                rc = bithenge_transform_prefix_length(subxform, scope, blob,
    436427                    &sub_size);
    437428                if (rc != EOK)
     
    517508}
    518509
    519 static int compose_apply(bithenge_transform_t *base,
    520     bithenge_transform_context_t *context, bithenge_node_t *in,
    521     bithenge_node_t **out)
     510static int compose_apply(bithenge_transform_t *base, bithenge_scope_t *scope,
     511    bithenge_node_t *in, bithenge_node_t **out)
    522512{
    523513        int rc;
     
    528518        for (size_t i = self->num; i--; ) {
    529519                bithenge_node_t *tmp;
    530                 rc = bithenge_transform_apply(self->xforms[i], context, in,
     520                rc = bithenge_transform_apply(self->xforms[i], scope, in,
    531521                    &tmp);
    532522                bithenge_node_dec_ref(in);
     
    541531
    542532static int compose_prefix_length(bithenge_transform_t *base,
    543     bithenge_transform_context_t *context, bithenge_blob_t *blob,
    544     aoff64_t *out)
     533    bithenge_scope_t *scope, bithenge_blob_t *blob, aoff64_t *out)
    545534{
    546535        compose_transform_t *self = transform_as_compose(base);
    547536        return bithenge_transform_prefix_length(self->xforms[self->num - 1],
    548             context, blob, out);
     537            scope, blob, out);
    549538}
    550539
Note: See TracChangeset for help on using the changeset viewer.