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

Switch static inline to inline

The linker does not create symbols for static functions so Rust FFI
can't find them. All static inline function have been changed to 'inline'
functions with an 'extern inline' declaration in the corresponding .c
files. Other than Rust FFI seeing the functions this has other
advantages. See [1] for a nice explanation.

[1]
https://gustedt.wordpress.com/2010/11/29/myth-and-reality-about-inline-in-c99/
This commit is contained in:
lurchi 2016-08-21 09:58:36 +02:00
parent 33f2862476
commit 9d7ad2a67f
14 changed files with 198 additions and 54 deletions

View file

@ -64,7 +64,7 @@ psyc_map_lookup (const PsycMap *map, size_t size,
* Look up value associated with a key in a map with integer values. * Look up value associated with a key in a map with integer values.
* @see psyc_map_lookup * @see psyc_map_lookup
*/ */
static inline intptr_t inline intptr_t
psyc_map_lookup_int (const PsycMapInt *map, size_t size, psyc_map_lookup_int (const PsycMapInt *map, size_t size,
const char *key, size_t keylen, PsycBool inherit) const char *key, size_t keylen, PsycBool inherit)
{ {

View file

@ -249,7 +249,7 @@ typedef struct {
/** /**
* Return the number of digits a number has in its base 10 representation. * Return the number of digits a number has in its base 10 representation.
*/ */
static inline size_t inline size_t
psyc_num_length (size_t n) psyc_num_length (size_t n)
{ {
return n < 10 ? 1 : log10(n) + 1; return n < 10 ? 1 : log10(n) + 1;
@ -259,7 +259,7 @@ psyc_num_length (size_t n)
* \internal * \internal
* Check if a modifier needs length. * Check if a modifier needs length.
*/ */
static inline PsycModifierFlag inline PsycModifierFlag
psyc_modifier_length_check (PsycModifier *m) psyc_modifier_length_check (PsycModifier *m)
{ {
if (m->value.length > 0 if (m->value.length > 0
@ -271,7 +271,7 @@ psyc_modifier_length_check (PsycModifier *m)
} }
/** Initialize modifier */ /** Initialize modifier */
static inline void inline void
psyc_modifier_init (PsycModifier *m, PsycOperator oper, psyc_modifier_init (PsycModifier *m, PsycOperator oper,
char *name, size_t namelen, char *name, size_t namelen,
char *value, size_t valuelen, PsycModifierFlag flag) char *value, size_t valuelen, PsycModifierFlag flag)

View file

@ -509,7 +509,7 @@ typedef struct {
* @param flags Flags to be set for the parser, see PsycParseFlag. * @param flags Flags to be set for the parser, see PsycParseFlag.
* @see PsycParseFlag * @see PsycParseFlag
*/ */
static inline void inline void
psyc_parse_state_init (PsycParseState *state, uint8_t flags) psyc_parse_state_init (PsycParseState *state, uint8_t flags)
{ {
memset(state, 0, sizeof(PsycParseState)); memset(state, 0, sizeof(PsycParseState));
@ -530,7 +530,7 @@ psyc_parse_state_init (PsycParseState *state, uint8_t flags)
* @param length length of the data in bytes * @param length length of the data in bytes
* @see PsycString * @see PsycString
*/ */
static inline void inline void
psyc_parse_buffer_set (PsycParseState *state, const char *buffer, size_t length) psyc_parse_buffer_set (PsycParseState *state, const char *buffer, size_t length)
{ {
state->buffer = (PsycString) {length, (char*)buffer}; state->buffer = (PsycString) {length, (char*)buffer};
@ -545,7 +545,7 @@ psyc_parse_buffer_set (PsycParseState *state, const char *buffer, size_t length)
/** /**
* Initializes the list parser state. * Initializes the list parser state.
*/ */
static inline void inline void
psyc_parse_list_state_init (PsycParseListState *state) psyc_parse_list_state_init (PsycParseListState *state)
{ {
memset(state, 0, sizeof(PsycParseListState)); memset(state, 0, sizeof(PsycParseListState));
@ -554,7 +554,7 @@ psyc_parse_list_state_init (PsycParseListState *state)
/** /**
* 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.
*/ */
static inline void inline void
psyc_parse_list_buffer_set (PsycParseListState *state, psyc_parse_list_buffer_set (PsycParseListState *state,
const char *buffer, size_t length) const char *buffer, size_t length)
{ {
@ -565,7 +565,7 @@ psyc_parse_list_buffer_set (PsycParseListState *state,
/** /**
* Initializes the dict parser state. * Initializes the dict parser state.
*/ */
static inline void inline void
psyc_parse_dict_state_init (PsycParseDictState *state) psyc_parse_dict_state_init (PsycParseDictState *state)
{ {
memset(state, 0, sizeof(PsycParseDictState)); memset(state, 0, sizeof(PsycParseDictState));
@ -574,7 +574,7 @@ psyc_parse_dict_state_init (PsycParseDictState *state)
/** /**
* Sets a new buffer in the dict parser state struct with data to be parsed. * Sets a new buffer in the dict parser state struct with data to be parsed.
*/ */
static inline void inline void
psyc_parse_dict_buffer_set (PsycParseDictState *state, psyc_parse_dict_buffer_set (PsycParseDictState *state,
const char *buffer, size_t length) const char *buffer, size_t length)
{ {
@ -585,7 +585,7 @@ psyc_parse_dict_buffer_set (PsycParseDictState *state,
/** /**
* Initializes the index parser state. * Initializes the index parser state.
*/ */
static inline void inline void
psyc_parse_index_state_init (PsycParseIndexState *state) psyc_parse_index_state_init (PsycParseIndexState *state)
{ {
memset(state, 0, sizeof(PsycParseIndexState)); memset(state, 0, sizeof(PsycParseIndexState));
@ -594,7 +594,7 @@ psyc_parse_index_state_init (PsycParseIndexState *state)
/** /**
* Sets a new buffer in the index parser state struct with data to be parsed. * Sets a new buffer in the index parser state struct with data to be parsed.
*/ */
static inline void inline void
psyc_parse_index_buffer_set (PsycParseIndexState *state, psyc_parse_index_buffer_set (PsycParseIndexState *state,
const char *buffer, size_t length) const char *buffer, size_t length)
{ {
@ -605,7 +605,7 @@ psyc_parse_index_buffer_set (PsycParseIndexState *state,
/** /**
* Initializes the update modifier parser state. * Initializes the update modifier parser state.
*/ */
static inline void inline void
psyc_parse_update_state_init (PsycParseUpdateState *state) psyc_parse_update_state_init (PsycParseUpdateState *state)
{ {
memset(state, 0, sizeof(PsycParseUpdateState)); memset(state, 0, sizeof(PsycParseUpdateState));
@ -614,7 +614,7 @@ psyc_parse_update_state_init (PsycParseUpdateState *state)
/** /**
* Sets a new buffer in the update modifier parser state struct with data to be parsed. * Sets a new buffer in the update modifier parser state struct with data to be parsed.
*/ */
static inline void inline void
psyc_parse_update_buffer_set (PsycParseUpdateState *state, psyc_parse_update_buffer_set (PsycParseUpdateState *state,
const char *buffer, size_t length) const char *buffer, size_t length)
{ {
@ -622,49 +622,49 @@ psyc_parse_update_buffer_set (PsycParseUpdateState *state,
state->cursor = 0; state->cursor = 0;
} }
static inline size_t inline size_t
psyc_parse_content_length (PsycParseState *state) psyc_parse_content_length (PsycParseState *state)
{ {
return state->contentlen; return state->contentlen;
} }
static inline PsycBool inline PsycBool
psyc_parse_content_length_found (PsycParseState *state) psyc_parse_content_length_found (PsycParseState *state)
{ {
return (PsycBool) state->contentlen_found; return (PsycBool) state->contentlen_found;
} }
static inline size_t inline size_t
psyc_parse_value_length (PsycParseState *state) psyc_parse_value_length (PsycParseState *state)
{ {
return state->valuelen; return state->valuelen;
} }
static inline PsycBool inline PsycBool
psyc_parse_value_length_found (PsycParseState *state) psyc_parse_value_length_found (PsycParseState *state)
{ {
return (PsycBool) state->valuelen_found; return (PsycBool) state->valuelen_found;
} }
static inline size_t inline size_t
psyc_parse_cursor (PsycParseState *state) psyc_parse_cursor (PsycParseState *state)
{ {
return state->cursor; return state->cursor;
} }
static inline size_t inline size_t
psyc_parse_buffer_length (PsycParseState *state) psyc_parse_buffer_length (PsycParseState *state)
{ {
return state->buffer.length; return state->buffer.length;
} }
static inline size_t inline size_t
psyc_parse_remaining_length (PsycParseState *state) psyc_parse_remaining_length (PsycParseState *state)
{ {
return state->buffer.length - state->cursor; return state->buffer.length - state->cursor;
} }
static inline const char * inline const char *
psyc_parse_remaining_buffer (PsycParseState *state) psyc_parse_remaining_buffer (PsycParseState *state)
{ {
return state->buffer.data + state->cursor; return state->buffer.data + state->cursor;
@ -687,7 +687,7 @@ psyc_parse_remaining_buffer (PsycParseState *state)
* in case of the body it will point to the data. * in case of the body it will point to the data.
*/ */
#ifdef __INLINE_PSYC_PARSE #ifdef __INLINE_PSYC_PARSE
static inline inline
#endif #endif
PsycParseRC PsycParseRC
psyc_parse (PsycParseState *state, char *oper, psyc_parse (PsycParseState *state, char *oper,
@ -705,30 +705,30 @@ psyc_parse (PsycParseState *state, char *oper,
* @param elem It will point to the next element in the list. * @param elem It will point to the next element in the list.
*/ */
#ifdef __INLINE_PSYC_PARSE #ifdef __INLINE_PSYC_PARSE
static inline inline
#endif #endif
PsycParseListRC PsycParseListRC
psyc_parse_list (PsycParseListState *state, PsycString *type, PsycString *elem); psyc_parse_list (PsycParseListState *state, PsycString *type, PsycString *elem);
#ifdef __INLINE_PSYC_PARSE #ifdef __INLINE_PSYC_PARSE
static inline inline
#endif #endif
PsycParseDictRC PsycParseDictRC
psyc_parse_dict (PsycParseDictState *state, PsycString *type, PsycString *elem); psyc_parse_dict (PsycParseDictState *state, PsycString *type, PsycString *elem);
#ifdef __INLINE_PSYC_PARSE #ifdef __INLINE_PSYC_PARSE
static inline inline
#endif #endif
PsycParseIndexRC PsycParseIndexRC
psyc_parse_index (PsycParseIndexState *state, PsycString *idx); psyc_parse_index (PsycParseIndexState *state, PsycString *idx);
#ifdef __INLINE_PSYC_PARSE #ifdef __INLINE_PSYC_PARSE
static inline inline
#endif #endif
PsycParseUpdateRC PsycParseUpdateRC
psyc_parse_update (PsycParseUpdateState *state, char *oper, PsycString *value); psyc_parse_update (PsycParseUpdateState *state, char *oper, PsycString *value);
static inline size_t inline size_t
psyc_parse_int (const char *value, size_t len, int64_t *n) psyc_parse_int (const char *value, size_t len, int64_t *n)
{ {
size_t c = 0; size_t c = 0;
@ -753,7 +753,7 @@ psyc_parse_int (const char *value, size_t len, int64_t *n)
return c; return c;
} }
static inline size_t inline size_t
psyc_parse_uint (const char *value, size_t len, uint64_t *n) psyc_parse_uint (const char *value, size_t len, uint64_t *n)
{ {
size_t c = 0; size_t c = 0;
@ -767,7 +767,7 @@ psyc_parse_uint (const char *value, size_t len, uint64_t *n)
return c; return c;
} }
static inline size_t inline size_t
psyc_parse_list_index (const char *value, size_t len, int64_t *n) psyc_parse_list_index (const char *value, size_t len, int64_t *n)
{ {
if (!value || len == 0 || value[0] != '#') if (!value || len == 0 || value[0] != '#')
@ -779,7 +779,7 @@ psyc_parse_list_index (const char *value, size_t len, int64_t *n)
* Determines if the argument is a glyph. * Determines if the argument is a glyph.
* Glyphs are: : = + - ? ! * Glyphs are: : = + - ? !
*/ */
static inline PsycBool inline PsycBool
psyc_is_oper (char g) psyc_is_oper (char g)
{ {
switch (g) { switch (g) {
@ -799,7 +799,7 @@ psyc_is_oper (char g)
/** /**
* Determines if the argument is numeric. * Determines if the argument is numeric.
*/ */
static inline char inline char
psyc_is_numeric (char c) psyc_is_numeric (char c)
{ {
return c >= '0' && c <= '9'; return c >= '0' && c <= '9';
@ -808,7 +808,7 @@ psyc_is_numeric (char c)
/** /**
* Determines if the argument is alphabetic. * Determines if the argument is alphabetic.
*/ */
static inline char inline char
psyc_is_alpha (char c) psyc_is_alpha (char c)
{ {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
@ -817,7 +817,7 @@ psyc_is_alpha (char c)
/** /**
* Determines if the argument is alphanumeric. * Determines if the argument is alphanumeric.
*/ */
static inline char inline char
psyc_is_alpha_numeric (char c) psyc_is_alpha_numeric (char c)
{ {
return psyc_is_alpha(c) || psyc_is_numeric(c); return psyc_is_alpha(c) || psyc_is_numeric(c);
@ -827,7 +827,7 @@ psyc_is_alpha_numeric (char c)
* Determines if the argument is a keyword character. * Determines if the argument is a keyword character.
* Keyword characters are: alphanumeric and _ * Keyword characters are: alphanumeric and _
*/ */
static inline char inline char
psyc_is_kw_char (char c) psyc_is_kw_char (char c)
{ {
return psyc_is_alpha_numeric(c) || c == '_'; return psyc_is_alpha_numeric(c) || c == '_';
@ -837,7 +837,7 @@ psyc_is_kw_char (char c)
* Determines if the argument is a name character. * Determines if the argument is a name character.
* Name characters are: see opaque_part in RFC 2396 * Name characters are: see opaque_part in RFC 2396
*/ */
static inline char inline char
psyc_is_name_char (char c) psyc_is_name_char (char c)
{ {
return psyc_is_alpha(c) || (c >= '$' && c <= ';') return psyc_is_alpha(c) || (c >= '$' && c <= ';')
@ -848,7 +848,7 @@ psyc_is_name_char (char c)
* Determines if the argument is a hostname character. * Determines if the argument is a hostname character.
* Hostname characters are: alphanumeric and - * Hostname characters are: alphanumeric and -
*/ */
static inline char inline char
psyc_is_host_char (char c) psyc_is_host_char (char c)
{ {
return psyc_is_alpha_numeric(c) || c == '.' || c == '-'; return psyc_is_alpha_numeric(c) || c == '.' || c == '-';
@ -859,7 +859,7 @@ psyc_is_host_char (char c)
* It should contain one or more keyword characters. * It should contain one or more keyword characters.
* @return Number of characters parsed. * @return Number of characters parsed.
*/ */
static inline size_t inline size_t
psyc_parse_keyword (const char *data, size_t len) psyc_parse_keyword (const char *data, size_t len)
{ {
size_t c = 0; size_t c = 0;

View file

@ -66,7 +66,7 @@ typedef enum {
* @see psyc_packet_length_set() * @see psyc_packet_length_set()
*/ */
#ifdef __INLINE_PSYC_RENDER #ifdef __INLINE_PSYC_RENDER
static inline inline
#endif #endif
PsycRenderRC PsycRenderRC
psyc_render (PsycPacket *packet, char *buffer, size_t buflen); psyc_render (PsycPacket *packet, char *buffer, size_t buflen);
@ -84,7 +84,7 @@ psyc_render_dict_key (PsycDictKey *elem, char *buffer, size_t buflen);
* Render a PSYC list into a buffer. * Render a PSYC list into a buffer.
*/ */
#ifdef __INLINE_PSYC_RENDER #ifdef __INLINE_PSYC_RENDER
static inline inline
#endif #endif
PsycRenderRC PsycRenderRC
psyc_render_list (PsycList *list, char *buffer, size_t buflen); psyc_render_list (PsycList *list, char *buffer, size_t buflen);

View file

@ -94,7 +94,7 @@ typedef PsycTextValueRC (*PsycTextCB) (void *cls, const char *name, size_t namel
* @param buffer Output buffer where the rendered text is going to be written. * @param buffer Output buffer where the rendered text is going to be written.
* @param buflen Length of output buffer. * @param buflen Length of output buffer.
*/ */
static inline void inline void
psyc_text_state_init (PsycTextState *state, psyc_text_state_init (PsycTextState *state,
char *tmpl, size_t tmplen, char *tmpl, size_t tmplen,
char *buffer, size_t buflen) char *buffer, size_t buflen)
@ -120,7 +120,7 @@ psyc_text_state_init (PsycTextState *state,
* @param clo Closing brace. * @param clo Closing brace.
* @param clolen Length of closing brace. * @param clolen Length of closing brace.
*/ */
static inline void inline void
psyc_text_state_init_custom (PsycTextState *state, psyc_text_state_init_custom (PsycTextState *state,
char *tmpl, size_t tmplen, char *tmpl, size_t tmplen,
char *buffer, size_t buflen, char *buffer, size_t buflen,
@ -138,7 +138,7 @@ psyc_text_state_init_custom (PsycTextState *state,
/** /**
* Sets a new output buffer in the PSYC text state struct. * Sets a new output buffer in the PSYC text state struct.
*/ */
static inline void inline void
psyc_text_buffer_set (PsycTextState *state, char *buffer, size_t length) psyc_text_buffer_set (PsycTextState *state, char *buffer, size_t length)
{ {
state->buffer = (PsycString) { state->buffer = (PsycString) {
@ -146,7 +146,7 @@ psyc_text_buffer_set (PsycTextState *state, char *buffer, size_t length)
state->written = 0; state->written = 0;
} }
static inline size_t inline size_t
psyc_text_bytes_written (PsycTextState *state) psyc_text_bytes_written (PsycTextState *state)
{ {
return state->written; return state->written;

View file

@ -112,7 +112,7 @@ psyc_uniform_parse (PsycUniform *uni, const char *buffer, size_t length);
* *
* @return PsycEntityType on success, PSYC_ERROR on error. * @return PsycEntityType on success, PSYC_ERROR on error.
*/ */
static inline int inline int
psyc_entity_type (char entity) psyc_entity_type (char entity)
{ {
switch (entity) { switch (entity) {

View file

@ -88,7 +88,7 @@ typedef enum {
/** /**
* Look up routing variable. * Look up routing variable.
*/ */
static inline PsycRoutingVar inline PsycRoutingVar
psyc_var_routing (const char *name, size_t len) psyc_var_routing (const char *name, size_t len)
{ {
return (PsycRoutingVar) return (PsycRoutingVar)
@ -99,7 +99,7 @@ psyc_var_routing (const char *name, size_t len)
/** /**
* Get the type of variable name. * Get the type of variable name.
*/ */
static inline PsycType inline PsycType
psyc_var_type (const char *name, size_t len) psyc_var_type (const char *name, size_t len)
{ {
return (PsycType) return (PsycType)
@ -110,7 +110,7 @@ psyc_var_type (const char *name, size_t len)
/** /**
* Is this a list variable name? * Is this a list variable name?
*/ */
static inline PsycBool inline PsycBool
psyc_var_is_list (const char *name, size_t len) psyc_var_is_list (const char *name, size_t len)
{ {
return len < 5 || memcmp(name, "_list", 5) != 0 || (len > 5 && name[5] != '_') return len < 5 || memcmp(name, "_list", 5) != 0 || (len > 5 && name[5] != '_')

View file

@ -166,6 +166,10 @@ psyc_map_lookup(const PsycMap * map, size_t size,
return NULL; return NULL;
} }
extern inline intptr_t
psyc_map_lookup_int (const PsycMapInt *map, size_t size,
const char *key, size_t keylen, PsycBool inherit);
#ifdef CMDTOOL #ifdef CMDTOOL
int int
main(int argc, char **argv) main(int argc, char **argv)

View file

@ -21,6 +21,17 @@
#include "lib.h" #include "lib.h"
#include <psyc/packet.h> #include <psyc/packet.h>
extern inline size_t
psyc_num_length (size_t n);
extern inline PsycModifierFlag
psyc_modifier_length_check (PsycModifier *m);
extern inline void
psyc_modifier_init (PsycModifier *m, PsycOperator oper,
char *name, size_t namelen,
char *value, size_t valuelen, PsycModifierFlag flag);
inline PsycElemFlag inline PsycElemFlag
psyc_elem_length_check (PsycString *value, const char end) psyc_elem_length_check (PsycString *value, const char end)
{ {

View file

@ -53,6 +53,65 @@ typedef struct {
size_t startc; size_t startc;
} ParseState; } ParseState;
extern inline void
psyc_parse_state_init (PsycParseState *state, uint8_t flags);
extern inline void
psyc_parse_buffer_set (PsycParseState *state, const char *buffer, size_t length);
extern inline void
psyc_parse_list_state_init (PsycParseListState *state);
extern inline void
psyc_parse_list_buffer_set (PsycParseListState *state,
const char *buffer, size_t length);
extern inline void
psyc_parse_dict_state_init (PsycParseDictState *state);
extern inline void
psyc_parse_dict_buffer_set (PsycParseDictState *state,
const char *buffer, size_t length);
extern inline void
psyc_parse_index_state_init (PsycParseIndexState *state);
extern inline void
psyc_parse_index_buffer_set (PsycParseIndexState *state,
const char *buffer, size_t length);
extern inline void
psyc_parse_update_state_init (PsycParseUpdateState *state);
extern inline void
psyc_parse_update_buffer_set (PsycParseUpdateState *state,
const char *buffer, size_t length);
extern inline size_t
psyc_parse_content_length (PsycParseState *state);
extern inline PsycBool
psyc_parse_content_length_found (PsycParseState *state);
extern inline size_t
psyc_parse_value_length (PsycParseState *state);
extern inline PsycBool
psyc_parse_value_length_found (PsycParseState *state);
extern inline size_t
psyc_parse_cursor (PsycParseState *state);
extern inline size_t
psyc_parse_buffer_length (PsycParseState *state);
extern inline size_t
psyc_parse_remaining_length (PsycParseState *state);
extern inline const char *
psyc_parse_remaining_buffer (PsycParseState *state);
/** /**
* Parse variable name or method name. * Parse variable name or method name.
* *
@ -155,7 +214,10 @@ parse_until (ParseState *state, const char end, PsycString *value)
* Parse simple or binary variable. * Parse simple or binary variable.
* @return PARSE_ERROR or PARSE_SUCCESS * @return PARSE_ERROR or PARSE_SUCCESS
*/ */
static inline ParseRC #ifdef __INLINE_PSYC_PARSE
extern inline
#endif
ParseRC
psyc_parse_modifier (PsycParseState *state, char *oper, psyc_parse_modifier (PsycParseState *state, char *oper,
PsycString *name, PsycString *value) PsycString *name, PsycString *value)
{ {
@ -504,7 +566,7 @@ psyc_parse (PsycParseState *state, char *oper,
* list-value = %x00-7B / %x7D-FF ; any byte except "|" * list-value = %x00-7B / %x7D-FF ; any byte except "|"
*/ */
#ifdef __INLINE_PSYC_PARSE #ifdef __INLINE_PSYC_PARSE
static inline extern inline
#endif #endif
PsycParseListRC PsycParseListRC
psyc_parse_list (PsycParseListState *state, PsycString *type, PsycString *elem) psyc_parse_list (PsycParseListState *state, PsycString *type, PsycString *elem)
@ -664,6 +726,9 @@ psyc_parse_list (PsycParseListState *state, PsycString *type, PsycString *elem)
* dict-key = %x00-7C / %x7E-FF ; any byte except "{" * dict-key = %x00-7C / %x7E-FF ; any byte except "{"
* dict-value = %x00-7A / %x7C-FF ; any byte except "}" * dict-value = %x00-7A / %x7C-FF ; any byte except "}"
*/ */
#ifdef __INLINE_PSYC_PARSE
extern inline
#endif
PsycParseDictRC PsycParseDictRC
psyc_parse_dict (PsycParseDictState *state, PsycString *type, PsycString *elem) psyc_parse_dict (PsycParseDictState *state, PsycString *type, PsycString *elem)
{ {
@ -886,7 +951,7 @@ psyc_parse_dict (PsycParseDictState *state, PsycString *type, PsycString *elem)
} }
#ifdef __INLINE_PSYC_PARSE #ifdef __INLINE_PSYC_PARSE
static inline extern inline
#endif #endif
PsycParseIndexRC PsycParseIndexRC
psyc_parse_index (PsycParseIndexState *state, PsycString *idx) psyc_parse_index (PsycParseIndexState *state, PsycString *idx)
@ -1014,7 +1079,7 @@ psyc_parse_index (PsycParseIndexState *state, PsycString *idx)
} }
#ifdef __INLINE_PSYC_PARSE #ifdef __INLINE_PSYC_PARSE
static inline extern inline
#endif #endif
PsycParseUpdateRC PsycParseUpdateRC
psyc_parse_update (PsycParseUpdateState *state, char *oper, PsycString *value) psyc_parse_update (PsycParseUpdateState *state, char *oper, PsycString *value)
@ -1146,3 +1211,37 @@ psyc_parse_update (PsycParseUpdateState *state, char *oper, PsycString *value)
return PSYC_PARSE_INDEX_ERROR; // should not be reached return PSYC_PARSE_INDEX_ERROR; // should not be reached
} }
extern inline size_t
psyc_parse_int (const char *value, size_t len, int64_t *n);
extern inline size_t
psyc_parse_uint (const char *value, size_t len, uint64_t *n);
extern inline size_t
psyc_parse_list_index (const char *value, size_t len, int64_t *n);
extern inline PsycBool
psyc_is_oper (char g);
extern inline char
psyc_is_numeric (char c);
extern inline char
psyc_is_alpha (char c);
extern inline char
psyc_is_alpha_numeric (char c);
extern inline char
psyc_is_kw_char (char c);
extern inline char
psyc_is_name_char (char c);
extern inline char
psyc_is_host_char (char c);
extern inline size_t
psyc_parse_keyword (const char *data, size_t len);

View file

@ -78,7 +78,7 @@ psyc_render_dict_key (PsycDictKey *elem, char *buffer, size_t buflen)
} }
#ifdef __INLINE_PSYC_RENDER #ifdef __INLINE_PSYC_RENDER
static inline extern inline
#endif #endif
PsycRenderRC PsycRenderRC
psyc_render_list (PsycList *list, char *buffer, size_t buflen) psyc_render_list (PsycList *list, char *buffer, size_t buflen)
@ -162,7 +162,7 @@ psyc_render_modifier (PsycModifier *mod, char *buffer)
} }
#ifdef __INLINE_PSYC_RENDER #ifdef __INLINE_PSYC_RENDER
static inline extern inline
#endif #endif
PsycRenderRC PsycRenderRC
psyc_render (PsycPacket *p, char *buffer, size_t buflen) psyc_render (PsycPacket *p, char *buffer, size_t buflen)

View file

@ -25,6 +25,24 @@ const PsycTemplates psyc_templates = { .s = {
#include "templates.h" #include "templates.h"
}}; }};
extern inline void
psyc_text_state_init (PsycTextState *state,
char *tmpl, size_t tmplen,
char *buffer, size_t buflen);
extern inline void
psyc_text_state_init_custom (PsycTextState *state,
char *tmpl, size_t tmplen,
char *buffer, size_t buflen,
char *ope, size_t opelen,
char *clo, size_t clolen);
extern inline void
psyc_text_buffer_set (PsycTextState *state, char *buffer, size_t length);
extern inline size_t
psyc_text_bytes_written (PsycTextState *state);
PsycTextRC PsycTextRC
psyc_text (PsycTextState *state, PsycTextCB get_value, void *get_value_cls) psyc_text (PsycTextState *state, PsycTextCB get_value, void *get_value_cls)
{ {

View file

@ -195,3 +195,6 @@ psyc_uniform_parse (PsycUniform *uni, const char *buffer, size_t length)
uni->valid = 1; uni->valid = 1;
return uni->type; return uni->type;
} }
extern inline int
psyc_entity_type (char entity);

View file

@ -104,6 +104,15 @@ const PsycMapInt psyc_methods[] = {
}; };
const size_t psyc_methods_num = PSYC_NUM_ELEM(psyc_methods); const size_t psyc_methods_num = PSYC_NUM_ELEM(psyc_methods);
extern inline PsycRoutingVar
psyc_var_routing (const char *name, size_t len);
extern inline PsycType
psyc_var_type (const char *name, size_t len);
extern inline PsycBool
psyc_var_is_list (const char *name, size_t len);
/** /**
* Get the method, its family and its flags. * Get the method, its family and its flags.
*/ */