Automatic code generation in density functional theory