(svn r10629) [NoAI] -Fix: on returning a class instance which is NULL, do not make a wrapper SQ, but return a NULL pointer too
#include "ai_road.hpp"
namespace SQConvert {
/* Allow AIRoad to be used as Squirrel parameter */
template <> AIRoad *GetParam(ForceType<AIRoad *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIRoad *)instance; }
template <> AIRoad &GetParam(ForceType<AIRoad &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIRoad *)instance; }
template <> const AIRoad *GetParam(ForceType<const AIRoad *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIRoad *)instance; }
template <> const AIRoad &GetParam(ForceType<const AIRoad &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIRoad *)instance; }
template <> int Return<AIRoad *>(HSQUIRRELVM vm, AIRoad *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIRoad", res, NULL, DefSQDestructorCallback<AIRoad>); return 1; }
}; // namespace SQConvert
void SQAIRoadRegister(Squirrel *engine) {
DefSQClass <AIRoad> SQAIRoad("AIRoad");
SQAIRoad.PreRegister(engine);
SQAIRoad.AddConstructor<void (AIRoad::*)(), 1>(engine, "x");
SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetClassName, "GetClassName", 1, "x");
SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetNeighbourRoadCount, "GetNeighbourRoadCount", 2, "xi");
SQAIRoad.DefSQMethod(engine, &AIRoad::IsRoadTile, "IsRoadTile", 2, "xi");
SQAIRoad.DefSQMethod(engine, &AIRoad::IsRoadDepotTile, "IsRoadDepotTile", 2, "xi");
SQAIRoad.DefSQMethod(engine, &AIRoad::IsRoadStationTile, "IsRoadStationTile", 2, "xi");
SQAIRoad.DefSQMethod(engine, &AIRoad::IsDriveThroughRoadStationTile, "IsDriveThroughRoadStationTile", 2, "xi");
SQAIRoad.DefSQMethod(engine, &AIRoad::AreRoadTilesConnected, "AreRoadTilesConnected", 3, "xii");
SQAIRoad.DefSQMethod(engine, &AIRoad::GetRoadDepotFrontTile, "GetRoadDepotFrontTile", 2, "xi");
SQAIRoad.DefSQMethod(engine, &AIRoad::GetRoadStationFrontTile, "GetRoadStationFrontTile", 2, "xi");
SQAIRoad.DefSQMethod(engine, &AIRoad::GetDriveThroughBackTile, "GetDriveThroughBackTile", 2, "xi");
SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoad, "BuildRoad", 3, "xii");
SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoadFull, "BuildRoadFull", 3, "xii");
SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoadDepot, "BuildRoadDepot", 3, "xii");
SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoadStation, "BuildRoadStation", 5, "xiibb");
SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoad, "RemoveRoad", 3, "xii");
SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoadFull, "RemoveRoadFull", 3, "xii");
SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoadDepot, "RemoveRoadDepot", 2, "xi");
SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoadStation, "RemoveRoadStation", 2, "xi");
SQAIRoad.PostRegister(engine);
}