我想通過修改另一個BWAPI橋(它是用C#編寫的)從http://code.google.com/p/bwapi/製作BWAPI(用C++編寫)的CFFI包裝器, http://code.google.com/p/bwapi-mono-bridge/。SWIG製作BWAPI庫(C++)的CFFI包裝時發生錯誤
我的OS:微軟Windows 7專業版
痛飲版本:2.0.3
的UAC關閉
(*這裏來的錯誤代碼,如果我不指定在中/ STD文件夾%包括部分:http://pastebin.com/XkePbKjG)
更新:在Linux上的同樣的錯誤:
在窗口SWIG 2.0.3
這裏是一個從原始修改了BuildInterface.bat
的內容:
:start
erase /s /q Classes\*.*
erase /s /q Wrapper\*.*
swig.exe -cffi -c++ -I..\BWAPI\Include -outdir Classes\BWAPI -o Wrapper\bwapi-bridge.cxx Interfaces\bwapi-bridge.i
swig.exe -cffi -c++ -I..\BWAPI\Include -outdir Classes\BWTA -o Wrapper\bwta-bridge.cxx Interfaces\bwta-bridge.i
swig.exe -cffi -c++ -I..\BWAPI\Include -outdir Classes\BWAPIC -o Wrapper\bwapiclient-bridge.cxx Interfaces\bwapiclient-bridge.i
pause
goto start
而修改bwapi-bridge.i
:
%include "cpointer.i"
%include "carrays.i"
//include headers in our generated code.
%module bwapi
%{
#include "BWAPI.h"
using namespace BWAPI;
%}
//special include for our dllimport attribute
%include "dllimport.i"
//resolve ambiguities
%include "ambiguities.i"
//unimplemented functions in headers (or ones that should not be called)
//uncomment these each new version of BWAPI to ensure they are not later implemented.
#%ignore getPlayerUnits;
#%ignore BWAPI::GameData::GameData;
//fix up operator overrides.
%rename (opAssign) *::operator =;
%rename (opEquals) *::operator ==;
%rename (opLessThan) *::operator <;
%rename (opGreaterThan) *::operator >;
%rename (opMinus) *::operator -;
%rename (opNotEquals) *::operator !=;
%rename (opPlus) *::operator +;
%rename (opAdd) *::operator +=;
%rename (opSubtract) *::operator -=;
//fix up const strings.
%apply const string & { string &};
%include "BWAPI.h"
%include "BWAPI/EventType.h"
%include "BWAPI/GameType.h"
%include "BWAPI/Race.h"
%include "BWAPI/TechType.h"
%include "BWAPI/UpgradeType.h"
%include "BWAPI/Position.h"
%include "BWAPI/AIModule.h"
%include "BWAPI/Color.h"
%include "BWAPI/Constants.h"
%include "BWAPI/CoordinateType.h"
%include "BWAPI/DamageType.h"
%include "BWAPI/Error.h"
%include "BWAPI/ExplosionType.h"
%include "BWAPI/Flag.h"
%include "BWAPI/Force.h"
%include "BWAPI/Input.h"
%include "BWAPI/Event.h"
%include "BWAPI/Latency.h"
%include "BWAPI/Order.h"
%include "BWAPI/PlayerType.h"
%include "BWAPI/Player.h"
%include "BWAPI/BulletType.h"
%include "BWAPI/Bullet.h"
%include "BWAPI/TilePosition.h"
%include "BWAPI/UnitCommandType.h"
%include "BWAPI/UnitCommand.h"
%include "BWAPI/Game.h"
%include "BWAPI/Unit.h"
%include "BWAPI/UnitSizeType.h"
%include "BWAPI/UnitType.h"
%include "BWAPI/WeaponType.h"
%include "std/std_vector.i"
%include "std/std_set.i"
%include "std/std_pair.i"
%include "std/std_list.i"
%include "std/std_map.i"
//Instantiate our templates
namespace std {
%template (PositionVector)vector<BWAPI::Position>;
%template (BulletPtrSet) set<BWAPI::Bullet *>;
%template (BulletTypeSet) set<BWAPI::BulletType>;
%template (DamageTypeSet) set<BWAPI::DamageType>;
%template (ErrorSet) set<BWAPI::Error>;
%template (ExplosionTypeSet) set<BWAPI::ExplosionType>;
%template (ForcePtrSet) set<BWAPI::Force *>;
%template (GameTypeSet) set<BWAPI::GameType>;
%template (OrderSet) set<BWAPI::Order>;
%template (PlayerPtrSet) set<BWAPI::Player *>;
%template (PlayerTypeSet) set<BWAPI::PlayerType>;
%template (RaceSet) set<BWAPI::Race>;
%template (TechTypeSet) set<BWAPI::TechType>;
%template (TilePositionSet) set<BWAPI::TilePosition>;
%template (UnitPtrSet) set<BWAPI::Unit*>;
%template (UnitCommandTypeSet) set<BWAPI::UnitCommandType>;
%template (UnitSizeTypeSet) set<BWAPI::UnitSizeType>;
%template (UnitTypeSet) set<BWAPI::UnitType>;
%template (UpgradeTypeSet) set<BWAPI::UpgradeType>;
%template (WeaponTypeSet) set<BWAPI::WeaponType>;
%template (EventList) list<BWAPI::Event>;
%template (UnitTypeList) list<BWAPI::UnitType>;
%template (TilePositionDoubleMap) map<BWAPI::TilePosition, double>;
%template (UnitTypeIntMap) map<BWAPI::UnitType, int>;
%template (PositionPair) pair<BWAPI::Position,BWAPI::Position>;
%template (TilePositionDoublePair) pair<BWAPI::TilePosition, double>;
%template (UnitTypeIntPair) pair<BWAPI::UnitType,int>;
%template (TilePositionVector) vector<BWAPI::TilePosition>;
%template (PositionSet) set<BWAPI::Position>;
};
隨着修改bwta-bridge.i
:
%include "cpointer.i"
%module bwta
%{
#include "BWAPI.h"
#include "BWTA.h"
using namespace BWTA;
%}
//use getcolumn instead
%ignore operator[];
//import BWAPI
%import "bwapi-bridge.i"
//BWTA order of includes is important to stop SWIGTYPE_p etc class generation with and without namespace
%include "BWTA/RectangleArray.h"
%include "BWTA/BaseLocation.h"
%include "BWTA/Chokepoint.h"
%include "BWTA/Polygon.h"
%include "BWTA/Region.h"
%include "BWTA.h"
%module bwta-bridge
%include "std/std_vector.i"
%include "std/std_set.i"
%include "std/std_pair.i"
//Instantiate our templates
%template (RectangleArrayDouble) BWTA::RectangleArray<double>;
namespace std {
%template (BaseLocationPtrSet) set<BWTA::BaseLocation *>;
%template (RegionPtrSet) set<BWTA::Region *>;
%template (ChokepointPtrSet) set<BWTA::Chokepoint *>;
%template (PolygonPtrSet) set<BWTA::Polygon *>;
%template (PolygonVector) vector<BWTA::Polygon>;
%template (RegionPtrRegionPtrPair) pair<BWTA::Region *, BWTA::Region *>;
}
;
您可以從2頁我上面任何SVN客戶端下載列出原來的SRC代碼。 謝謝。 請幫忙!
您可以通過#IRC頻道與我聯繫:irc.quakenet:#BWAPI – 2011-04-22 02:54:14