c++ compat

This commit is contained in:
Gabor Adam Toth 2012-02-21 03:00:52 +01:00
parent 89b1466d58
commit 6bc4dbb8cc
5 changed files with 28 additions and 14 deletions

View File

@ -17,6 +17,14 @@
#ifndef PSYC_H
#define PSYC_H
#ifdef __cplusplus
extern "C"
{
#if 0 /* keep Emacsens' auto-indent happy */
}
#endif
#endif
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
@ -72,4 +80,11 @@ typedef struct {
#include "psyc/text.h"
#include "psyc/uniform.h"
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -45,8 +45,8 @@ psyc_map_lookup (const PsycMap *map, size_t size,
* @see psyc_map_lookup
*/
static inline intptr_t
psyc_map_lookup_int (const PsycMapInt * map, size_t size,
const char *key, size_t keylen, PsycBool inherit)
psyc_map_lookup_int (const PsycMapInt *map, size_t size,
const char *key, size_t keylen, PsycBool inherit)
{
return (intptr_t) psyc_map_lookup((PsycMap *) map, size, key, keylen, inherit);
}

View File

@ -256,17 +256,15 @@ psyc_modifier_init (PsycModifier *m, PsycOperator oper,
char *name, size_t namelen,
char *value, size_t valuelen, PsycModifierFlag flag)
{
*m = (PsycModifier) {
.oper = oper,
.name = {namelen, name},
.value = {valuelen, value},
.flag = flag
};
m->oper = oper;
m->name = (PsycString){namelen, name};
m->value = (PsycString){valuelen, value};
m->flag = flag;
if (flag == PSYC_MODIFIER_CHECK_LENGTH) // find out if it needs a length
m->flag = psyc_modifier_length_check(m);
else if (flag & PSYC_MODIFIER_ROUTING)
m->flag |= PSYC_MODIFIER_NO_LENGTH;
m->flag = (PsycModifierFlag)(m->flag | PSYC_MODIFIER_NO_LENGTH);
}
/**

View File

@ -611,7 +611,7 @@ psyc_parse_content_length (PsycParseState *state)
static inline PsycBool
psyc_parse_content_length_found (PsycParseState *state)
{
return state->contentlen_found;
return (PsycBool) state->contentlen_found;
}
static inline size_t
@ -623,7 +623,7 @@ psyc_parse_value_length (PsycParseState *state)
static inline PsycBool
psyc_parse_value_length_found (PsycParseState *state)
{
return state->valuelen_found;
return (PsycBool) state->valuelen_found;
}
static inline size_t

View File

@ -72,7 +72,8 @@ static inline PsycRoutingVar
psyc_var_routing (const char *name, size_t len)
{
return (PsycRoutingVar)
psyc_map_lookup((PsycMap*)psyc_rvars, psyc_rvars_num, name, len, PSYC_NO);
psyc_map_lookup_int((PsycMapInt*)psyc_rvars, psyc_rvars_num, name, len,
PSYC_NO);
}
/**
@ -82,8 +83,8 @@ static inline PsycType
psyc_var_type (const char *name, size_t len)
{
return (PsycType)
psyc_map_lookup((PsycMap*)psyc_var_types, psyc_var_types_num,
name, len, PSYC_YES);
psyc_map_lookup_int((PsycMapInt*)psyc_var_types, psyc_var_types_num,
name, len, PSYC_YES);
}
/**