Index: nacltoons/bindings/post_process.py |
diff --git a/nacltoons/bindings/post_process.py b/nacltoons/bindings/post_process.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..81022103423daa27138ca16e092f7141f49554f2 |
--- /dev/null |
+++ b/nacltoons/bindings/post_process.py |
@@ -0,0 +1,43 @@ |
+#!/usr/bin/env python |
+# Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+"""Script for post processing C++ bindings files that are generated by tolua++. |
+ |
+This script performs two replacements. Firstly it injects our copyright |
+header. Secondly it fixes up the toluafix_pushusertype_ccobject calls |
+in the same way that it is done in cocos. |
+""" |
+import sys |
+ |
+def main(args): |
+ if len(args) != 1: |
+ sys.exit("Please specify exactly one filename to process") |
+ |
+ filename = args[0] |
+ with open(filename) as input_file: |
+ file_data = input_file.read() |
+ |
+ file_data = file_data.replace(r'''#ifndef __cplusplus |
+#include "stdlib.h" |
+#endif |
+''', r'''// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+#ifndef __cplusplus |
+#include "stdlib.h" |
+#endif |
+''') |
+ |
+ file_data = file_data.replace( |
+ r'toluafix_pushusertype_ccobject(tolua_S,(void*)tolua_ret', |
+ r'''int nID = (tolua_ret) ? (int)tolua_ret->m_uID : -1; |
+ int* pLuaID = (tolua_ret) ? &tolua_ret->m_nLuaID : NULL; |
+ toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret''') |
+ |
+ with open(filename, 'w') as output_file: |
+ output_file.write(file_data) |
+ |
noelallen1
2013/03/09 02:05:05
return 0
|
+ |
+if __name__ == '__main__': |
+ sys.exit(main(sys.argv[1:])) |