Skip to content

Commit

Permalink
filter work with not.
Browse files Browse the repository at this point in the history
  • Loading branch information
jweinst1 committed Jun 7, 2018
1 parent 545f5db commit 01de2c2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/WindComp.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ unsigned WindComp_apply_plus(unsigned char* args, const unsigned char* argsEnd);

unsigned WindComp_apply_minus(unsigned char* args, const unsigned char* argsEnd);

/*/ filtering functions /*/

// Checks if item in comp buffer is true or false after NOT
int WindComp_check_not(void);

// Maps an array of instructions onto the item in the comp buffer.
// Returns zero if error.
int WindComp_map(unsigned char* ins, const unsigned char* insEnd);
Expand Down
24 changes: 24 additions & 0 deletions src/flow/WindComp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

static unsigned char WindComp_BUF[WindComp_BUF_SIZE];

// Access to body chunk of comp item.
static unsigned char* WindComp_BODY = WindComp_BUF + 1;
// End of comp item.
static const unsigned char* WindComp_END = WindComp_BUF + WindComp_BUF_SIZE;

static unsigned WindComp_ITEM_LEN = 0;
Expand Down Expand Up @@ -164,6 +166,16 @@ unsigned WindComp_apply_minus(unsigned char* args, const unsigned char* argsEnd)
return mover - args;
}

int WindComp_check_not(void)
{
switch(WindComp_BUF[0])
{
case WindBool:
return *WindComp_BODY;
}
return 0;
}

/*Applies series of operations to item in comp*/
int WindComp_map(unsigned char* ins, const unsigned char* insEnd)
{
Expand Down Expand Up @@ -210,5 +222,17 @@ int WindComp_map(unsigned char* ins, const unsigned char* insEnd)

int WindComp_filter(unsigned char* ins, const unsigned char* insEnd)
{
unsigned moveChecker = 0;
// Active while object has still not failed a filter.
while(WindComp_get_len() && ins != insEnd)
{
switch(*ins)
{
case WindType_Not:
ins++;
break;
default: return 0;
}
}
return 1;
}

0 comments on commit 01de2c2

Please sign in to comment.