forked from loafle/openapi-generator-original
[C][Client] Define and initialize non-primitive variables at the beginning of function (#10756)
This commit is contained in:
parent
40018c333d
commit
369133a03e
@ -527,6 +527,17 @@ fail:
|
||||
|
||||
{{classname}}_t *{{classname}}_local_var = NULL;
|
||||
|
||||
{{#vars}}
|
||||
{{^isPrimitiveType}}
|
||||
{{#isModel}}
|
||||
{{^isEnum}}
|
||||
// define the local variable for {{{classname}}}->{{{name}}}
|
||||
{{^isFreeFormObject}}{{complexType}}{{/isFreeFormObject}}{{#isFreeFormObject}}object{{/isFreeFormObject}}_t *{{name}}_local_nonprim = NULL;
|
||||
|
||||
{{/isEnum}}
|
||||
{{/isModel}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/vars}}
|
||||
{{#vars}}
|
||||
// {{{classname}}}->{{{name}}}
|
||||
cJSON *{{{name}}} = cJSON_GetObjectItemCaseSensitive({{classname}}JSON, "{{{baseName}}}");
|
||||
@ -614,7 +625,6 @@ fail:
|
||||
{{{name}}}_local_nonprim_enum = {{datatypeWithEnum}}_parseFromJSON({{{name}}}); //enum model
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{^isFreeFormObject}}{{complexType}}{{/isFreeFormObject}}{{#isFreeFormObject}}object{{/isFreeFormObject}}_t *{{name}}_local_nonprim = NULL;
|
||||
{{^required}}if ({{{name}}}) { {{/required}}
|
||||
{{{name}}}_local_nonprim = {{complexType}}{{#isFreeFormObject}}object{{/isFreeFormObject}}_parseFromJSON({{{name}}}); //nonprimitive
|
||||
{{/isEnum}}
|
||||
|
@ -168,6 +168,9 @@ pet_t *pet_parseFromJSON(cJSON *petJSON){
|
||||
|
||||
pet_t *pet_local_var = NULL;
|
||||
|
||||
// define the local variable for pet->category
|
||||
category_t *category_local_nonprim = NULL;
|
||||
|
||||
// pet->id
|
||||
cJSON *id = cJSON_GetObjectItemCaseSensitive(petJSON, "id");
|
||||
if (id) {
|
||||
@ -179,7 +182,6 @@ pet_t *pet_parseFromJSON(cJSON *petJSON){
|
||||
|
||||
// pet->category
|
||||
cJSON *category = cJSON_GetObjectItemCaseSensitive(petJSON, "category");
|
||||
category_t *category_local_nonprim = NULL;
|
||||
if (category) {
|
||||
category_local_nonprim = category_parseFromJSON(category); //nonprimitive
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user