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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « nacltoons/bindings/lua_level_layer.cpp ('k') | nacltoons/bindings/tolua_preload.lua » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:]))
« 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