From 46a8eb54918e41c533f82ff2549668734421dbf1 Mon Sep 17 00:00:00 2001 From: dualface Date: Thu, 20 Sep 2012 23:37:23 +0800 Subject: [PATCH] [Lua] add ccTexParams, add new luabinding build script, update luabinding --- .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- tools/tolua++/CCTexture2D.pkg | 8 + tools/tolua++/build.php | 257 ++++++++++++++++++ 3 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 tools/tolua++/build.php diff --git a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 3c867363b0..1bb2a5fbef 100644 --- a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -d33790c08f03c11f8432a3bd2b9be537d00fa8c2 \ No newline at end of file +dab2e1ed075027aac1e137daaa68542dfe2d7c63 \ No newline at end of file diff --git a/tools/tolua++/CCTexture2D.pkg b/tools/tolua++/CCTexture2D.pkg index a667d9fa38..b9966b1cd7 100644 --- a/tools/tolua++/CCTexture2D.pkg +++ b/tools/tolua++/CCTexture2D.pkg @@ -36,6 +36,14 @@ typedef enum { kTexture2DPixelFormat_Default = kCCTexture2DPixelFormat_Default } CCTexture2DPixelFormat; +class ccTexParams { + ccTexParams(void); + GLuint minFilter; + GLuint magFilter; + GLuint wrapS; + GLuint wrapT; +}; + class CCTexture2D : public CCObject { void releaseData(void* data); diff --git a/tools/tolua++/build.php b/tools/tolua++/build.php new file mode 100644 index 0000000000..80403afe7f --- /dev/null +++ b/tools/tolua++/build.php @@ -0,0 +1,257 @@ +_extensionName = $extensionName; + $this->_luabindingFilename = $luabindingFilename; + $this->_inputPath = SRC_DIR . $extensionName . '.pkg'; + $this->_outputCppPath = OUT_DIR . $luabindingFilename . '.cpp'; + $this->_outputHeaderPath = OUT_DIR . $luabindingFilename . '.h'; + $this->_luaopenFunctionName = sprintf('tolua_%s_open', $extensionName); + $this->_fix = $fix; + } + + function build() + { + $command = sprintf('%s -L basic.lua -o %s %s', + TOLUA_BIN, $this->_outputCppPath, $this->_inputPath); + + printf(" creating file: %s.cpp\n", $this->_luabindingFilename); + printf(" command: %s\n", $command); + passthru($command); + + if (file_exists($this->_outputCppPath)) + { + $this->_fixLuabindingFile(); + } + + $includeOnce = sprintf('__%s_H_', strtoupper($this->_luabindingFilename)); + $functionName = $this->_luaopenFunctionName; + $header = <<_luabindingFilename); + // file_put_contents($this->_outputHeaderPath, $header); + } + + function getLuaopenFunctionName() + { + return $this->_luaopenFunctionName; + } + + private function _fixLuabindingFile() + { + $contents = file_get_contents($this->_outputCppPath); + $contents = str_replace("\t", ' ', $contents); + foreach ($this->_fix as $find => $replace) + { + $find = str_replace('##EXTENSION_NAME##', $this->_extensionName, $find); + $replace = str_replace('##EXTENSION_NAME##', $this->_extensionName, $replace); + + $contents = str_replace($find, $replace, $contents); + } + + file_put_contents($this->_outputCppPath, $contents); + } +} + +$FIX = array(); + +// remove unused header +$find = <<m_uID : -1; + int* pLuaID = (tolua_ret) ? &tolua_ret->m_nLuaID : NULL; + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret +EOT; +$FIX[$find] = $replace; + +// fix LUA_STRING +$find = '((LUA_STRING*)'; +$replace = '('; +$FIX[$find] = $replace; + +$find = 'tolua_usertype(tolua_S,"LUA_STRING");'; +$replace = ''; +$FIX[$find] = $replace; + +$find = <<build();