diff --git a/src/engine/candidate_list.h b/src/engine/candidate_list.h index 08fa3d447..cb7979ca5 100644 --- a/src/engine/candidate_list.h +++ b/src/engine/candidate_list.h @@ -113,6 +113,15 @@ class CandidateList final { rotate_(rotate), focused_(false) {} + // Minimum copy operator. + // TODO(all): Support full copy operation of CandidateList as EngineConverter + // is currently copyable. Since the CandidateList contractor is + // initialized with `rotate`, `rotate_` is copied in the copy operator. + CandidateList &operator=(const CandidateList &candidate_list) { + rotate_ = candidate_list.rotate_; + return *this; + } + void Clear(); const Candidate &GetDeepestFocusedCandidate() const; diff --git a/src/engine/engine_converter.cc b/src/engine/engine_converter.cc index 545c3ec7e..58a31c3fa 100644 --- a/src/engine/engine_converter.cc +++ b/src/engine/engine_converter.cc @@ -1151,26 +1151,7 @@ void EngineConverter::FillOutput(const composer::Composer &composer, EngineConverter *EngineConverter::Clone() const { EngineConverter *engine_converter = new EngineConverter(converter_, request_, config_); - - // Copy the members in order of their declarations. - engine_converter->state_ = state_; - // TODO(team): copy of |converter_| member. - // We cannot copy the member converter_ from EngineConverterInterface because - // it doesn't (and shouldn't) define a method like GetConverter(). At the - // moment it's ok because the current design guarantees that the converter is - // singleton. However, we should refactor such bad design; see also the - // comment right above. - engine_converter->segments_ = segments_; - engine_converter->incognito_segments_ = incognito_segments_; - engine_converter->segment_index_ = segment_index_; - engine_converter->previous_suggestions_ = previous_suggestions_; - engine_converter->conversion_preferences_ = conversion_preferences(); - engine_converter->result_ = result_; - engine_converter->request_ = request_; - engine_converter->config_ = config_; - engine_converter->use_cascading_window_ = use_cascading_window_; - engine_converter->selected_candidate_indices_ = selected_candidate_indices_; - engine_converter->request_type_ = request_type_; + *engine_converter = *this; if (engine_converter->CheckState(SUGGESTION | PREDICTION | CONVERSION)) { // UpdateCandidateList() is not simple setter and it uses some members. diff --git a/src/engine/engine_converter.h b/src/engine/engine_converter.h index 4b9a957a0..1d33a8095 100644 --- a/src/engine/engine_converter.h +++ b/src/engine/engine_converter.h @@ -61,7 +61,6 @@ class EngineConverter : public EngineConverterInterface { std::shared_ptr config); explicit EngineConverter(std::shared_ptr converter); EngineConverter(const EngineConverter &) = delete; - EngineConverter &operator=(const EngineConverter &) = delete; // Checks if the current state is in the state bitmap. bool CheckState(States) const override; @@ -245,8 +244,6 @@ class EngineConverter : public EngineConverterInterface { void OnStartComposition(const commands::Context &context) override; // Copies EngineConverter - // TODO(hsumita): Copy all member variables. - // Currently, converter_ is not copied. EngineConverter *Clone() const override; void set_selection_shortcut( @@ -264,6 +261,9 @@ class EngineConverter : public EngineConverterInterface { std::numeric_limits::max(); private: + // Uses default copy operator to simply copy all members. + EngineConverter &operator=(const EngineConverter &) = default; + friend class EngineConverterTest; // Resets the result value stored at the previous command. diff --git a/src/engine/engine_converter_interface.h b/src/engine/engine_converter_interface.h index d33e34507..3168300e5 100644 --- a/src/engine/engine_converter_interface.h +++ b/src/engine/engine_converter_interface.h @@ -66,10 +66,6 @@ struct ConversionPreferences { // support stateful operations related with the converter. class EngineConverterInterface { public: - EngineConverterInterface() = default; - EngineConverterInterface(const EngineConverterInterface &) = delete; - EngineConverterInterface &operator=(const EngineConverterInterface &) = - delete; virtual ~EngineConverterInterface() = default; typedef int States;