Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jer: Formatting enhancements #153

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion skeletons/BIT_STRING_jer.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ BIT_STRING_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
}
*p++ = '"';
ASN__CALLBACK(scratch, p - scratch);
ASN__TEXT_INDENT(1, ilevel - 1);

ASN__ENCODED_OK(er);
cb_failed:
Expand Down
6 changes: 5 additions & 1 deletion skeletons/constr_CHOICE_jer.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ CHOICE_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
(const asn_CHOICE_specifics_t *)td->specifics;
asn_enc_rval_t er = {0,0,0};
unsigned present = 0;
int xcan = 0;

if(!sptr)
ASN__ENCODE_FAILED;
Expand Down Expand Up @@ -298,13 +299,16 @@ CHOICE_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,

er.encoded = 0;

ASN__CALLBACK3("{\n\"", 3, mname, mlen, "\": ", 2);
ASN__CALLBACK("{",1);
if(!xcan) ASN__TEXT_INDENT(1, ilevel + 1);
ASN__CALLBACK3("\"", 1, mname, mlen, "\": ", 3);

tmper = elm->type->op->jer_encoder(elm->type, memb_ptr,
ilevel + 1, flags, cb, app_key);
if(tmper.encoded == -1) return tmper;
er.encoded += tmper.encoded;

if(!xcan) ASN__TEXT_INDENT(1, ilevel);
ASN__CALLBACK("}", 1);
}

Expand Down
3 changes: 2 additions & 1 deletion skeletons/constr_SEQUENCE_OF_jer.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SEQUENCE_OF_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
void *memb_ptr = list->array[i];
if(!memb_ptr) continue;

if(!xcan) ASN__TEXT_INDENT(1, ilevel + 1);
tmper = elm->type->op->jer_encoder(elm->type, memb_ptr, ilevel + 1,
flags, cb, app_key);
if(tmper.encoded == -1) return tmper;
Expand All @@ -44,7 +45,7 @@ SEQUENCE_OF_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr,
}
}

if(!xcan) ASN__TEXT_INDENT(1, ilevel - 1);
if(!xcan) ASN__TEXT_INDENT(1, ilevel);
ASN__CALLBACK("]", 1);

ASN__ENCODED_OK(er);
Expand Down
6 changes: 3 additions & 3 deletions skeletons/constr_SEQUENCE_jer.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ asn_enc_rval_t SEQUENCE_encode_jer(const asn_TYPE_descriptor_t *td, const void *
er.encoded = 0;

int bAddComma = 0;
ASN__CALLBACK("{\n", 2);
ASN__CALLBACK("{", 1);
for(edx = 0; edx < td->elements_count; edx++) {
asn_enc_rval_t tmper = {0,0,0};
asn_TYPE_member_t *elm = &td->elements[edx];
Expand Down Expand Up @@ -344,7 +344,7 @@ asn_enc_rval_t SEQUENCE_encode_jer(const asn_TYPE_descriptor_t *td, const void *
bAddComma = 0;
}

if(!xcan) ASN__TEXT_INDENT(1, ilevel);
if(!xcan) ASN__TEXT_INDENT(1, ilevel+1);
ASN__CALLBACK3("\"", 1, mname, mlen, "\": ", 3);

/* Print the member itself */
Expand All @@ -360,9 +360,9 @@ asn_enc_rval_t SEQUENCE_encode_jer(const asn_TYPE_descriptor_t *td, const void *
bAddComma = 1;
}
}
if(!xcan) ASN__TEXT_INDENT(1, ilevel);
ASN__CALLBACK("}", 1);

if(!xcan) ASN__TEXT_INDENT(1, ilevel - 1);

ASN__ENCODED_OK(er);
cb_failed:
Expand Down
5 changes: 2 additions & 3 deletions skeletons/constr_SET_OF_jer.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ SET_OF_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
encs_count++;
}

if(!xcan && specs->as_XMLValueList == 1)
ASN__TEXT_INDENT(1, ilevel + 1);
ASN__TEXT_INDENT(1, ilevel + 1);
tmper = elm->type->op->jer_encoder(elm->type, memb_ptr,
ilevel + (specs->as_XMLValueList != 2),
flags, cb, app_key);
Expand All @@ -273,7 +272,7 @@ SET_OF_encode_jer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
}
}

if(!xcan) ASN__TEXT_INDENT(1, ilevel - 1);
if(!xcan) ASN__TEXT_INDENT(1, ilevel);
ASN__CALLBACK("]", 1);

if(encs) {
Expand Down
2 changes: 1 addition & 1 deletion skeletons/jer_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jer_encode(const asn_TYPE_descriptor_t *td, const void *sptr,
if(!td || !sptr) goto cb_failed;

int xFail = 1; /* TODO JER flags */
tmper = td->op->jer_encoder(td, sptr, 1, xFail, cb, app_key);
tmper = td->op->jer_encoder(td, sptr, 0, xFail, cb, app_key);
if(tmper.encoded == -1) return tmper;
er.encoded += tmper.encoded;

Expand Down
Loading