diff options
Diffstat (limited to 'src/ai')
-rw-r--r-- | src/ai/api/ai_error.hpp | 2 | ||||
-rw-r--r-- | src/ai/api/ai_error.hpp.sq | 9 | ||||
-rw-r--r-- | src/ai/api/ai_event.hpp | 2 | ||||
-rw-r--r-- | src/ai/api/ai_event.hpp.sq | 6 | ||||
-rw-r--r-- | src/ai/api/ai_log.hpp | 4 | ||||
-rw-r--r-- | src/ai/api/ai_log.hpp.sq | 17 | ||||
-rw-r--r-- | src/ai/api/ai_order.hpp | 2 | ||||
-rw-r--r-- | src/ai/api/ai_tunnel.hpp | 2 | ||||
-rw-r--r-- | src/ai/api/squirrel_export.awk | 13 |
9 files changed, 27 insertions, 30 deletions
diff --git a/src/ai/api/ai_error.hpp b/src/ai/api/ai_error.hpp index b9fd572bb..d3e7c9aea 100644 --- a/src/ai/api/ai_error.hpp +++ b/src/ai/api/ai_error.hpp @@ -136,6 +136,7 @@ public: */ static char *GetLastErrorString(); +#ifndef EXPORT_SKIP /** * Get the error based on the OpenTTD StringID. * @note DO NOT INVOKE THIS METHOD YOURSELF! @@ -159,6 +160,7 @@ public: * @param message The string representation of this error message, used for debug purposes. */ static void RegisterErrorMapString(AIErrorType ai_error_msg, const char *message); +#endif /* EXPORT_SKIP */ private: typedef std::map<StringID, AIErrorType> AIErrorMap; diff --git a/src/ai/api/ai_error.hpp.sq b/src/ai/api/ai_error.hpp.sq index 929907599..0ce1cfed4 100644 --- a/src/ai/api/ai_error.hpp.sq +++ b/src/ai/api/ai_error.hpp.sq @@ -109,12 +109,9 @@ void SQAIError_Register(Squirrel *engine) { AIError::RegisterErrorMapString(AIError::ERR_TOO_CLOSE_TO_EDGE, "ERR_TOO_CLOSE_TO_EDGE"); AIError::RegisterErrorMapString(AIError::ERR_STATION_TOO_SPREAD_OUT, "ERR_STATION_TOO_SPREAD_OUT"); - SQAIError.DefSQStaticMethod(engine, &AIError::GetErrorCategory, "GetErrorCategory", 1, "?"); - SQAIError.DefSQStaticMethod(engine, &AIError::GetLastError, "GetLastError", 1, "?"); - SQAIError.DefSQStaticMethod(engine, &AIError::GetLastErrorString, "GetLastErrorString", 1, "?"); - SQAIError.DefSQStaticMethod(engine, &AIError::StringToError, "StringToError", 2, "?i"); - SQAIError.DefSQStaticMethod(engine, &AIError::RegisterErrorMap, "RegisterErrorMap", 3, "?ii"); - SQAIError.DefSQStaticMethod(engine, &AIError::RegisterErrorMapString, "RegisterErrorMapString", 3, "?is"); + SQAIError.DefSQStaticMethod(engine, &AIError::GetErrorCategory, "GetErrorCategory", 1, "?"); + SQAIError.DefSQStaticMethod(engine, &AIError::GetLastError, "GetLastError", 1, "?"); + SQAIError.DefSQStaticMethod(engine, &AIError::GetLastErrorString, "GetLastErrorString", 1, "?"); SQAIError.PostRegister(engine); } diff --git a/src/ai/api/ai_event.hpp b/src/ai/api/ai_event.hpp index 2c053d33d..077e2a2e6 100644 --- a/src/ai/api/ai_event.hpp +++ b/src/ai/api/ai_event.hpp @@ -87,6 +87,7 @@ public: */ static AIEvent *GetNextEvent(); +#ifndef EXPORT_SKIP /** * Insert an event to the queue for the company. * @param event The event to insert. @@ -98,6 +99,7 @@ public: * @note DO NOT CALL YOURSELF; leave it to the internal AI programming. */ static void FreeEventPointer(); +#endif /* EXPORT_SKIP */ private: /** diff --git a/src/ai/api/ai_event.hpp.sq b/src/ai/api/ai_event.hpp.sq index 572e53658..d7b5fe0a2 100644 --- a/src/ai/api/ai_event.hpp.sq +++ b/src/ai/api/ai_event.hpp.sq @@ -62,10 +62,8 @@ void SQAIEventController_Register(Squirrel *engine) { SQAIEventController.PreRegister(engine); SQAIEventController.AddConstructor<void (AIEventController::*)(), 1>(engine, "x"); - SQAIEventController.DefSQStaticMethod(engine, &AIEventController::IsEventWaiting, "IsEventWaiting", 1, "?"); - SQAIEventController.DefSQStaticMethod(engine, &AIEventController::GetNextEvent, "GetNextEvent", 1, "?"); - SQAIEventController.DefSQStaticMethod(engine, &AIEventController::InsertEvent, "InsertEvent", 2, "?x"); - SQAIEventController.DefSQStaticMethod(engine, &AIEventController::FreeEventPointer, "FreeEventPointer", 1, "?"); + SQAIEventController.DefSQStaticMethod(engine, &AIEventController::IsEventWaiting, "IsEventWaiting", 1, "?"); + SQAIEventController.DefSQStaticMethod(engine, &AIEventController::GetNextEvent, "GetNextEvent", 1, "?"); SQAIEventController.PostRegister(engine); } diff --git a/src/ai/api/ai_log.hpp b/src/ai/api/ai_log.hpp index 7fd1cdb64..da9eaeb46 100644 --- a/src/ai/api/ai_log.hpp +++ b/src/ai/api/ai_log.hpp @@ -18,6 +18,7 @@ class AILog : public AIObject { public: static const char *GetClassName() { return "AILog"; } +#ifndef EXPORT_SKIP /** * Log levels; The value is also feed to DEBUG() lvl. * This has no use for you, as AI writer. @@ -41,6 +42,7 @@ public: int pos; //!< Current position in lines. int used; //!< Total amount of used log-lines. }; +#endif /* EXPORT_SKIP */ /** * Print an Info message to the logs. @@ -60,11 +62,13 @@ public: */ static void Error(const char *message); +#ifndef EXPORT_SKIP /** * Free the log pointer. * @note DO NOT CALL YOURSELF; leave it to the internal AI programming. */ static void FreeLogPointer(); +#endif /* EXPORT_SKIP */ private: /** diff --git a/src/ai/api/ai_log.hpp.sq b/src/ai/api/ai_log.hpp.sq index 5f6803d7c..b6cd6c659 100644 --- a/src/ai/api/ai_log.hpp.sq +++ b/src/ai/api/ai_log.hpp.sq @@ -4,10 +4,6 @@ #include "ai_log.hpp" namespace SQConvert { - /* Allow enums to be used as Squirrel parameters */ - template <> AILog::AILogType GetParam(ForceType<AILog::AILogType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AILog::AILogType)tmp; } - template <> int Return<AILog::AILogType>(HSQUIRRELVM vm, AILog::AILogType res) { sq_pushinteger(vm, (int32)res); return 1; } - /* Allow AILog to be used as Squirrel parameter */ template <> AILog *GetParam(ForceType<AILog *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AILog *)instance; } template <> AILog &GetParam(ForceType<AILog &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AILog *)instance; } @@ -21,16 +17,9 @@ void SQAILog_Register(Squirrel *engine) { SQAILog.PreRegister(engine); SQAILog.AddConstructor<void (AILog::*)(), 1>(engine, "x"); - SQAILog.DefSQConst(engine, AILog::LOG_SQ_ERROR, "LOG_SQ_ERROR"); - SQAILog.DefSQConst(engine, AILog::LOG_ERROR, "LOG_ERROR"); - SQAILog.DefSQConst(engine, AILog::LOG_SQ_INFO, "LOG_SQ_INFO"); - SQAILog.DefSQConst(engine, AILog::LOG_WARNING, "LOG_WARNING"); - SQAILog.DefSQConst(engine, AILog::LOG_INFO, "LOG_INFO"); - - SQAILog.DefSQStaticMethod(engine, &AILog::Info, "Info", 2, "?s"); - SQAILog.DefSQStaticMethod(engine, &AILog::Warning, "Warning", 2, "?s"); - SQAILog.DefSQStaticMethod(engine, &AILog::Error, "Error", 2, "?s"); - SQAILog.DefSQStaticMethod(engine, &AILog::FreeLogPointer, "FreeLogPointer", 1, "?"); + SQAILog.DefSQStaticMethod(engine, &AILog::Info, "Info", 2, "?s"); + SQAILog.DefSQStaticMethod(engine, &AILog::Warning, "Warning", 2, "?s"); + SQAILog.DefSQStaticMethod(engine, &AILog::Error, "Error", 2, "?s"); SQAILog.PostRegister(engine); } diff --git a/src/ai/api/ai_order.hpp b/src/ai/api/ai_order.hpp index c4e9f99be..07df6b778 100644 --- a/src/ai/api/ai_order.hpp +++ b/src/ai/api/ai_order.hpp @@ -185,7 +185,7 @@ public: * Internal function to help ChangeOrder. */ static bool _ChangeOrder(); -#endif +#endif /* DOXYGEN_SKIP */ /** * Changes the order flags of the given order. diff --git a/src/ai/api/ai_tunnel.hpp b/src/ai/api/ai_tunnel.hpp index 6aa6ea4c0..2288f2537 100644 --- a/src/ai/api/ai_tunnel.hpp +++ b/src/ai/api/ai_tunnel.hpp @@ -64,7 +64,7 @@ public: * Internal function to help BuildTunnel in case of road. */ static bool _BuildTunnelRoad2(); -#endif +#endif /* DOXYGEN_SKIP */ /** * Builds a tunnel starting at start. The direction of the tunnel depends diff --git a/src/ai/api/squirrel_export.awk b/src/ai/api/squirrel_export.awk index 9ce3ff26b..1a37289d6 100644 --- a/src/ai/api/squirrel_export.awk +++ b/src/ai/api/squirrel_export.awk @@ -86,10 +86,10 @@ BEGIN { /^( *)private/ { if (cls_level == 1) public = "false"; next; } # Ignore special doxygen blocks -/^#ifndef DOXYGEN_SKIP/ { doxygen_skip = "next"; next; } -/^#ifdef DOXYGEN_SKIP/ { doxygen_skip = "true"; next; } -/^#endif/ { doxygen_skip = "false"; next; } -/^#else/ { +/^#ifndef DOXYGEN_SKIP/ { doxygen_skip = "next"; next; } +/^#ifdef DOXYGEN_SKIP/ { doxygen_skip = "true"; next; } +/^#endif \/\* DOXYGEN_SKIP \*\// { doxygen_skip = "false"; next; } +/^#else/ { if (doxygen_skip == "next") { doxygen_skip = "true"; } else { @@ -99,6 +99,11 @@ BEGIN { } { if (doxygen_skip == "true") next } +# Ignore functions that shouldn't be exported to squirrel +/^#ifndef EXPORT_SKIP/ { export_skip = "true"; next; } +/^#endif \/\* EXPORT_SKIP \*\// { export_skip = "false"; next; } +{ if (export_skip == "true") next } + # Ignore the comments /^#/ { next; } /\/\*.*\*\// { comment = "false"; next; } |