Slide 7
Slide 7 text
Copyright© Pasona Inc. All rights reserved.
はまったところ1:PythonからC++の関数を呼び出す
7
C++の変数を作る
class Hand {
Hand(…) {
};
・・・
};
このクラスをPython内でinstance化したい。
hand = dll.ct_Hand(type, name, 10.5)
③ターゲットのライブラリのコンストラクタ
が呼ばれ、instance化を行う。
void * ct_Hand(int type, char* name,
double v) {
Hand *p = new Hand(type, name, v);
return (void *)p;
}
Hand::Hand(int type, const std::string
&name, double v) {type:type .. }
hand = dll.ct_Hand(type, name, 10.5)
①Python側でヘルパー関数を呼び出す。
②ヘルパー関数はCのI/Fを提供して、内部で
newを使いinstance化を行う。
④ヘルパー関数は、voidのpointerに変換して返す。
⑤Pythonの中でC++の変数が使える
pointer