Changes in uspace/lib/bithenge/src/expression.c [6cd10ac:b7fd2a0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/bithenge/src/expression.c
r6cd10ac rb7fd2a0 48 48 * @param[in] ops Operations provided by the expression. 49 49 * @return EOK or an error code from errno.h. */ 50 int bithenge_init_expression(bithenge_expression_t *self,50 errno_t bithenge_init_expression(bithenge_expression_t *self, 51 51 const bithenge_expression_ops_t *ops) 52 52 { … … 88 88 } 89 89 90 static int binary_expression_evaluate(bithenge_expression_t *base,90 static errno_t binary_expression_evaluate(bithenge_expression_t *base, 91 91 bithenge_scope_t *scope, bithenge_node_t **out) 92 92 { 93 int rc;93 errno_t rc; 94 94 binary_expression_t *self = expression_as_binary(base); 95 95 bithenge_node_t *a, *b; … … 250 250 * @param b The second operand. 251 251 * @return EOK on success or an error code from errno.h. */ 252 int bithenge_binary_expression(bithenge_expression_t **out,252 errno_t bithenge_binary_expression(bithenge_expression_t **out, 253 253 bithenge_binary_op_t op, bithenge_expression_t *a, 254 254 bithenge_expression_t *b) 255 255 { 256 int rc;256 errno_t rc; 257 257 binary_expression_t *self = malloc(sizeof(*self)); 258 258 if (!self) { … … 283 283 /***************** in_node_expression *****************/ 284 284 285 static int in_node_evaluate(bithenge_expression_t *self,285 static errno_t in_node_evaluate(bithenge_expression_t *self, 286 286 bithenge_scope_t *scope, bithenge_node_t **out) 287 287 { … … 306 306 * @param[out] out Holds the new expression. 307 307 * @return EOK on success or an error code from errno.h. */ 308 int bithenge_in_node_expression(bithenge_expression_t **out)308 errno_t bithenge_in_node_expression(bithenge_expression_t **out) 309 309 { 310 310 if (bithenge_should_fail()) … … 319 319 /***************** current_node_expression *****************/ 320 320 321 static int current_node_evaluate(bithenge_expression_t *self,321 static errno_t current_node_evaluate(bithenge_expression_t *self, 322 322 bithenge_scope_t *scope, bithenge_node_t **out) 323 323 { … … 340 340 * @param[out] out Holds the new expression. 341 341 * @return EOK on success or an error code from errno.h. */ 342 int bithenge_current_node_expression(bithenge_expression_t **out)342 errno_t bithenge_current_node_expression(bithenge_expression_t **out) 343 343 { 344 344 bithenge_expression_inc_ref(¤t_node_expression); … … 368 368 } 369 369 370 static int param_expression_evaluate(bithenge_expression_t *base,370 static errno_t param_expression_evaluate(bithenge_expression_t *base, 371 371 bithenge_scope_t *scope, bithenge_node_t **out) 372 372 { … … 390 390 * @param index The index of the parameter to get. 391 391 * @return EOK on success or an error code from errno.h. */ 392 int bithenge_param_expression(bithenge_expression_t **out, int index)393 { 394 int rc;392 errno_t bithenge_param_expression(bithenge_expression_t **out, int index) 393 { 394 errno_t rc; 395 395 param_expression_t *self = malloc(sizeof(*self)); 396 396 if (!self) … … 430 430 } 431 431 432 static int const_expression_evaluate(bithenge_expression_t *base,432 static errno_t const_expression_evaluate(bithenge_expression_t *base, 433 433 bithenge_scope_t *scope, bithenge_node_t **out) 434 434 { … … 455 455 * @param node The constant. 456 456 * @return EOK on success or an error code from errno.h. */ 457 int bithenge_const_expression(bithenge_expression_t **out,457 errno_t bithenge_const_expression(bithenge_expression_t **out, 458 458 bithenge_node_t *node) 459 459 { 460 int rc;460 errno_t rc; 461 461 const_expression_t *self = malloc(sizeof(*self)); 462 462 if (!self) { … … 501 501 } 502 502 503 static int scope_member_expression_evaluate(bithenge_expression_t *base,503 static errno_t scope_member_expression_evaluate(bithenge_expression_t *base, 504 504 bithenge_scope_t *scope, bithenge_node_t **out) 505 505 { … … 511 511 continue; 512 512 bithenge_node_inc_ref(self->key); 513 int rc = bithenge_node_get(cur, self->key, out);513 errno_t rc = bithenge_node_get(cur, self->key, out); 514 514 bithenge_node_dec_ref(cur); 515 515 if (rc != ENOENT) /* EOK or error */ … … 537 537 * @param key The key to search for in nodes being created. 538 538 * @return EOK on success or an error code from errno.h. */ 539 int bithenge_scope_member_expression(bithenge_expression_t **out,539 errno_t bithenge_scope_member_expression(bithenge_expression_t **out, 540 540 bithenge_node_t *key) 541 541 { 542 int rc;542 errno_t rc; 543 543 scope_member_expression_t *self = malloc(sizeof(*self)); 544 544 if (!self) { … … 582 582 } 583 583 584 static int subblob_expression_evaluate(bithenge_expression_t *base,584 static errno_t subblob_expression_evaluate(bithenge_expression_t *base, 585 585 bithenge_scope_t *scope, bithenge_node_t **out) 586 586 { 587 587 subblob_expression_t *self = expression_as_subblob(base); 588 588 bithenge_node_t *start_node; 589 int rc = bithenge_expression_evaluate(self->start, scope, &start_node);589 errno_t rc = bithenge_expression_evaluate(self->start, scope, &start_node); 590 590 if (rc != EOK) 591 591 return rc; … … 658 658 * it is relative to the start. 659 659 * @return EOK on success or an error code from errno.h. */ 660 int bithenge_subblob_expression(bithenge_expression_t **out,660 errno_t bithenge_subblob_expression(bithenge_expression_t **out, 661 661 bithenge_expression_t *blob, bithenge_expression_t *start, 662 662 bithenge_expression_t *limit, bool absolute_limit) 663 663 { 664 int rc;664 errno_t rc; 665 665 subblob_expression_t *self = malloc(sizeof(*self)); 666 666 if (!self) { … … 709 709 } 710 710 711 static int param_wrapper_fill_scope(param_wrapper_t *self, bithenge_scope_t711 static errno_t param_wrapper_fill_scope(param_wrapper_t *self, bithenge_scope_t 712 712 *inner, bithenge_scope_t *outer) 713 713 { 714 int rc;714 errno_t rc; 715 715 int num_params = bithenge_transform_num_params(self->transform); 716 716 rc = bithenge_scope_alloc_params(inner, num_params); … … 730 730 } 731 731 732 static int param_wrapper_apply(bithenge_transform_t *base,732 static errno_t param_wrapper_apply(bithenge_transform_t *base, 733 733 bithenge_scope_t *outer, bithenge_node_t *in, bithenge_node_t **out) 734 734 { 735 735 param_wrapper_t *self = transform_as_param_wrapper(base); 736 736 bithenge_scope_t *inner; 737 int rc = bithenge_scope_new(&inner, outer);737 errno_t rc = bithenge_scope_new(&inner, outer); 738 738 if (rc != EOK) 739 739 return rc; … … 750 750 } 751 751 752 static int param_wrapper_prefix_length(bithenge_transform_t *base,752 static errno_t param_wrapper_prefix_length(bithenge_transform_t *base, 753 753 bithenge_scope_t *outer, bithenge_blob_t *in, aoff64_t *out) 754 754 { 755 755 param_wrapper_t *self = transform_as_param_wrapper(base); 756 756 bithenge_scope_t *inner; 757 int rc = bithenge_scope_new(&inner, outer);757 errno_t rc = bithenge_scope_new(&inner, outer); 758 758 if (rc != EOK) 759 759 return rc; … … 770 770 } 771 771 772 static int param_wrapper_prefix_apply(bithenge_transform_t *base,772 static errno_t param_wrapper_prefix_apply(bithenge_transform_t *base, 773 773 bithenge_scope_t *outer, bithenge_blob_t *in, bithenge_node_t **out_node, 774 774 aoff64_t *out_length) … … 776 776 param_wrapper_t *self = transform_as_param_wrapper(base); 777 777 bithenge_scope_t *inner; 778 int rc = bithenge_scope_new(&inner, outer);778 errno_t rc = bithenge_scope_new(&inner, outer); 779 779 if (rc != EOK) 780 780 return rc; … … 816 816 * @param params The expressions used to calculate the parameters. 817 817 * @return EOK on success or an error code from errno.h. */ 818 int bithenge_param_wrapper(bithenge_transform_t **out,818 errno_t bithenge_param_wrapper(bithenge_transform_t **out, 819 819 bithenge_transform_t *transform, bithenge_expression_t **params) 820 820 { 821 int rc;821 errno_t rc; 822 822 int num_params = bithenge_transform_num_params(transform); 823 823 param_wrapper_t *self = malloc(sizeof(*self)); … … 868 868 } 869 869 870 static int expression_transform_apply(bithenge_transform_t *base,870 static errno_t expression_transform_apply(bithenge_transform_t *base, 871 871 bithenge_scope_t *scope, bithenge_node_t *in, bithenge_node_t **out) 872 872 { 873 873 expression_transform_t *self = transform_as_expression(base); 874 874 bithenge_scope_t *inner; 875 int rc = bithenge_scope_new(&inner, scope);875 errno_t rc = bithenge_scope_new(&inner, scope); 876 876 if (rc != EOK) 877 877 return rc; … … 900 900 * @param expr The expression to evaluate. 901 901 * @return EOK on success or an error code from errno.h. */ 902 int bithenge_expression_transform(bithenge_transform_t ** out,902 errno_t bithenge_expression_transform(bithenge_transform_t ** out, 903 903 bithenge_expression_t *expr) 904 904 { 905 int rc;905 errno_t rc; 906 906 expression_transform_t *self = malloc(sizeof(*self)); 907 907 if (!self) { … … 929 929 /***************** inputless_transform *****************/ 930 930 931 static int inputless_transform_prefix_length(bithenge_transform_t *base,931 static errno_t inputless_transform_prefix_length(bithenge_transform_t *base, 932 932 bithenge_scope_t *scope, bithenge_blob_t *in, aoff64_t *out) 933 933 { … … 936 936 } 937 937 938 static int inputless_transform_prefix_apply(bithenge_transform_t *base,938 static errno_t inputless_transform_prefix_apply(bithenge_transform_t *base, 939 939 bithenge_scope_t *scope, bithenge_blob_t *in, bithenge_node_t **out_node, 940 940 aoff64_t *out_size) … … 957 957 * @param expr The expression to evaluate. 958 958 * @return EOK on success or an error code from errno.h. */ 959 int bithenge_inputless_transform(bithenge_transform_t ** out,959 errno_t bithenge_inputless_transform(bithenge_transform_t ** out, 960 960 bithenge_expression_t *expr) 961 961 { 962 int rc;962 errno_t rc; 963 963 expression_transform_t *self = malloc(sizeof(*self)); 964 964 if (!self) { … … 1004 1004 } 1005 1005 1006 static int concat_blob_evaluate_b(concat_blob_t *self)1006 static errno_t concat_blob_evaluate_b(concat_blob_t *self) 1007 1007 { 1008 1008 if (self->b) 1009 1009 return EOK; 1010 1010 bithenge_node_t *b_node; 1011 int rc = bithenge_expression_evaluate(self->b_expr, self->scope,1011 errno_t rc = bithenge_expression_evaluate(self->b_expr, self->scope, 1012 1012 &b_node); 1013 1013 if (rc != EOK) … … 1026 1026 } 1027 1027 1028 static int concat_blob_size(bithenge_blob_t *base, aoff64_t *size)1028 static errno_t concat_blob_size(bithenge_blob_t *base, aoff64_t *size) 1029 1029 { 1030 1030 concat_blob_t *self = blob_as_concat(base); 1031 int rc = concat_blob_evaluate_b(self);1031 errno_t rc = concat_blob_evaluate_b(self); 1032 1032 if (rc != EOK) 1033 1033 return rc; … … 1037 1037 } 1038 1038 1039 static int concat_blob_read(bithenge_blob_t *base, aoff64_t offset,1039 static errno_t concat_blob_read(bithenge_blob_t *base, aoff64_t offset, 1040 1040 char *buffer, aoff64_t *size) 1041 1041 { 1042 int rc;1042 errno_t rc; 1043 1043 concat_blob_t *self = blob_as_concat(base); 1044 1044 … … 1065 1065 } 1066 1066 1067 static int concat_blob_read_bits(bithenge_blob_t *base, aoff64_t offset,1067 static errno_t concat_blob_read_bits(bithenge_blob_t *base, aoff64_t offset, 1068 1068 char *buffer, aoff64_t *size, bool little_endian) 1069 1069 { 1070 int rc;1070 errno_t rc; 1071 1071 concat_blob_t *self = blob_as_concat(base); 1072 1072 … … 1118 1118 * @param b The second blob. 1119 1119 * @return EOK on success or an error code from errno.h. */ 1120 int bithenge_concat_blob(bithenge_node_t **out, bithenge_blob_t *a,1120 errno_t bithenge_concat_blob(bithenge_node_t **out, bithenge_blob_t *a, 1121 1121 bithenge_blob_t *b) 1122 1122 { … … 1124 1124 assert(a); 1125 1125 assert(b); 1126 int rc;1126 errno_t rc; 1127 1127 concat_blob_t *self = malloc(sizeof(*self)); 1128 1128 if (!self) { … … 1160 1160 * @param scope The scope in which @a b_expr should be evaluated. 1161 1161 * @return EOK on success or an error code from errno.h. */ 1162 int bithenge_concat_blob_lazy(bithenge_node_t **out, bithenge_blob_t *a,1162 errno_t bithenge_concat_blob_lazy(bithenge_node_t **out, bithenge_blob_t *a, 1163 1163 bithenge_expression_t *b_expr, bithenge_scope_t *scope) 1164 1164 { … … 1167 1167 assert(b_expr); 1168 1168 assert(scope); 1169 int rc;1169 errno_t rc; 1170 1170 concat_blob_t *self = malloc(sizeof(*self)); 1171 1171 if (!self) {
Note:
See TracChangeset
for help on using the changeset viewer.