たとえば、Pythonにc ++に変換したい(またはc ++から呼び出したが、Pythonインタープリターに依存したくない)単純なPython関数がある関数があります。
//test.py
def my_sum(x,y):
print "Hello World!"
return x*x+y
私はshedskinを実行し、
//test.cpp
#include "builtin.hpp"
#include "test.hpp"
namespace __test__ {
str *__name__;
void __init() {
__name__ = new str("__main__");
}
} // module namespace
int main(int, char **) {
__shedskin__::__init();
__shedskin__::__start(__test__::__init);
}
//test.hpp
#ifndef __TEST_HPP
#define __TEST_HPP
using namespace __shedskin__;
namespace __test__ {
extern str *__name__;
} // module namespace
#endif
醜いコードで、私の関数my_sumはなく、コードは「builtin.hpp」に依存しています。関数のみを変換することは可能ですか?
また
c++コードからintsum= py.my_sum(3,5);のような関数を呼び出したい。これどうやってするの?
また
多分私はc++コードで使用できるPythonコードからDLLまたはLibを行うことができますか?