Ошибка создания оболочки CFFI для библиотеки BWAPI (C ++) с помощью SWIG - PullRequest
0 голосов
/ 22 апреля 2011

Я пытаюсь сделать оболочку CFFI для BWAPI (которая была написана на C ++) из http://code.google.com/p/bwapi/, изменяя другой BWAPI-мост (который был написан на C #) http://code.google.com/p/bwapi-mono-bridge/.

Моя ОС: Windows 7 Professional

SWIG версия: 2.0.3

UAC: выкл.

(* Вот код ошибки, если я не указываю папку / std в части% include: 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 *>;
}
;

Вы можете загрузить исходный код src с 2-х страниц, которые я перечислил выше, с помощью любого клиента SVN Спасибо. Пожалуйста, помогите!

1 Ответ

0 голосов
/ 24 апреля 2011

Хорошо ... Выбросьте его с телом, которое содержит не менее 30 символов.

...