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

moved inline functions back to the header

shouldn't result in any problems when used with static inline
This commit is contained in:
Marenz 2011-05-03 22:56:54 +02:00
parent 5bbcda7da0
commit 0fd0cd6e7a
2 changed files with 57 additions and 59 deletions

View file

@ -18,6 +18,7 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <psyc.h>
typedef enum typedef enum
{ {
@ -129,7 +130,10 @@ typedef struct
* *
* @param state Pointer to the state struct that should be initiated. * @param state Pointer to the state struct that should be initiated.
*/ */
inline void psyc_initParseState (psycParseState* state); static inline void psyc_initParseState (psycParseState* state)
{
memset(state, 0, sizeof(psycParseState));
}
/** /**
* Initiates the state struct with flags. * Initiates the state struct with flags.
@ -137,30 +141,75 @@ inline void psyc_initParseState (psycParseState* state);
* @param state Pointer to the state struct that should be initiated. * @param state Pointer to the state struct that should be initiated.
* @param flags Flags to be set for the parser, see psycParseFlag. * @param flags Flags to be set for the parser, see psycParseFlag.
*/ */
inline void psyc_initParseState2 (psycParseState* state, uint8_t flags); static inline void psyc_initParseState2 (psycParseState* state, uint8_t flags)
{
memset(state, 0, sizeof(psycParseState));
state->flags = flags;
if (flags & PSYC_PARSE_START_AT_CONTENT)
state->part = PSYC_PART_CONTENT;
}
/** /**
* Sets a new buffer in the parser state struct with data to be parsed. * Sets a new buffer in the parser state struct with data to be parsed.
*
* @param state Pointer to the initialized state of the parser
* @param buffer the buffer that should be parsed now
* @see psycString
*/ */
inline void psyc_setParseBuffer (psycParseState* state, psycString buffer); static inline void psyc_setParseBuffer (psycParseState* state, psycString buffer)
{
state->buffer = buffer;
state->cursor = 0;
inline void psyc_setParseBuffer2 (psycParseState* state, char *buffer, size_t length); if (state->flags & PSYC_PARSE_START_AT_CONTENT)
{
state->contentLength = buffer.length;
state->contentLengthFound = PSYC_TRUE;
}
}
/**
* Sets a new buffer in the parser state struct with data to be parsed.
*
* @param state Pointer to the initialized state of the parser
* @param buffer pointer to the data that should be parsed
* @param length length of the data in bytes
* @see psycString
*/
static inline void psyc_setParseBuffer2 (psycParseState* state, char *buffer, size_t length)
{
psyc_setParseBuffer(state, psyc_newString(buffer, length));
}
/** /**
* Initiates the list state struct. * Initiates the list state struct.
* *
* @param state Pointer to the list state struct that should be initiated. * @param state Pointer to the list state struct that should be initiated.
*/ */
inline void psyc_initParseListState (psycParseListState* state); static inline void psyc_initParseListState (psycParseListState* state)
{
memset(state, 0, sizeof(psycParseListState));
}
/** /**
* Sets a new buffer in the list parser state struct with data to be parsed. * Sets a new buffer in the list parser state struct with data to be parsed.
*/ */
inline void psyc_setParseListBuffer (psycParseListState* state, psycString buffer); static inline void psyc_setParseListBuffer (psycParseListState* state, psycString buffer)
{
state->buffer = buffer;
state->cursor = 0;
}
inline void psyc_setParseListBuffer2 (psycParseListState* state, char *buffer, size_t length); static inline void psyc_setParseListBuffer2 (psycParseListState* state, char *buffer, size_t length)
{
psyc_setParseListBuffer(state, psyc_newString(buffer, length));
}
inline size_t psyc_getContentLength (psycParseState* s); static inline size_t psyc_getContentLength (psycParseState* s)
{
return s->contentLength;
}
/** /**
* Parse PSYC packets. * Parse PSYC packets.

View file

@ -15,57 +15,6 @@
return ret; \ return ret; \
} }
inline void psyc_initParseState (psycParseState* state)
{
memset(state, 0, sizeof(psycParseState));
}
inline void psyc_initParseState2 (psycParseState* state, uint8_t flags)
{
memset(state, 0, sizeof(psycParseState));
state->flags = flags;
if (flags & PSYC_PARSE_START_AT_CONTENT)
state->part = PSYC_PART_CONTENT;
}
inline void psyc_setParseBuffer (psycParseState* state, psycString buffer)
{
state->buffer = buffer;
state->cursor = 0;
if (state->flags & PSYC_PARSE_START_AT_CONTENT)
{
state->contentLength = buffer.length;
state->contentLengthFound = PSYC_TRUE;
}
}
inline void psyc_setParseBuffer2 (psycParseState* state, char *buffer, size_t length)
{
psyc_setParseBuffer(state, psyc_newString(buffer, length));
}
inline void psyc_initParseListState (psycParseListState* state)
{
memset(state, 0, sizeof(psycParseListState));
}
inline void psyc_setParseListBuffer (psycParseListState* state, psycString buffer)
{
state->buffer = buffer;
state->cursor = 0;
}
inline void psyc_setParseListBuffer2 (psycParseListState* state, char *buffer, size_t length)
{
psyc_setParseListBuffer(state, psyc_newString(buffer, length));
}
inline size_t psyc_getContentLength (psycParseState* s)
{
return s->contentLength;
}
/** /**
* Determines if the argument is a glyph. * Determines if the argument is a glyph.