Skip to content

Commit

Permalink
#341 add CORTO_WALK_INIT, rename any_walk to walk_any
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Jul 30, 2018
1 parent 2f9440b commit 88471bc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
22 changes: 22 additions & 0 deletions include/store/walk.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,21 @@ struct corto_walk_opt {
corto_walk_cb observable;
};

#define CORTO_WALK_INIT {\
.program[CORTO_ANY] = corto_walk_any,\
.program[CORTO_COMPOSITE] = corto_walk_members,\
.program[CORTO_COLLECTION] = corto_walk_elements,\
.program[CORTO_BASE] = corto_walk_value,\
.observable = corto_walk_observable,\
.initialized = TRUE,\
.constructed = FALSE,\
.access = CORTO_GLOBAL,\
.accessKind = CORTO_XOR,\
.aliasAction = CORTO_WALK_ALIAS_FOLLOW,\
.optionalAction = CORTO_WALK_OPTIONAL_IF_SET,\
.visitAllCases = FALSE\
}

/** Walk over a corto object.
* @param opt Pointer to an initialized corto_walk_opt instance.
* @param object The object to be visited.
Expand Down Expand Up @@ -285,6 +300,13 @@ int16_t corto_walk_elements(
corto_value* value,
void* userData);

/** Walk any value */
CORTO_EXPORT
int16_t corto_walk_any(
corto_walk_opt* opt,
corto_value* info,
void* userData);

/** Walk an observable member.
* This function should only be called from the callback specified for the
* 'observable' member of 'opt'.
Expand Down
9 changes: 2 additions & 7 deletions src/store/walk.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
#include <corto/corto.h>
#include "object.h"

int16_t corto_any_walk(
corto_walk_opt* this,
corto_value* info,
void* userData);

int16_t corto_walk_ptr(
corto_walk_opt* this,
void *ptr,
Expand Down Expand Up @@ -119,7 +114,7 @@ void corto_walk_init(
corto_walk_opt* this)
{
memset(this, 0, sizeof(corto_walk_opt));
this->program[CORTO_ANY] = corto_any_walk;
this->program[CORTO_ANY] = corto_walk_any;
this->program[CORTO_COMPOSITE] = corto_walk_members;
this->program[CORTO_COLLECTION] = corto_walk_elements;
this->metaprogram[CORTO_BASE] = corto_walk_value;
Expand Down Expand Up @@ -213,7 +208,7 @@ bool corto_serializeMatchAccess(
}

/* Serialize any-value */
int16_t corto_any_walk(
int16_t corto_walk_any(
corto_walk_opt* this,
corto_value* info,
void* userData)
Expand Down

0 comments on commit 88471bc

Please sign in to comment.