Skip to content

Commit

Permalink
Fix more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Dec 5, 2024
1 parent 56060c6 commit d591930
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 33 deletions.
17 changes: 10 additions & 7 deletions distr/flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -7313,6 +7313,7 @@ int flecs_traverse_add(
ecs_vec_fini_t(&world->allocator, &ids, ecs_id_t);
return 0;
error:
flecs_table_diff_builder_fini(world, &diff);
ecs_vec_fini_t(&world->allocator, &ids, ecs_id_t);
return -1;
}
Expand Down Expand Up @@ -48061,7 +48062,6 @@ int flecs_meta_cursor_push_type(
if (ser == NULL) {
char *str = ecs_id_str(world, type);
ecs_err("cannot open scope for '%s' (missing reflection data)", str);
ecs_abort(ECS_INTERNAL_ERROR, NULL);
ecs_os_free(str);
return -1;
}
Expand Down Expand Up @@ -55322,7 +55322,8 @@ char* ecs_script_string_interpolate(

/* Definitions for parser functions */
#define ParserBegin\
ecs_script_tokenizer_t _tokenizer = {{0}};\
ecs_script_tokenizer_t _tokenizer;\
ecs_os_zeromem(&_tokenizer);\
_tokenizer.tokens = _tokenizer.stack.tokens;\
ecs_script_tokenizer_t *tokenizer = &_tokenizer;

Expand Down Expand Up @@ -58823,7 +58824,6 @@ const char* flecs_script_multiline_string(
const char *end = pos + 1;
while ((ch = end[0]) && (ch != '`')) {
if (ch == '\\' && end[1] == '`') {
ch = '`';
end ++;
}
end ++;
Expand Down Expand Up @@ -73689,7 +73689,7 @@ const char* flecs_script_parse_initializer(
LookAhead(
case ')':
case '}': {
if (lookahead_token.kind != until) {
if ((char)lookahead_token.kind != until) {
Error("expected '%c'", until);
}
node->node.kind = EcsExprEmptyInitializer;
Expand Down Expand Up @@ -73728,7 +73728,7 @@ const char* flecs_script_parse_initializer(
case '\n':
case ')':
case '}': {
if (lookahead_token.kind != until) {
if ((char)lookahead_token.kind != until) {
Error("expected '%c'", until);
}
EndOfRule;
Expand Down Expand Up @@ -74781,6 +74781,11 @@ int flecs_expr_variable_visit_eval(
ecs_expr_variable_t *node,
ecs_expr_value_t *out)
{
ecs_assert(ctx->desc != NULL, ECS_INVALID_OPERATION,
"variables available at parse time are not provided");
ecs_assert(ctx->desc->vars != NULL, ECS_INVALID_OPERATION,
"variables available at parse time are not provided");

const ecs_script_var_t *var = ecs_script_vars_lookup(
ctx->desc->vars, node->name);
if (!var) {
Expand Down Expand Up @@ -75968,7 +75973,6 @@ int flecs_expr_node_to_str(
break;
default:
ecs_abort(ECS_INTERNAL_ERROR, "invalid node kind");
break;
}

if (node->type) {
Expand Down Expand Up @@ -76906,7 +76910,6 @@ int flecs_script_expr_visit_type_priv(
case EcsExprComponent:
/* Component expressions are derived by type visitor */
ecs_abort(ECS_INTERNAL_ERROR, NULL);
break;
}

ecs_assert(node->type != 0, ECS_INTERNAL_ERROR, NULL);
Expand Down
18 changes: 9 additions & 9 deletions distr/flecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -14624,17 +14624,17 @@ void ecs_script_vars_from_iter(

/** Used with ecs_script_expr_run(). */
typedef struct ecs_script_expr_run_desc_t {
const char *name;
const char *expr;
ecs_entity_t (*lookup_action)(
const char *name; /**< Script name */
const char *expr; /**< Full expression string */
ecs_entity_t (*lookup_action)( /**< Function for resolving entity identifiers */
const ecs_world_t*,
const char *value,
void *ctx);
void *lookup_ctx;
ecs_script_vars_t *vars;
ecs_entity_t type;
bool disable_folding;
ecs_script_runtime_t *runtime;
void *lookup_ctx; /**< Context passed to lookup function */
ecs_script_vars_t *vars; /**< Variables accessible in expression */
ecs_entity_t type; /**< Type of parsed value (optional) */
bool disable_folding; /**< Disable constant folding (slower evaluation, faster parsing) */
ecs_script_runtime_t *runtime; /**< Reusable runtime (optional) */
} ecs_script_expr_run_desc_t;

/** Run expression.
Expand Down Expand Up @@ -14670,7 +14670,7 @@ const char* ecs_script_expr_run(
FLECS_API
ecs_script_t* ecs_script_expr_parse(
ecs_world_t *world,
const char *ptr,
const char *expr,
const ecs_script_expr_run_desc_t *desc);

/** Evaluate expression.
Expand Down
18 changes: 9 additions & 9 deletions include/flecs/addons/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,17 +445,17 @@ void ecs_script_vars_from_iter(

/** Used with ecs_script_expr_run(). */
typedef struct ecs_script_expr_run_desc_t {
const char *name;
const char *expr;
ecs_entity_t (*lookup_action)(
const char *name; /**< Script name */
const char *expr; /**< Full expression string */
ecs_entity_t (*lookup_action)( /**< Function for resolving entity identifiers */
const ecs_world_t*,
const char *value,
void *ctx);
void *lookup_ctx;
ecs_script_vars_t *vars;
ecs_entity_t type;
bool disable_folding;
ecs_script_runtime_t *runtime;
void *lookup_ctx; /**< Context passed to lookup function */
ecs_script_vars_t *vars; /**< Variables accessible in expression */
ecs_entity_t type; /**< Type of parsed value (optional) */
bool disable_folding; /**< Disable constant folding (slower evaluation, faster parsing) */
ecs_script_runtime_t *runtime; /**< Reusable runtime (optional) */
} ecs_script_expr_run_desc_t;

/** Run expression.
Expand Down Expand Up @@ -491,7 +491,7 @@ const char* ecs_script_expr_run(
FLECS_API
ecs_script_t* ecs_script_expr_parse(
ecs_world_t *world,
const char *ptr,
const char *expr,
const ecs_script_expr_run_desc_t *desc);

/** Evaluate expression.
Expand Down
11 changes: 10 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ flecs_src = files(
'src/addons/rest.c',
'src/addons/script/template.c',
'src/addons/script/ast.c',
'src/addons/script/expr.c',
'src/addons/script/builtin_functions.c',
'src/addons/script/interpolate.c',
'src/addons/script/parser.c',
'src/addons/script/query_parser.c',
Expand All @@ -71,6 +71,15 @@ flecs_src = files(
'src/addons/script/visit_free.c',
'src/addons/script/visit_to_str.c',
'src/addons/script/visit.c',
'src/addons/script/expr/ast.c',
'src/addons/script/expr/parser.c',
'src/addons/script/expr/stack.c',
'src/addons/script/expr/util.c',
'src/addons/script/expr/visit_eval.c',
'src/addons/script/expr/visit_fold.c',
'src/addons/script/expr/visit_free.c',
'src/addons/script/expr/visit_to_str.c',
'src/addons/script/expr/visit_type.c',
'src/addons/system/system.c',
'src/addons/timer.c',
'src/addons/units.c',
Expand Down
1 change: 0 additions & 1 deletion src/addons/meta/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ int flecs_meta_cursor_push_type(
if (ser == NULL) {
char *str = ecs_id_str(world, type);
ecs_err("cannot open scope for '%s' (missing reflection data)", str);
ecs_abort(ECS_INTERNAL_ERROR, NULL);
ecs_os_free(str);
return -1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/addons/script/expr/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const char* flecs_script_parse_initializer(
LookAhead(
case ')':
case '}': {
if (lookahead_token.kind != until) {
if ((char)lookahead_token.kind != until) {
Error("expected '%c'", until);
}
node->node.kind = EcsExprEmptyInitializer;
Expand Down Expand Up @@ -130,7 +130,7 @@ const char* flecs_script_parse_initializer(
case '\n':
case ')':
case '}': {
if (lookahead_token.kind != until) {
if ((char)lookahead_token.kind != until) {
Error("expected '%c'", until);
}
EndOfRule;
Expand Down
5 changes: 5 additions & 0 deletions src/addons/script/expr/visit_eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ int flecs_expr_variable_visit_eval(
ecs_expr_variable_t *node,
ecs_expr_value_t *out)
{
ecs_assert(ctx->desc != NULL, ECS_INVALID_OPERATION,
"variables available at parse time are not provided");
ecs_assert(ctx->desc->vars != NULL, ECS_INVALID_OPERATION,
"variables available at parse time are not provided");

const ecs_script_var_t *var = ecs_script_vars_lookup(
ctx->desc->vars, node->name);
if (!var) {
Expand Down
1 change: 0 additions & 1 deletion src/addons/script/expr/visit_to_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ int flecs_expr_node_to_str(
break;
default:
ecs_abort(ECS_INTERNAL_ERROR, "invalid node kind");
break;
}

if (node->type) {
Expand Down
1 change: 0 additions & 1 deletion src/addons/script/expr/visit_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,6 @@ int flecs_script_expr_visit_type_priv(
case EcsExprComponent:
/* Component expressions are derived by type visitor */
ecs_abort(ECS_INTERNAL_ERROR, NULL);
break;
}

ecs_assert(node->type != 0, ECS_INTERNAL_ERROR, NULL);
Expand Down
3 changes: 2 additions & 1 deletion src/addons/script/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@

/* Definitions for parser functions */
#define ParserBegin\
ecs_script_tokenizer_t _tokenizer = {{0}};\
ecs_script_tokenizer_t _tokenizer;\
ecs_os_zeromem(&_tokenizer);\
_tokenizer.tokens = _tokenizer.stack.tokens;\
ecs_script_tokenizer_t *tokenizer = &_tokenizer;

Expand Down
1 change: 0 additions & 1 deletion src/addons/script/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ const char* flecs_script_multiline_string(
const char *end = pos + 1;
while ((ch = end[0]) && (ch != '`')) {
if (ch == '\\' && end[1] == '`') {
ch = '`';
end ++;
}
end ++;
Expand Down
1 change: 1 addition & 0 deletions src/entity.c
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,7 @@ int flecs_traverse_add(
ecs_vec_fini_t(&world->allocator, &ids, ecs_id_t);
return 0;
error:
flecs_table_diff_builder_fini(world, &diff);
ecs_vec_fini_t(&world->allocator, &ids, ecs_id_t);
return -1;
}
Expand Down

0 comments on commit d591930

Please sign in to comment.