Changeset 0784869 in mainline
- Timestamp:
- 2012-08-20T17:32:00Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1f136a27
- Parents:
- 1a3b953
- Location:
- uspace/lib/bithenge
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/bithenge/blob.h
r1a3b953 r0784869 233 233 } 234 234 235 /** @memberof bithenge_blob_t */ 235 236 int bithenge_init_random_access_blob(bithenge_blob_t *, 236 237 const bithenge_random_access_blob_ops_t *); 238 /** @memberof bithenge_sequential_blob_t */ 237 239 int bithenge_init_sequential_blob(bithenge_sequential_blob_t *, 238 240 const bithenge_sequential_blob_ops_t *); 241 /** @memberof bithenge_blob_t */ 239 242 int bithenge_new_blob_from_data(bithenge_node_t **, const void *, size_t); 243 /** @memberof bithenge_blob_t */ 240 244 int bithenge_new_blob_from_buffer(bithenge_node_t **, const void *, size_t, 241 245 bool); … … 243 247 int bithenge_new_subblob(bithenge_node_t **, bithenge_blob_t *, aoff64_t, 244 248 aoff64_t); 249 /** @memberof bithenge_blob_t */ 245 250 int bithenge_blob_equal(bool *, bithenge_blob_t *, bithenge_blob_t *); 246 251 -
uspace/lib/bithenge/expression.c
r1a3b953 r0784869 530 530 }; 531 531 532 /** Create an expression that gets a member from one of the current nodes being 533 * created. It searches from the current scope outwards, stopping at barrier 534 * scopes. 535 * @param[out] out Holds the new expression. 536 * @param key The key to search for in nodes being created. 537 * @return EOK on success or an error code from errno.h. */ 532 538 int bithenge_scope_member_expression(bithenge_expression_t **out, 533 539 bithenge_node_t *key) -
uspace/lib/bithenge/expression.h
r1a3b953 r0784869 93 93 } 94 94 95 /** The binary operators supported by @a bithenge_binary_expression(). */ 95 96 typedef enum { 96 97 BITHENGE_EXPRESSION_INVALID_BINARY_OP, -
uspace/lib/bithenge/failure.c
r1a3b953 r0784869 27 27 */ 28 28 29 /** @cond internal */ 29 30 /** @addtogroup bithenge 30 31 * @{ … … 237 238 /** @} 238 239 */ 240 /** @endcond */ -
uspace/lib/bithenge/failure.h
r1a3b953 r0784869 27 27 */ 28 28 29 /** @cond internal */ 29 30 /** @addtogroup bithenge 30 31 * @{ … … 71 72 /** @} 72 73 */ 74 75 /** @endcond */ 76 -
uspace/lib/bithenge/script.c
r1a3b953 r0784869 46 46 #include "tree.h" 47 47 48 /** @cond internal */ 49 #define BUFFER_SIZE 4096 50 /** @endcond */ 51 48 52 /** Tokens with more characters than this may be read incorrectly. */ 49 #define MAX_TOKEN_SIZE 256 50 #define BUFFER_SIZE 4096 51 52 /** Single-character symbols are represented by the character itself. Every53 static const int MAX_TOKEN_SIZE = 256; 54 55 /** @cond internal 56 * Single-character symbols are represented by the character itself. Every 53 57 * other token uses one of these values: */ 54 58 typedef enum { … … 82 86 TOKEN_WHILE, 83 87 } token_type_t; 88 /** @endcond */ 84 89 85 90 /** Singly-linked list of named transforms. */ … … 438 443 /***************** Expressions *****************/ 439 444 445 /** @cond internal */ 440 446 typedef enum { 441 447 PRECEDENCE_NONE, … … 446 452 PRECEDENCE_MULTIPLY, 447 453 } precedence_t; 454 /** @endcond */ 448 455 449 456 static bithenge_binary_op_t token_as_binary_operator(token_type_t token) -
uspace/lib/bithenge/transform.c
r1a3b953 r0784869 184 184 /** Create a transform scope. It must be dereferenced with @a 185 185 * bithenge_scope_dec_ref after it is used. Takes ownership of nothing. 186 * @memberof bithenge_scope_t 186 187 * @param[out] out Holds the new scope. 187 188 * @param outer The outer scope, or NULL. … … 207 208 208 209 /** Dereference a transform scope. 209 * @param self The scope to dereference. */ 210 * @memberof bithenge_scope_t 211 * @param self The scope to dereference, or NULL. */ 210 212 void bithenge_scope_dec_ref(bithenge_scope_t *self) 211 213 { … … 224 226 225 227 /** Get the outer scope of a scope, which may be NULL. 228 * @memberof bithenge_scope_t 226 229 * @param self The scope to examine. 227 230 * @return The outer scope, which may be NULL. */ … … 233 236 /** Get the error message stored in the scope, which may be NULL. The error 234 237 * message only exists as long as the scope does. 238 * @memberof bithenge_scope_t 235 239 * @param scope The scope to get the error message from. 236 240 * @return The error message, or NULL. */ … … 243 247 * outermost scope, but if any scope already has an error message this error 244 248 * message is ignored. 249 * @memberof bithenge_scope_t 245 250 * @param scope The scope. 246 251 * @param format The format string. … … 292 297 293 298 /** Get the current node being created, which may be NULL. 299 * @memberof bithenge_scope_t 294 300 * @param scope The scope to get the current node from. 295 301 * @return The node being created, or NULL. */ … … 302 308 303 309 /** Set the current node being created. Takes a reference to @a node. 310 * @memberof bithenge_scope_t 304 311 * @param scope The scope to set the current node in. 305 312 * @param node The current node being created, or NULL. */ … … 312 319 313 320 /** Get the current input node, which may be NULL. 321 * @memberof bithenge_scope_t 314 322 * @param scope The scope to get the current input node from. 315 323 * @return The input node, or NULL. */ … … 322 330 323 331 /** Set the current input node. Takes a reference to @a node. 332 * @memberof bithenge_scope_t 324 333 * @param scope The scope to set the input node in. 325 334 * @param node The input node, or NULL. */ … … 331 340 332 341 /** Set a scope as a barrier. 342 * @memberof bithenge_scope_t 333 343 * @param self The scope to change. */ 334 344 void bithenge_scope_set_barrier(bithenge_scope_t *self) … … 339 349 /** Check whether a scope is a barrier, meaning that variable lookup stops at 340 350 * it. 351 * @memberof bithenge_scope_t 341 352 * @param self The scope to check. 342 353 * @return Whether the scope is a barrier. */ … … 349 360 * bithenge_scope_set_param. This must not be called on a scope that already 350 361 * has parameters. 362 * @memberof bithenge_scope_t 351 363 * @param scope The scope in which to allocate parameters. 352 364 * @param num_params The number of parameters to allocate. … … 363 375 } 364 376 365 /** Set a parameter. Takes a reference to @a value. Note that range checking is377 /** Set a parameter. Takes a reference to @a node. Note that range checking is 366 378 * not done in release builds. 379 * @memberof bithenge_scope_t 367 380 * @param scope The scope in which to allocate parameters. 368 381 * @param i The index of the parameter to set. 369 * @param value The value to store in the parameter.382 * @param node The value to store in the parameter. 370 383 * @return EOK on success or an error code from errno.h. */ 371 384 int bithenge_scope_set_param( bithenge_scope_t *scope, int i, … … 383 396 384 397 /** Get a parameter. Note that range checking is not done in release builds. 398 * @memberof bithenge_scope_t 385 399 * @param scope The scope to get the parameter from. 386 400 * @param i The index of the parameter to set. … … 867 881 } 868 882 883 /** @cond internal */ 869 884 #define MAKE_UINT_TRANSFORM(NAME, TYPE, ENDIAN, PREFIX_LENGTH_FUNC) \ 870 885 static int NAME##_apply(bithenge_transform_t *self, \ … … 906 921 MAKE_UINT_TRANSFORM(uint64le, uint64_t, uint64_t_le2host, prefix_length_8); 907 922 MAKE_UINT_TRANSFORM(uint64be, uint64_t, uint64_t_be2host, prefix_length_8); 923 /** @endcond */ 908 924 909 925 -
uspace/lib/bithenge/transform.h
r1a3b953 r0784869 62 62 } bithenge_scope_t; 63 63 64 static inline void bithenge_scope_inc_ref(bithenge_scope_t *self) { 64 /** Increment a scope's reference count. 65 * @memberof bithenge_scope_t 66 * @param self The scope to reference. */ 67 static inline void bithenge_scope_inc_ref(bithenge_scope_t *self) 68 { 69 assert(self); 65 70 self->refs++; 66 71 } … … 117 122 /** A transform with a name. */ 118 123 typedef struct { 124 /** The transform's name. */ 119 125 const char *name; 126 /** The transform. */ 120 127 bithenge_transform_t *transform; 121 128 } bithenge_named_transform_t; 122 129 130 /** Transform that decodes an 8-bit unsigned integer */ 131 extern bithenge_transform_t bithenge_uint8_transform; 132 /** Transform that decodes a 16-bit little-endian unsigned integer */ 133 extern bithenge_transform_t bithenge_uint16le_transform; 134 /** Transform that decodes a 16-bit big-endian unsigned integer */ 135 extern bithenge_transform_t bithenge_uint16be_transform; 136 /** Transform that decodes a 32-bit little-endian unsigned integer */ 137 extern bithenge_transform_t bithenge_uint32le_transform; 138 /** Transform that decodes a 32-bit big-endian unsigned integer */ 139 extern bithenge_transform_t bithenge_uint32be_transform; 140 /** Transform that decodes a 64-bit little-endian unsigned integer */ 141 extern bithenge_transform_t bithenge_uint64le_transform; 142 /** Transform that decodes a 64-bit big-endian unsigned integer */ 143 extern bithenge_transform_t bithenge_uint64be_transform; 144 145 /** @cond */ 123 146 extern bithenge_transform_t bithenge_ascii_transform; 124 147 extern bithenge_transform_t bithenge_bit_transform; … … 128 151 extern bithenge_transform_t bithenge_known_length_transform; 129 152 extern bithenge_transform_t bithenge_nonzero_boolean_transform; 130 extern bithenge_transform_t bithenge_uint8_transform;131 extern bithenge_transform_t bithenge_uint16le_transform;132 extern bithenge_transform_t bithenge_uint16be_transform;133 extern bithenge_transform_t bithenge_uint32le_transform;134 extern bithenge_transform_t bithenge_uint32be_transform;135 extern bithenge_transform_t bithenge_uint64le_transform;136 extern bithenge_transform_t bithenge_uint64be_transform;137 153 extern bithenge_transform_t bithenge_uint_le_transform; 138 154 extern bithenge_transform_t bithenge_uint_be_transform; 139 155 extern bithenge_transform_t bithenge_zero_terminated_transform; 140 156 extern bithenge_named_transform_t *bithenge_primitive_transforms; 141 157 /** @endcond */ 158 159 /** @memberof bithenge_transform_t */ 142 160 int bithenge_init_transform(bithenge_transform_t *, 143 161 const bithenge_transform_ops_t *, int); 162 /** @memberof bithenge_transform_t */ 144 163 int bithenge_transform_apply(bithenge_transform_t *, bithenge_scope_t *, 145 164 bithenge_node_t *, bithenge_node_t **); 165 /** @memberof bithenge_transform_t */ 146 166 int bithenge_transform_prefix_length(bithenge_transform_t *, 147 167 bithenge_scope_t *, bithenge_blob_t *, aoff64_t *); 168 /** @memberof bithenge_transform_t */ 148 169 int bithenge_transform_prefix_apply(bithenge_transform_t *, bithenge_scope_t *, 149 170 bithenge_blob_t *, bithenge_node_t **, aoff64_t *); … … 152 173 bithenge_transform_t *); 153 174 175 /** @memberof bithenge_scope_t */ 154 176 int bithenge_scope_new(bithenge_scope_t **, bithenge_scope_t *); 177 /** @memberof bithenge_scope_t */ 155 178 void bithenge_scope_dec_ref(bithenge_scope_t *); 179 /** @memberof bithenge_scope_t */ 156 180 bithenge_scope_t *bithenge_scope_outer(bithenge_scope_t *); 181 /** @memberof bithenge_scope_t */ 157 182 const char *bithenge_scope_get_error(bithenge_scope_t *); 183 /** @memberof bithenge_scope_t */ 158 184 int bithenge_scope_error(bithenge_scope_t *, const char *, ...); 185 /** @memberof bithenge_scope_t */ 159 186 bithenge_node_t *bithenge_scope_get_current_node(bithenge_scope_t *); 187 /** @memberof bithenge_scope_t */ 160 188 void bithenge_scope_set_current_node(bithenge_scope_t *, bithenge_node_t *); 189 /** @memberof bithenge_scope_t */ 161 190 bithenge_node_t *bithenge_scope_in_node(bithenge_scope_t *); 191 /** @memberof bithenge_scope_t */ 162 192 void bithenge_scope_set_in_node(bithenge_scope_t *, bithenge_node_t *); 193 /** @memberof bithenge_scope_t */ 163 194 void bithenge_scope_set_barrier(bithenge_scope_t *); 195 /** @memberof bithenge_scope_t */ 164 196 bool bithenge_scope_is_barrier(bithenge_scope_t *); 197 /** @memberof bithenge_scope_t */ 165 198 int bithenge_scope_alloc_params(bithenge_scope_t *, int); 199 /** @memberof bithenge_scope_t */ 166 200 int bithenge_scope_set_param(bithenge_scope_t *, int, bithenge_node_t *); 201 /** @memberof bithenge_scope_t */ 167 202 int bithenge_scope_get_param(bithenge_scope_t *, int, bithenge_node_t **); 168 203 -
uspace/lib/bithenge/tree.c
r1a3b953 r0784869 358 358 * @param a, b Nodes to compare. 359 359 * @return EOK on success or an error code from errno.h. 360 * @todo Add support for internal nodes. 361 */ 360 * @todo Add support for internal nodes. */ 362 361 int bithenge_node_equal(bool *out, bithenge_node_t *a, bithenge_node_t *b) 363 362 { -
uspace/lib/bithenge/tree.h
r1a3b953 r0784869 56 56 } bithenge_node_type_t; 57 57 58 /** A tree node. It can have any of the types in @a bithenge_node_type_t. */ 58 59 typedef struct bithenge_node_t { 59 60 /** @privatesection */ … … 61 62 unsigned int refs; 62 63 union { 64 /** @privatesection */ 63 65 const struct bithenge_internal_node_ops_t *internal_ops; 64 66 bool boolean_value; 65 67 bithenge_int_t integer_value; 66 68 struct { 69 /** @privatesection */ 67 70 const char *ptr; 68 71 bool needs_free; … … 111 114 } 112 115 116 /** @memberof bithenge_node_t */ 113 117 void bithenge_node_dec_ref(bithenge_node_t *node); 114 118 … … 126 130 } 127 131 132 /** @memberof bithenge_node_t */ 128 133 int bithenge_node_get(bithenge_node_t *, bithenge_node_t *, 129 134 bithenge_node_t **); … … 159 164 } 160 165 166 /** @memberof bithenge_node_t */ 161 167 int bithenge_init_internal_node(bithenge_node_t *, 162 168 const bithenge_internal_node_ops_t *); 169 /** @memberof bithenge_node_t */ 163 170 int bithenge_new_empty_internal_node(bithenge_node_t **); 171 /** @memberof bithenge_node_t */ 164 172 int bithenge_new_simple_internal_node(bithenge_node_t **, bithenge_node_t **, 165 173 bithenge_int_t, bool needs_free); 174 /** @memberof bithenge_node_t */ 166 175 int bithenge_new_boolean_node(bithenge_node_t **, bool); 176 /** @memberof bithenge_node_t */ 167 177 int bithenge_new_integer_node(bithenge_node_t **, bithenge_int_t); 178 /** @memberof bithenge_node_t */ 168 179 int bithenge_new_string_node(bithenge_node_t **, const char *, bool); 180 /** @memberof bithenge_node_t */ 169 181 int bithenge_node_equal(bool *, bithenge_node_t *, bithenge_node_t *); 170 182
Note:
See TracChangeset
for help on using the changeset viewer.