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