api.cc, runtime.cc: convert macros to templates
dataview.js: fix bounds checks