generate whole function in macro