OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ | 6 """ |
7 Creates a library loader (a header and implementation file), | 7 Creates a library loader (a header and implementation file), |
8 which is a wrapper for dlopen or direct linking with given library. | 8 which is a wrapper for dlopen or direct linking with given library. |
9 | 9 |
10 The loader makes it possible to have the same client code for both cases, | 10 The loader makes it possible to have the same client code for both cases, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 // Disallow copy constructor and assignment operator. | 55 // Disallow copy constructor and assignment operator. |
56 %(class_name)s(const %(class_name)s&); | 56 %(class_name)s(const %(class_name)s&); |
57 void operator=(const %(class_name)s&); | 57 void operator=(const %(class_name)s&); |
58 }; | 58 }; |
59 | 59 |
60 #endif // %(unique_prefix)s | 60 #endif // %(unique_prefix)s |
61 """ | 61 """ |
62 | 62 |
63 | 63 |
64 HEADER_MEMBER_TEMPLATE = """ typeof(&::%(function_name)s) %(function_name)s; | 64 HEADER_MEMBER_TEMPLATE = """ decltype(&::%(function_name)s) %(function_name)s; |
65 """ | 65 """ |
66 | 66 |
67 | 67 |
68 IMPL_TEMPLATE = """// This is generated file. Do not modify directly. | 68 IMPL_TEMPLATE = """// This is generated file. Do not modify directly. |
69 // Path to the code generator: %(generator_path)s . | 69 // Path to the code generator: %(generator_path)s . |
70 | 70 |
71 #include "%(generated_header_name)s" | 71 #include "%(generated_header_name)s" |
72 | 72 |
73 #include <dlfcn.h> | 73 #include <dlfcn.h> |
74 | 74 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 #endif | 113 #endif |
114 loaded_ = false; | 114 loaded_ = false; |
115 %(member_cleanup)s | 115 %(member_cleanup)s |
116 } | 116 } |
117 """ | 117 """ |
118 | 118 |
119 IMPL_MEMBER_INIT_TEMPLATE = """ | 119 IMPL_MEMBER_INIT_TEMPLATE = """ |
120 #if defined(%(unique_prefix)s_DLOPEN) | 120 #if defined(%(unique_prefix)s_DLOPEN) |
121 %(function_name)s = | 121 %(function_name)s = |
122 reinterpret_cast<typeof(this->%(function_name)s)>( | 122 reinterpret_cast<decltype(this->%(function_name)s)>( |
123 dlsym(library_, "%(function_name)s")); | 123 dlsym(library_, "%(function_name)s")); |
124 #endif | 124 #endif |
125 #if defined(%(unique_prefix)s_DT_NEEDED) | 125 #if defined(%(unique_prefix)s_DT_NEEDED) |
126 %(function_name)s = &::%(function_name)s; | 126 %(function_name)s = &::%(function_name)s; |
127 #endif | 127 #endif |
128 if (!%(function_name)s) { | 128 if (!%(function_name)s) { |
129 CleanUp(true); | 129 CleanUp(true); |
130 return false; | 130 return false; |
131 } | 131 } |
132 """ | 132 """ |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 impl_file = open(os.path.join(source_tree_root, options.output_cc), 'w') | 240 impl_file = open(os.path.join(source_tree_root, options.output_cc), 'w') |
241 try: | 241 try: |
242 impl_file.write(impl_contents) | 242 impl_file.write(impl_contents) |
243 finally: | 243 finally: |
244 impl_file.close() | 244 impl_file.close() |
245 | 245 |
246 return 0 | 246 return 0 |
247 | 247 |
248 if __name__ == '__main__': | 248 if __name__ == '__main__': |
249 sys.exit(main()) | 249 sys.exit(main()) |
OLD | NEW |