forked from chukong/quick-cocos2d-x
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yuleiliao
committed
May 8, 2014
1 parent
7fe259e
commit da09d28
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
function help() | ||
{ | ||
echo <<<EOT | ||
Fix luabinding, use CLASS_HASH_CODE for type mapping. | ||
Usage: | ||
fix_luabinding input_filename | ||
EOT; | ||
|
||
exit(1); | ||
} | ||
|
||
if (!isset($argv)) | ||
{ | ||
echo "\nERR: PHP \$argv not declared.\n"; | ||
help(); | ||
} | ||
|
||
if (count($argv) < 1) | ||
{ | ||
help(); | ||
} | ||
|
||
$path = $argv[1]; | ||
|
||
if (!file_exists($path)) | ||
{ | ||
echo "\nERR: file {$path} not found.\n"; | ||
help(); | ||
} | ||
|
||
$contents = file_get_contents($path); | ||
$contents = str_replace('CCNodeRGBA', 'CCNode', $contents); | ||
$contents = preg_replace('/tolua_usertype\(tolua_S,"(\w+)"\);/', 'tolua_usertype(tolua_S,"\1"); toluafix_add_type_mapping(CLASS_HASH_CODE(typeid(\1)), "\1");', $contents); | ||
file_put_contents($path, $contents); | ||
|
||
echo "\nDONE.\n"; | ||
|