开发者

Error on making CFFI wrapper for BWAPI library (C++) by SWIG

开发者 https://www.devze.com 2023-02-28 04:38 出处:网络
I\'m trying to make a CFFI wrapper for BWAPI (which was written on C++ ) from http://code.google.com/p/bwapi/ ,by modifying another BWAPI-bridge (which was written on C#) http://code.google.com/p/bwap

I'm trying to make a CFFI wrapper for BWAPI (which was written on C++ ) from http://code.google.com/p/bwapi/ ,by modifying another BWAPI-bridge (which was written on C#) http://code.google.com/p/bwapi-mono-bridge/.

My OS: Window 7 Professional

SWIG version: 2.0.3

UAC : off

(*Here come the error code if I don't specify the /std folder in the %include part: http://pastebin.com/XkePbKjG )

  • Update: The same error on Linux :

    Error on making CFFI wrapper for BWAPI library (C++) by SWIG

  • On window with SWIG 2.0.3

    Error on making CFFI wrapper for BWAPI library (C++) by SWIG

Here is the content of my BuildInterface.bat which was modified from the original :

: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

And the modified 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 开发者_C百科(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>;
};

Along with modified 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 *>;
}
;

You can download the original src code from the 2 pages I listed above with any svn client. Thank you. Please Help !


Ok... Throw it away with a body that at least 30 characters.

0

精彩评论

暂无评论...
验证码 换一张
取 消