charmxi sdag: factor out method generation code