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

Side by Side Diff: third_party/ffmpeg/generate_stubs.py

Issue 126170: Make the generated stubs weak. Enable the unittests that had conflicting symbols. (Closed)
Patch Set: Fix indent.w Created 11 years, 6 months 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 | « media/media.gyp ('k') | 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/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Creates windows and posix stub files for a given set of signatures. 7 """Creates windows and posix stub files for a given set of signatures.
8 8
9 For libraries that need to be loaded outside of the standard executable startup 9 For libraries that need to be loaded outside of the standard executable startup
10 path mechanism, stub files need to be generated for the wanted functions. In 10 path mechanism, stub files need to be generated for the wanted functions. In
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 A string with the declaration of the function pointer for the signature. 370 A string with the declaration of the function pointer for the signature.
371 """ 371 """
372 return 'static %s (*%s_ptr)(%s) = NULL;' % (signature['return_type'], 372 return 'static %s (*%s_ptr)(%s) = NULL;' % (signature['return_type'],
373 signature['name'], 373 signature['name'],
374 ', '.join(signature['params'])) 374 ', '.join(signature['params']))
375 375
376 @classmethod 376 @classmethod
377 def StubFunction(cls, signature): 377 def StubFunction(cls, signature):
378 """Generates a stub function definition for the given signature. 378 """Generates a stub function definition for the given signature.
379 379
380 The function definitions are created with __attribute__((weak)) so that
381 they may be overridden by a real static link or mock versions to be used
382 when testing.
383
380 Args: 384 Args:
381 signature: The hash representing the function signature. 385 signature: The hash representing the function signature.
382 386
383 Returns: 387 Returns:
384 A string with the stub function definition. 388 A string with the stub function definition.
385 """ 389 """
386 # Generate the return statement prefix if this is not a void function. 390 # Generate the return statement prefix if this is not a void function.
387 return_prefix = '' 391 return_prefix = ''
388 if signature['return_type'] != 'void': 392 if signature['return_type'] != 'void':
389 return_prefix = 'return ' 393 return_prefix = 'return '
390 394
391 # Generate the argument list. 395 # Generate the argument list.
392 arguments = [re.split('[\*& ]', arg)[-1].strip() for arg in 396 arguments = [re.split('[\*& ]', arg)[-1].strip() for arg in
393 signature['params']] 397 signature['params']]
394 arg_list = ', '.join(arguments) 398 arg_list = ', '.join(arguments)
395 if arg_list == 'void': 399 if arg_list == 'void':
396 arg_list = '' 400 arg_list = ''
397 401
398 return """%(return_type)s %(name)s(%(params)s) { 402 return """extern %(return_type)s %(name)s(%(params)s) __attribute__((weak));
403 %(return_type)s %(name)s(%(params)s) {
399 %(return_prefix)s%(name)s_ptr(%(arg_list)s); 404 %(return_prefix)s%(name)s_ptr(%(arg_list)s);
400 }""" % {'return_type': signature['return_type'], 405 }""" % {'return_type': signature['return_type'],
401 'name': signature['name'], 406 'name': signature['name'],
402 'params': ', '.join(signature['params']), 407 'params': ', '.join(signature['params']),
403 'return_prefix': return_prefix, 408 'return_prefix': return_prefix,
404 'arg_list': arg_list} 409 'arg_list': arg_list}
405 410
406 @classmethod 411 @classmethod
407 def WriteImplementationPreamble(cls, header_path, outfile): 412 def WriteImplementationPreamble(cls, header_path, outfile):
408 """Write the necessary includes for the implementation file. 413 """Write the necessary includes for the implementation file.
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 finally: 852 finally:
848 if header_file is not None: 853 if header_file is not None:
849 header_file.close() 854 header_file.close()
850 855
851 else: 856 else:
852 raise Error('Should not reach here') 857 raise Error('Should not reach here')
853 858
854 859
855 if __name__ == '__main__': 860 if __name__ == '__main__':
856 main() 861 main()
OLDNEW
« no previous file with comments | « media/media.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698