cocos2dx toLua 没有PyYAML的解决办法

cocos2dx toLua 没有PyYAML的解决办法,第1张

概述What's new Add a prebuilt libclang3.4 in libclang/for mac, linux and windows. If you want use the prebuilt licbclang3.4 work with Android NDK, then only the NDK r9b is can work corrently with it. Requ What's new Add a prebuilt libclang3.4 inlibclang/for mac,linux and windows. If you want use the prebuilt licbclang3.4 work with AndroID NDK,thenonly the NDK r9b is can work correntlywith it. Requirements python2.7 py-yaml cheetah (for target language templates) libclang,from clang 3.3 or later Usage
Usage: generator.py [options] {configfile}Options:  -h,--help   show this help message and exit  -s SECTION   sets a specific section to be converted  -t TARGET    specifIEs the target vm. Will search for TARGET.yaml

Basically,you specify a target vm (spIDermonkey is the only current target vm) and the section from the.inifile you want to generate code for.

Run the simple test with prebuilt libclang3.4

Included in this repository is a simple test. Use this to confirm the generator is working and that your environment is set up correctly.

NOTE The test uses the prebuilt 3.4 libclang,so you should useAndroID NDK r9b. The test uses <string> and <stdint.h> so you need a C++ implementation that provIDes these Currently,the test script is setup to use the AndroID NDK's GNU libstdc++ Mac OS X

The OSX 10.9 has a built-in python2.7 and if your os don't have python2.7 then useHomebrewto install the python and use pip install the python dependencIEs.

brew install python

Install python dependices by pip.

sudo easy_install pipsudo pip install PyYAMLsudo pip install Cheetah

Download64bit ndk-r9b-x86_64fromgoogle

If you are using python installed from other way,copy user.cfg.sample and rename it asuser.cfgthen set the absolute path to pythonPYTHON_BINinuser.cfg Run follow command,it will generate auserconf.ini,and check the values in it if it occorus any error.
export NDK_ROOT=/path/to/androID-ndk-r9b./test.sh
Ubuntu linux 12.04 64bit Install python
sudo apt-get install python2.7
Install python dependices by pip.
sudo apt-get install python-pipsudo pip install PyYAMLsudo pip install Cheetah
Downloadgoogle If you are using python installed from other way,sans-serif"> windows 7 64bit Download python2.7.3 (32bit) from (http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi). Add the installed path of python (e.g. C:\Python27) to windows environment variable named 'PATH'. Download pyyaml fromhttp://pyyaml.org/download/pyyaml/PyYAML-3.10.win32-py2.7.exeand install it. Download pyCheetah fromhttps://raw.github.com/dumganhar/my_old_cocos2d-x_backup/download/downloads/Cheetah.zip,unzip it to "C:\Python27\lib\site-packages" Download64bit NDK-r9bfromgoogle Set the environment variables (PYTHON_ROOTandNDK_ROOT) or just them intest.bat. Run "test.bat". The generated codes will be under "simple_test_bindings". Expected output

Upon running the test you might see some warnings but should not see any errors.

The test will create a directory named simple_test_bindings that contains 3 files

A .hpp header file for the bindings class A .cpp file implementing the bindings class A .Js file that documents how to call (from JavaScript) the methods the C++ class exposes The.inifile

The.inifile is a simple text file specifying the settings for the code generator. Here's the default one,used for cocos2d-x

[cocos2d-x]prefix = cocos2dxevents  = CCNode#onEnter CCNode#onExitextra_arguments = -I../../cocos2dx/include -I../../cocos2dx/platform -I../../cocos2dx/platform/ios -I../../cocos2dx -I../../cocos2dx/kazmath/include -arch i386 -DTARGET_OS_IPHONE -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhonesimulator.platform/Developer/SDKs/iPhonesimulator5.1.sdk -x c++headers = ../../cocos2dx/include/cocos2d.hclasses = CCSpritefunctions = my_free_function
required sections prefix: the prefix for the project. Must be a valID IDentifIEr for the language of the target vm. Most of the time,the name will be intermixed between the class name and the function name,since all generated (probably) will be free functions,we do that in order to avoID name collition. The script will generate ${prefix}.cpp and ${prefix}.hpp as a result. events: a List of IDentifIErs in the form of Classname#functionname that are events to be called from the native world to the target vm. extra_arguments: extra arguments to pass to the clang interface. Basically you can think of this as the arguments to pass to the "compiler",so add as many as you need here. If you're targetting C++,make sure you add "-x c++" as the last argument to force C++ mode on a ".h" file. Otherwise,name your header files as ".hpp". headers: List of headers to parse. Usually you add a single header that in turn#includes the rest of the files. classes: the classes that will be parsed. Right not is just a string,but it will accept regular Expressions functions: space-separated List of free functions to be binded. Same as with classes,it will support regular Expressions. skip: a space-separated List ofClasses::functionsor justfunctionsto not generate any code. The templates

The generator is usingCheetah templatesto create a more flexible generator. The way it was thought,is that for every target environment,you should provIDe with a way to generate the same C/C++ functionality. Every template has access to the proper Meta information for the code or generator (function,classes,etc.)

Right Now it's separated in the following set of templates:

prelude.c/.h: The header of the generated files. ifunction.c/.h: The template for an instance function ifunction_overloaded.c: The template for the implementation of an overloaded function. An overloaded function is exactly the same as a function,but it has an array of functions sharing the same name. The current implementation for spIDermonkey only works if the overloading is with different number of arguments. sfunction.c/.h: The template for a static function sfunction_overloaded.c: The template for an overloaded static function register.c: Here you should add the constructor/finalizer,the registration function (if needed) and the footer of the header file. This is the last chunk being generated

Templates are stored in thetemplates/${target}directory and follow the naming specifIEd above.

One final part of the puzzle is the${target}.yamlfile,that contains specific type conversion snippets to be used by the templates. For instance,for spIDermonkey,this is the place where we specify the conversion routines for the native types (to and from int,float,string,etc.)

limitations

Currently the generator is Leveraging clang in order to get information about the C/C++ code,so we can only get as much information as clang give us. KNown List of things that won't work:

variable number of arguments. Solution: write a manual wrapper 总结

以上是内存溢出为你收集整理的cocos2dx toLua 没有PyYAML的解决办法全部内容,希望文章能够帮你解决cocos2dx toLua 没有PyYAML的解决办法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1063838.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存