1 /* 2 * Copyright 2014 Google Inc. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #define IN_FRUIT_CPP_FILE 1 18 19 #include <fruit/component.h> 20 21 #include <exception> 22 #include <iostream> 23 24 namespace fruit { 25 26 // TODO: reimplement this check somehow. 27 /* 28 EmptyPartialComponent::~EmptyPartialComponent() { 29 // If the user of Fruit didn't cast the result of createComponent() (possibly after adding some bindings) to a 30 Component<>, we abort 31 // because that's a misuse of the Fruit API. If we went ahead, there might be some PartialComponent<> instances that 32 point 33 // to the ComponentStorage in this EmptyComponent, and any use of those would cause undefined behavior. 34 // If an exception is in flight, don't abort; that's likely to be an unexpected flow so we don't want to alert the 35 user of Fruit, 36 // and there can't be any leftover instances of PartialComponent<> referring to this EmptyComponent anyway. 37 if (!already_converted_to_component && !std::uncaught_exception()) { 38 std::cerr << "The result of fruit::createComponent() was not converted to a Component before the end of the 39 expression! " 40 << "This is a misuse of the Fruit API. This is likely to cause undefined behavior, aborting now to be safe." << 41 std::endl; 42 std::abort(); 43 } 44 } 45 */ 46 47 // We need a LCOV_EXCL_BR_LINE below because for some reason gcov/lcov think there's a branch there. 48 } // namespace fruit LCOV_EXCL_BR_LINE 49