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

Side by Side Diff: nacltoons/bindings/post_process.py

Issue 12634010: [nacltoons] Add Makefile for building lua bindings. (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « nacltoons/bindings/lua_level_layer.cpp ('k') | nacltoons/bindings/tolua_preload.lua » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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:]))
OLDNEW
« no previous file with comments | « nacltoons/bindings/lua_level_layer.cpp ('k') | nacltoons/bindings/tolua_preload.lua » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698