Skip to content

Commit

Permalink
Fix emit_go error (lcm-proj#294)
Browse files Browse the repository at this point in the history
* Add check if:
  - fingerprint suffix is requested, and
  - member is primitive type

If not, don't bother calling lcm_find_struct() when creating array
  • Loading branch information
hoxell committed Jan 10, 2020
1 parent 2357c6a commit 8066803
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ endif()
lcm_option(
LCM_ENABLE_GO
"Build Go utilities, bindings is source distributed"

# Disable until #294 is resolved
FALSE Go)
# GO_FOUND Go)
GO_FOUND Go)

option(LCM_ENABLE_TESTS "Build unit tests" ON)
if(LCM_ENABLE_TESTS)
Expand Down
17 changes: 14 additions & 3 deletions lcmgen/emit_go.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ uint64_t __lcm_recursive_fingerprint(lcmgen_t *lcm, lcm_struct_t *ls,
if (ls_ != NULL) {
fingerprint += __lcm_recursive_fingerprint(lcm, ls_, &fp);
} else {
fprintf(stderr, "Unable to locate fingerprint for member '%s' of '%s'\n",
fprintf(stderr, "Unable to locate fingerprint for member '%s' of '%s'. "
"Are you missing any .lcm files?\n",
lm->membername, ls->structname->shortname);
return 0;
}
Expand Down Expand Up @@ -567,8 +568,18 @@ static unsigned int emit_go_array_loops(FILE *f, lcmgen_t *lcm, lcm_struct_t *ls
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);
uint64_t lm_fingerprint = 0;
if (!lcm_is_primitive_type(lm->type->lctypename)) {
if (fingerprint != 0) {
lcm_struct_t *ls_lm = lcm_find_struct(lcm, lm);
if (ls_lm == NULL) {
fprintf(stderr, "Unable to locate %s.\n",
lm->membername);
return -1;
}
lm_fingerprint = lcm_get_fingerprint(lcm, ls_lm);
}
}
emit_go_slice_make(f, n + 1, ls->structname->package, lm, n, slicestr->str, size,
lm_fingerprint);
}
Expand Down

0 comments on commit 8066803

Please sign in to comment.