OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 """Script for post processing C++ bindings files that are generated by tolua++. | |
6 | |
7 This script performs two replacements. Firstly it injects our copyright | |
8 header. Secondly it fixes up the toluafix_pushusertype_ccobject calls | |
9 in the same way that it is done in cocos. | |
10 """ | |
11 import sys | |
12 | |
13 def main(args): | |
14 if len(args) != 1: | |
15 sys.exit("Please specify exactly one filename to process") | |
16 | |
17 filename = args[0] | |
18 with open(filename) as input_file: | |
19 file_data = input_file.read() | |
20 | |
21 file_data = file_data.replace(r'''#ifndef __cplusplus | |
22 #include "stdlib.h" | |
23 #endif | |
24 ''', r'''// Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
25 // Use of this source code is governed by a BSD-style license that can be | |
26 // found in the LICENSE file. | |
27 #ifndef __cplusplus | |
28 #include "stdlib.h" | |
29 #endif | |
30 ''') | |
31 | |
32 file_data = file_data.replace( | |
33 r'toluafix_pushusertype_ccobject(tolua_S,(void*)tolua_ret', | |
34 r'''int nID = (tolua_ret) ? (int)tolua_ret->m_uID : -1; | |
35 int* pLuaID = (tolua_ret) ? &tolua_ret->m_nLuaID : NULL; | |
36 toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret''') | |
37 | |
38 with open(filename, 'w') as output_file: | |
39 output_file.write(file_data) | |
40 | |
noelallen1
2013/03/09 02:05:05
return 0
| |
41 | |
42 if __name__ == '__main__': | |
43 sys.exit(main(sys.argv[1:])) | |
OLD | NEW |