generate functions that fill metatables