1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

more PSYC_Packet fields; s/Var/Modifier/

This commit is contained in:
Gabor Adam Toth 2011-04-22 23:16:50 +02:00
parent 427ef9ac56
commit c2ad0f0bd7
4 changed files with 22 additions and 7 deletions

View file

@ -79,18 +79,31 @@ typedef enum
PSYC_LIST_BINARY = 2, PSYC_LIST_BINARY = 2,
} PSYC_ListType; } PSYC_ListType;
typedef enum {
PSYC_MODIFIER_CHECK_LENGTH = 0,
PSYC_MODIFIER_NEED_LENGTH = 1,
PSYC_MODIFIER_NO_LENGTH = 2,
PSYC_MODIFIER_ROUTING = 3,
} PSYC_ModifierType;
typedef enum {
PSYC_CONTENT_CHECK_LENGTH = 0,
PSYC_CONTENT_NEED_LENGTH = 1,
PSYC_CONTENT_NO_LENGTH = 2,
} PSYC_ContentType;
typedef struct typedef struct
{ {
size_t length; size_t length;
const char* ptr; const char* ptr;
} PSYC_Array; } PSYC_Array;
/* intermediate struct for a PSYC variable modification */ /* intermediate struct for a PSYC variable modification */
typedef struct { typedef struct {
char oper; // not call it 'operator' as C++ may not like that..? char oper; // not call it 'operator' as C++ may not like that..?
PSYC_Array name; PSYC_Array name;
PSYC_Array parameter; PSYC_Array value;
PSYC_ModifierType type;
} PSYC_Modifier; } PSYC_Modifier;
/* intermediate struct for a PSYC packet */ /* intermediate struct for a PSYC packet */
@ -99,6 +112,8 @@ typedef struct {
PSYC_Modifier **entity; // Header PSYC_Modifier **entity; // Header
PSYC_Array method; PSYC_Array method;
PSYC_Array data; PSYC_Array data;
PSYC_ContentType contentType;
size_t contentLength;
} PSYC_Packet; } PSYC_Packet;

View file

@ -39,7 +39,7 @@ typedef struct
*/ */
inline void PSYC_initRenderState (PSYC_RenderState* state); inline void PSYC_initRenderState (PSYC_RenderState* state);
int PSYC_renderVar(PSYC_RenderState* render, int PSYC_renderModifier(PSYC_RenderState* render,
const char* name, size_t nlength, const char* name, size_t nlength,
const char* value, size_t vlength, const char* value, size_t vlength,
PSYC_RenderFlag flags, char oper); PSYC_RenderFlag flags, char oper);

View file

@ -154,7 +154,7 @@ inline PSYC_ParseRC PSYC_parseBinaryValue(PSYC_ParseState* state, PSYC_Array* va
* Parse simple or binary variable. * Parse simple or binary variable.
* @return PSYC_PARSE_ERROR or PSYC_PARSE_SUCCESS * @return PSYC_PARSE_ERROR or PSYC_PARSE_SUCCESS
*/ */
inline PSYC_ParseRC PSYC_parseVar(PSYC_ParseState* state, char* oper, PSYC_Array* name, PSYC_Array* value) inline PSYC_ParseRC PSYC_parseModifier(PSYC_ParseState* state, char* oper, PSYC_Array* name, PSYC_Array* value)
{ {
*oper = *(state->buffer.ptr + state->cursor); *oper = *(state->buffer.ptr + state->cursor);
ADVANCE_CURSOR_OR_RETURN(PSYC_PARSE_INSUFFICIENT); ADVANCE_CURSOR_OR_RETURN(PSYC_PARSE_INSUFFICIENT);
@ -248,7 +248,7 @@ PSYC_ParseRC PSYC_parse(PSYC_ParseState* state, char* oper, PSYC_Array* name, PS
// so just test if the first char is a glyph. // so just test if the first char is a glyph.
if (isGlyph(state->buffer.ptr[state->cursor])) // is the first char a glyph? if (isGlyph(state->buffer.ptr[state->cursor])) // is the first char a glyph?
{ // it is a glyph, so a variable starts here { // it is a glyph, so a variable starts here
ret = PSYC_parseVar(state, oper, name, value); ret = PSYC_parseModifier(state, oper, name, value);
return ret == PSYC_PARSE_SUCCESS ? PSYC_PARSE_ROUTING : ret; return ret == PSYC_PARSE_SUCCESS ? PSYC_PARSE_ROUTING : ret;
} }
else // not a glyph else // not a glyph
@ -310,7 +310,7 @@ PSYC_ParseRC PSYC_parse(PSYC_ParseState* state, char* oper, PSYC_Array* name, PS
if (isGlyph(state->buffer.ptr[state->cursor])) if (isGlyph(state->buffer.ptr[state->cursor]))
{ {
pos = state->cursor; pos = state->cursor;
ret = PSYC_parseVar(state, oper, name, value); ret = PSYC_parseModifier(state, oper, name, value);
state->contentParsed += state->cursor - pos; state->contentParsed += state->cursor - pos;
return ret == PSYC_PARSE_SUCCESS ? PSYC_PARSE_ENTITY : ret; return ret == PSYC_PARSE_SUCCESS ? PSYC_PARSE_ENTITY : ret;
} }

View file

@ -6,7 +6,7 @@ inline void PSYC_initRenderState (PSYC_RenderState* state)
memset(state, 0, sizeof(PSYC_RenderState)); memset(state, 0, sizeof(PSYC_RenderState));
} }
PSYC_RenderRC PSYC_renderVar(PSYC_RenderState* state, PSYC_RenderRC PSYC_renderModifier(PSYC_RenderState* state,
const char* name, size_t nlength, const char* name, size_t nlength,
const char* value, size_t vlength, const char* value, size_t vlength,
const PSYC_RenderFlag flags, char oper) const PSYC_RenderFlag flags, char oper)