Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: tools/generate_library_loader/generate_library_loader.py

Issue 685203002: Use decltype instead of typeof in generate_library_loader.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698