Skip to content

Commit

Permalink
Revert "fix variable length array error for emit_go.c"
Browse files Browse the repository at this point in the history
This reverts commit 6e5da12.
  • Loading branch information
gustafj committed Feb 10, 2020
1 parent 71c2426 commit 657d3fc
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lcmgen/emit_go.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,16 +321,19 @@ static char *go_membername(lcm_struct_t *ls, const char *const str, int method)
{
char *membername = go_name(str);

// expose all fields because the field value is inside the real data
membername[0] = toupper(membername[0]);
if (method) {
if (lcm_find_member_with_named_dimension(ls, str, 0) >= ls->members->len) {
// If not a read-only attribute, uppercase it to export it.
membername[0] = toupper(membername[0]);
} else if (method) {
// If read-only should be method invocation.
size_t len = strlen(membername);
membername = realloc(membername, len + 6);
// add Get at the end to distinguish between field name and method
strcat(membername, "Get()");
membername[len+5] = '\0';
membername = realloc(membername, len + 3);
membername[0] = toupper(membername[0]);
membername[len++] = '(';
membername[len++] = ')';
membername[len++] = '\0';
}

return membername;
}

Expand Down Expand Up @@ -566,12 +569,9 @@ static unsigned int emit_go_array_loops(FILE *f, lcmgen_t *lcm, lcm_struct_t *ls
const char *type =
map_builtintype_name(lcm_find_member(ls, dim->size)->type->lctypename);

if (slice_emit){
lcm_struct_t *ls_lm = lcm_find_struct(lcm, lm);
uint64_t lm_fingerprint = lcm_get_fingerprint(lcm, ls_lm);
if (slice_emit)
emit_go_slice_make(f, n + 1, ls->structname->package, lm, n, slicestr->str, size,
lm_fingerprint);
}
fingerprint);

emit(1 + n, "for i%d := %s(0); i%d < p.%s; i%d++ {", n, type, n, size, n);

Expand Down Expand Up @@ -949,7 +949,7 @@ static void emit_go_lcm_read_only_getters(FILE *f, lcmgen_t *lcm, lcm_struct_t *
for (; i < ls->members->len;
i = lcm_find_member_with_named_dimension(ls, lm->membername, i + 1)) {
lcm_member_t *lm_ = (lcm_member_t *) g_ptr_array_index(ls->members, i);
char *membername = go_membername(ls, lm_->membername, FALSE);
char *membername = go_membername(ls, lm_->membername, TRUE);

unsigned int j = lcm_find_named_dimension(f, ls, lm_, lm->membername, 0);

Expand Down

0 comments on commit 657d3fc

Please sign in to comment.