SWIG为BWAPI库(C ++)制作CFFI包装器时出错

时间:2011-04-22 02:17:16

标签: c++ common-lisp wrapper swig

我正在尝试通过修改另一个BWAPI桥(在C#上编写)http://code.google.com/p/bwapi/来为http://code.google.com/p/bwapi-mono-bridge/的BWAPI(在C ++上编写)创建一个CFFI包装器。

我的操作系统:Window 7 Professional

SWIG版本:2.0.3

UAC:关闭

(*如果我没有在%include部分中指定/ std文件夹,则出现错误代码:http://pastebin.com/XkePbKjG

  • 更新:Linux上的错误相同: enter image description here

  • 在SWIG 2.0.3的窗口中 Here come my error on wrapping process on window:

以下是我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 *>;
}
;

您可以使用任何svn客户端从上面列出的2个页面下载原始src代码。 谢谢。 请帮助!

1 个答案:

答案 0 :(得分:0)

好的......用一个至少30个字符的身体扔掉它。