added default returns to generated enum functions

main
Sara 2023-09-13 12:45:51 +02:00
parent 19deaea93e
commit e34a00086a
2 changed files with 4 additions and 0 deletions

View File

@ -196,6 +196,7 @@ int kwil_enum_generate_json_length(struct kwil_enum_t* self, FILE* file, const c
self->enum_values[option_index].name, strlen(self->enum_values[option_index].name)); self->enum_values[option_index].name, strlen(self->enum_values[option_index].name));
} }
fprintf(file, " }\\\n" fprintf(file, " }\\\n"
" return 2;\\\n"
"}\\\n"); "}\\\n");
return 0; return 0;
} }
@ -213,6 +214,7 @@ int kwil_enum_generate_to_json(struct kwil_enum_t* self, FILE* file, const char*
} }
fprintf(file, " }\\\n" fprintf(file, " }\\\n"
" return sprintf(out, \"\\\"\\\"\");\\\n"
"}\\\n"); "}\\\n");
return 0; return 0;
} }

View File

@ -6,6 +6,7 @@ size_t enum_A_json_length(enum enum_A* src) {\
case VALUE_B: return 7;\ case VALUE_B: return 7;\
case VALUE_C: return 7;\ case VALUE_C: return 7;\
}\ }\
return 2;\
}\ }\
size_t enum_A_to_json(enum enum_A* src, char* out) {\ size_t enum_A_to_json(enum enum_A* src, char* out) {\
switch(*src) {\ switch(*src) {\
@ -16,6 +17,7 @@ size_t enum_A_to_json(enum enum_A* src, char* out) {\
case VALUE_C:\ case VALUE_C:\
return sprintf(out, "\"VALUE_C\"");\ return sprintf(out, "\"VALUE_C\"");\
}\ }\
return sprintf(out, "\"\"");\
}\ }\
size_t struct_A_json_length(struct struct_A* src) {\ size_t struct_A_json_length(struct struct_A* src) {\
size_t json_capacity = 2;\ size_t json_capacity = 2;\