/* * feature -- Duplication */ public static object twin(object Current) // New object equal to `Current' // `twin' calls `copy'; to change copying/twining semantics, redefine `copy'. { object Result = null; bool l_check_assert; if (Current == null) { generate_call_on_void_target_exception(); } else { l_check_assert = ISE_RUNTIME.check_assert(false); Result = GENERIC_CONFORMANCE.create_like_object(Current); copy(Result, Current); l_check_assert = ISE_RUNTIME.check_assert(l_check_assert); } return(Result); }
public static object standard_twin(object Current) // New object field-by-field identical to `other'. // Always uses default copying semantics. { object Result = null; bool l_check_assert; EIFFEL_TYPE_INFO l_current = Current as EIFFEL_TYPE_INFO; if (Current == null) { generate_call_on_void_target_exception(); } else { if (l_current != null) { // For Eiffel object we can use our efficient implementation // which is using `MemberwiseClone'. Result = l_current.____standard_twin(); } else { // For .NET object, we have to do it the slow way, allocate // a new object, and then copy field by field. l_check_assert = ISE_RUNTIME.check_assert(false); Result = GENERIC_CONFORMANCE.create_like_object(Current); internal_standard_copy(Result, Current); l_check_assert = ISE_RUNTIME.check_assert(l_check_assert); } } #if ASSERTIONS ASSERTIONS.ENSURE("standard_twin_not_void", Result != null); ASSERTIONS.ENSURE("standard_equal", standard_equal(Current, Result, Current)); #endif return(Result); }