Method and apparatus for manufacturing molding