API generator: CPP: Fix bug in JS callbacks