Skip to content

Commit

Permalink
Fix format_signature for zero-argument functions.
Browse files Browse the repository at this point in the history
E.g. void f() has only one signature element (void) but the following string
1 * 2 + 3 = % string elements: <void> < > <f> <(> <)>. Thus, 3 instead of 2 must
be added to the n argument for concat in case of zero-argument functions.

Found while fixing #25.
  • Loading branch information
Oberon00 committed Jan 28, 2015
1 parent ecfe25e commit d749496
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions luabind/detail/format_signature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ void format_signature(lua_State* L, char const* function, Signature)
, typename mpl::end<Signature>::type()
);
lua_pushliteral(L, ")");

lua_concat(L, static_cast<int>(mpl::size<Signature>()) * 2 + 2);
int const signature_len = static_cast<int>(mpl::size<Signature>());
lua_concat(L, signature_len * 2 + (signature_len == 1 ?
3 /* zero-argument function: account for ')' */ : 2));
}

}} // namespace luabind::detail
Expand Down

0 comments on commit d749496

Please sign in to comment.