cocos2dx 自己主動綁定js

來源:互聯網
上載者:User

標籤:python2.7   rip   and   mpi   info   pre   objects   asc   find   

依照教程把全部資源下載好後.......

找到cocos2dx project下的tools/bindings-generator/test

發現裡面有test.sh , test.ini , 去掉simple尾碼後的user.cfg  , 與userconf.ini ; 把這四個檔案裡的路徑都改為那些資源的路徑

"test.sh"# optionsusage(){cat << EOFusage: $0 [options]Test the C++ <-> JS bindings generatorOPTIONS:-hthis helpDependencies :PYTHON_BINCLANG_ROOTNDK_ROOTDefine this to run from a different directoryCXX_GENERATOR_ROOTEOF}while getopts "dvh" OPTION; docase "$OPTION" ind)debug=1;;v)verbose=1;;h)usageexit 0;;esacdone# exit this script if any commmand failsset -e# find current dirDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"# read user.cfg if it exists and is readable_CFG_FILE=$(dirname "$0")"/user.cfg"if [ -e "$_CFG_FILE" ]then    [ -r "$_CFG_FILE" ] || die "Fatal Error: $_CFG_FILE exists but is unreadable"    . "$_CFG_FILE"fi# pathsif [ -z "${NDK_ROOT+aaa}" ]; then# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk"    NDK_ROOT="/Users/tudu/Downloads/android-ndk-r9c"fiif [ -z "${CLANG_ROOT+aaa}" ]; then# ... if CLANG_ROOT is not set, use "$HOME/bin/clang+llvm-3.1"    CLANG_ROOT="/Users/tudu/Downloads/clang+llvm-3.1-x86_64-apple-darwin11"fiif [ -z "${PYTHON_BIN+aaa}" ]; then# ... if PYTHON_BIN is not set, use "/usr/bin/python2.7"    PYTHON_BIN="/usr/bin/python2.7"fi# paths with defaults hardcoded to relative pathsif [ -z "${CXX_GENERATOR_ROOT+aaa}" ]; then    CXX_GENERATOR_ROOT="$DIR/.."fiecho "CLANG_ROOT: $CLANG_ROOT"echo "NDK_ROOT: $NDK_ROOT"echo "CXX_GENERATOR_ROOT: $CXX_GENERATOR_ROOT"echo "PYTHON_BIN: $PYTHON_BIN"# Generate bindings for simpletest using Android‘s system headersecho "Generating bindings for simpletest with Android headers..."set -xLD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${CXX_GENERATOR_ROOT}/test/test.ini -s testandroid -o ./simple_test_bindings





"test.ini"
<pre name="code" class="plain">[testandroid]name = simple_testprefix = tttttttclasses = testbangcocosdir = /Users/tuyou/Downloads/cocos2d-x-2.2.3# 從 cocos2dx.ini 等搬過來的cocos_headers = -I%(cocosdir)s/cocos2dx/include -I%(cocosdir)s/cocos2dx/platform -I%(cocosdir)s/cocos2dx/platform/android -I%(cocosdir)s/cocos2dx -I%(cocosdir)s/cocos2dx/kazmath/include cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPTextra_arguments = %(cocos_headers)s %(cocos_flags)s -D_SIZE_T_DEFINED_ -nostdinc -nostdinc++ -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.6/include -I%(clangllvmdir)s/lib/clang/3.1/include -I%(cxxgeneratordir)s/test/simple_test -x c++#headers = %(cxxgeneratordir)s/test/simple_test/test.hheaders = /Users/tuyou/Downloads/cocos2d-x-2.2.3/tools/bindings-generator/test/simple_test/test.htarget_namespace =remove_prefix =skip = base_objects =abstract_classes =classes_have_type_info = norename =rename_functions =rename_classes =# classes for which there will be no "parent" lookupclasses_have_no_parents =# base classes which will be skipped when their sub-classes found them.base_classes_to_skip =# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are ‘yes‘ or ‘no‘.script_control_cpp = yes



 
</pre><p></p><pre>

"user.cfg"PYTHON_BIN=/usr/bin/python2.7


"userconf.ini"[DEFAULT]androidndkdir=/Users/tudu/Downloads/android-ndk-r9cclangllvmdir=/Users/tudu/Downloads/clang+llvm-3.1-x86_64-apple-darwin11cxxgeneratordir=/Users/tudu/Downloads/cocos2d-x-2.2.3/tools/bindings-generator/test


然後執行test.sh

OK了

關於終端列印出的錯誤提示 , 以下這些warning貌似沒影響: 

/Library/Python/2.7/site-packages/Cheetah-2.4.4-py2.7.egg/Cheetah/Compiler.py:1509: UserWarning: You don‘t have the C version of NameMapper installed! I‘m disabling Cheetah‘s useStackFrames option as it is painfully slow with the Python version of NameMapper. You should get a copy of Cheetah with the compiled C version of NameMapper.  "\nYou don‘t have the C version of NameMapper installed! "====Errors in parsing headers:1. <severity = Warning,    location = <SourceLocation file None, line 0, column 0>,    details = "argument unused during compilation: ‘-nostdinc++‘">====


假設有severity = error就要檢查一番了 , 之前的error一般都能夠通過改動上面那些路徑而解決


自己主動綁定的問題 : 

1 . 不能綁定繼承的第二個類 , 一個類繼承多個類的時候 , 僅僅有被繼承的第一個類被綁定了 ,原因是 "JS_InitClass"這個函數的形參列表中僅僅能接受一個父類.以下是形參列表:

JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto,             JSClass *clasp, JSNative constructor, unsigned nargs,             JSPropertySpec *ps, JSFunctionSpec *fs,             JSPropertySpec *static_ps, JSFunctionSpec *static_fs);



 

cocos2dx 自己主動綁定js

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.