Skip to content

Commit

Permalink
add fix_luabinding.php
Browse files Browse the repository at this point in the history
  • Loading branch information
yuleiliao committed May 8, 2014
1 parent 7fe259e commit da09d28
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions bin/lib/fix_luabinding.php
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";

0 comments on commit da09d28

Please sign in to comment.