Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

Commit bb9dad5

Browse files
committed
text.cpp: use new technical space properties in assistant
1 parent adb1d28 commit bb9dad5

1 file changed

Lines changed: 47 additions & 11 deletions

File tree

projects/dogen.text.cpp/src/types/transforms/assistant.cpp

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,31 +297,67 @@ bool assistant::requires_nested_namespaces() const {
297297
}
298298

299299
bool assistant::requires_manual_default_constructor() const {
300-
const auto& ap(context_.element_properties().aspect_properties());
301-
302300
/*
303-
* In C++ 98 we must always create a default constructor because
304-
* we cannot make use of the defaulted functions.
301+
* We are only interested in objects or primitives; all other
302+
* element types do not need aspect properties.
305303
*/
306-
return is_cpp_standard_98() || ap.requires_manual_default_constructor();
304+
using logical::entities::structural::object;
305+
const auto optr(dynamic_cast<const object*>(&element_));
306+
using logical::entities::structural::primitive;
307+
const auto pptr(dynamic_cast<const primitive*>(&element_));
308+
309+
if (optr != nullptr) {
310+
return optr->technical_space_properties().
311+
requires_manual_default_constructor();
312+
} else if (pptr != nullptr) {
313+
return pptr->technical_space_properties().
314+
requires_manual_default_constructor();
315+
}
316+
return false;
307317
}
308318

309319
bool assistant::supports_move_operator() const {
310320
return !is_cpp_standard_98();
311321
}
312322

313323
bool assistant::requires_manual_move_constructor() const {
314-
const auto& ap(context_.element_properties().aspect_properties());
315-
316324
/*
317-
* C++ 98 does not support move constructors.
325+
* We are only interested in objects or primitives; all other
326+
* element types do not need aspect properties.
318327
*/
319-
return !is_cpp_standard_98() && ap.requires_manual_move_constructor();
328+
using logical::entities::structural::object;
329+
const auto optr(dynamic_cast<const object*>(&element_));
330+
using logical::entities::structural::primitive;
331+
const auto pptr(dynamic_cast<const primitive*>(&element_));
332+
333+
if (optr != nullptr) {
334+
return optr->technical_space_properties().
335+
requires_manual_move_constructor();
336+
} else if (pptr != nullptr) {
337+
return pptr->technical_space_properties().
338+
requires_manual_move_constructor();
339+
}
340+
return false;
320341
}
321342

322343
bool assistant::requires_stream_manipulators() const {
323-
const auto& ap(context_.element_properties().aspect_properties());
324-
return ap.requires_stream_manipulators();
344+
/*
345+
* We are only interested in objects or primitives; all other
346+
* element types do not need aspect properties.
347+
*/
348+
using logical::entities::structural::object;
349+
const auto optr(dynamic_cast<const object*>(&element_));
350+
using logical::entities::structural::primitive;
351+
const auto pptr(dynamic_cast<const primitive*>(&element_));
352+
353+
if (optr != nullptr) {
354+
return optr->technical_space_properties().
355+
requires_stream_manipulators();
356+
} else if (pptr != nullptr) {
357+
return pptr->technical_space_properties().
358+
requires_stream_manipulators();
359+
}
360+
return false;
325361
}
326362

327363
bool assistant::is_serialization_enabled() const {

0 commit comments

Comments
 (0)