chenting f761a3fdfa 第一次上传 | před 3 měsíci | |
---|---|---|
.. | ||
clang | před 3 měsíci | |
libclang | před 3 měsíci | |
targets | před 3 měsíci | |
test | před 3 měsíci | |
tools | před 3 měsíci | |
AUTHORS | před 3 měsíci | |
README.md | před 3 měsíci | |
generator | před 3 měsíci | |
generator.py | před 3 měsíci |
libclang/
for mac, linux and windows.only the NDK r16 (or higher version) can work corrently
with it.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 .ini
file you want to generate code for.
Included in this repository is a simple test. Use this to confirm the generator is working and that your environment is set up correctly.
Android NDK r16
or higher version.The OSX 10.9 has a built-in python2.7 and if your os don't have python2.7 then use Homebrew to install the python and use pip install the python dependencies.
brew install python
Install python dependices by pip.
sudo easy_install pip sudo pip install PyYAML sudo pip install Cheetah
If you are using python installed from other way, copy user.cfg.sample and rename it as user.cfg
then set the absolute path to python PYTHON_BIN
in user.cfg
Run follow command, it will generate a userconf.ini
, and check the values in it if it occorus any error.
export NDK_ROOT=/path/to/android-ndk-r16 ./test.sh
sudo apt-get install python2.7
sudo apt-get install python-pip sudo pip install PyYAML sudo pip install Cheetah
user.cfg
then set the absolute path to python PYTHON_BIN
in user.cfg
userconf.ini
, and check the values in it if it occorus any error.
export NDK_ROOT=/path/to/android-ndk-r16 ./test.sh
32bit
) from (http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi).python setup.py
.PYTHON_ROOT
and NDK_ROOT
) or just them in test.bat
.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
.ini
fileThe .ini
file is a simple text file specifying the settings for the code generator. Here's the
default one, used for cocos2d-x
[cocos2d-x]
prefix = cocos2dx
events = CCNode#onEnter CCNode#onExit
extra_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.h
classes = CCSprite
functions = my_free_function
#include
s the
rest of the files.Classes::functions
or just functions
to not generate any code.The generator is using Cheetah templates to 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:
Templates are stored in the templates/${target}
directory and follow the naming specified above.
One final part of the puzzle is the ${target}.yaml
file, 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.)
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: