• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  #ifndef FRUIT_NORMALIZED_BINDINGS_DEFN_H
18  #define FRUIT_NORMALIZED_BINDINGS_DEFN_H
19  
20  #include <fruit/impl/normalized_component_storage/normalized_bindings.h>
21  
22  namespace fruit {
23  namespace impl {
24  
NormalizedBinding(ComponentStorageEntry entry)25  inline NormalizedBinding::NormalizedBinding(ComponentStorageEntry entry) {
26    switch (entry.kind) { // LCOV_EXCL_BR_LINE
27    case ComponentStorageEntry::Kind::BINDING_FOR_CONSTRUCTED_OBJECT:
28      object = entry.binding_for_constructed_object.object_ptr;
29  #if FRUIT_EXTRA_DEBUG
30      is_nonconst = entry.binding_for_constructed_object.is_nonconst;
31  #endif
32      break;
33  
34    case ComponentStorageEntry::Kind::BINDING_FOR_OBJECT_TO_CONSTRUCT_THAT_NEEDS_ALLOCATION:
35    case ComponentStorageEntry::Kind::BINDING_FOR_OBJECT_TO_CONSTRUCT_THAT_NEEDS_NO_ALLOCATION:
36    case ComponentStorageEntry::Kind::BINDING_FOR_OBJECT_TO_CONSTRUCT_WITH_UNKNOWN_ALLOCATION:
37      create = entry.binding_for_object_to_construct.create;
38  #if FRUIT_EXTRA_DEBUG
39      is_nonconst = entry.binding_for_object_to_construct.is_nonconst;
40  #endif
41      break;
42  
43    default:
44  #if FRUIT_EXTRA_DEBUG
45      std::cerr << "Unexpected kind: " << (std::size_t)entry.kind << std::endl;
46  #endif
47      FRUIT_UNREACHABLE; // LCOV_EXCL_LINE
48    }
49  }
50  
51  } // namespace impl
52  } // namespace fruit
53  
54  #endif // FRUIT_NORMALIZED_BINDINGS_DEFN_H
55