1

Boost.Python を使用して JRA のBWRepLibを公開していますそのため、Python で sc:bw リプレイでデータ マイニングを実行しようとすると、C++ メソッドから値が返されるという小さな問題に遭遇しました。チュートリアルなどの古い単純なプログラムを実行すると、予期される値が python に返されます (正常に出力される "hello, world" 文字列)。しかし、bwreplib プログラムを実行すると、すべての文字列が切り捨てられ、特定の整数を返すメソッドが予期しない値を返すという問題が発生します。たとえば、あるリプレイでは、C++ のプレーヤー名は、プレーヤー 1 が SlayerS_'BoxeR'、プレーヤー 2 が iloveoov として適切に返されます。ただし、Python で出力される値は erS_'Boxer' と eoov であり、最初の 4 バイト/文字が欠落しています。もう 1 つの例は、整数値 1、2、3、または 6 である必要があるプレーヤーのレースですが、97 などの無関係な値が大きくなっています。120、111、および 78 ですが、120 や 97 などの特定の値は同じレースであり、純粋な C++ プログラムから同じ値を返す必要があります。数値間にバイナリ相関が見られないので、おそらくこれはPythonの単語によって相殺され、別の場所から値を返すのではないかと思いますか? 誰かが同様の問題に遭遇しましたか?

私は Boost.Python を使用するのが初めてで、C++ の専門家ではありません。ラッパーを投稿することはできますが、次のような関数を公開する以外には何もしません。

class_<BWrepPlayer>("BWrepPlayer")
.def("getName", &BWrepPlayer::getName)
.def("getNumber", &BWrepPlayer::getNumber)

私が行っていない機能をラップするために何か特別なことをすることになっているのではないかと思います。ただし、オンラインで検索してドキュメントを読んでも、それが何であるかはわかりませんが、見つけたら明らかに明白になると確信しています。

編集:ログ出力

...patience...
...patience...
...found 1547 targets...
...updating 4 targets...
compile-c-c++ bin\msvc-9.0\debug\threading-multi\BWrepAPI.obj
BWrepAPI.cpp
BWrepAPI.cpp(19) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        c:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\string.h(74) : see declaration of 'strcpy'
BWrepAPI.cpp(88) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        c:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\string.h(74) : see declaration of 'strcpy'
BWrepAPI.cpp(245) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        c:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\string.h(74) : see declaration of 'strcpy'
BWrepAPI.cpp(246) : warning C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        c:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\string.h(79) : see declaration of 'strcat'
BWrepAPI.cpp(259) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        c:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\string.h(74) : see declaration of 'strcpy'
BWrepAPI.cpp(265) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        c:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\string.h(74) : see declaration of 'strcpy'
BWrepAPI.cpp(277) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        c:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\string.h(74) : see declaration of 'strcpy'
BWrepAPI.cpp(323) : warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
        c:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\stdio.h(237) : see declaration of 'fopen'
msvc.link.dll bin\msvc-9.0\debug\threading-multi\pybwrep.pyd
   Creating library bin\msvc-9.0\debug\threading-multi\pybwrep.lib and object bin\msvc-9.0\debug\threading-multi\pybwrep.exp
msvc.manifest.dll bin\msvc-9.0\debug\threading-multi\pybwrep.pyd
...updated 4 targets...
4

0 に答える 0