(svn r23370) -Add: support @api tag in API header files, to select which API should receive the defined classes and functions

This commit is contained in:
truebrain 2011-11-29 23:27:26 +00:00
parent 2c877b074e
commit 4d91f645c1
52 changed files with 240 additions and 57 deletions

View File

@ -40,6 +40,39 @@ function dump_class_templates(name)
} }
} }
function dump_fileheader()
{
# Break the Id tag, so SVN doesn't replace it
print "/* $I" "d$ */"
print ""
print "/*"
print " * This file is part of OpenTTD."
print " * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2."
print " * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
print " * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>."
print " */"
print ""
print "/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */"
print ""
print "#include \"../../script/api/" filename "\""
}
function reset_reader()
{
enum_size = 0
enum_value_size = 0
enum_string_to_error_size = 0
enum_error_to_string_size = 0
struct_size = 0
method_size = 0
static_method_size = 0
virtual_class = "false"
cls = ""
start_squirrel_define_on_next_line = "false"
cls_level = 0
cls_in_api = ""
}
BEGIN { BEGIN {
enum_size = 0 enum_size = 0
enum_value_size = 0 enum_value_size = 0
@ -52,26 +85,35 @@ BEGIN {
virtual_class = "false" virtual_class = "false"
super_cls = "" super_cls = ""
cls = "" cls = ""
api_selected = ""
cls_in_api = ""
start_squirrel_define_on_next_line = "false" start_squirrel_define_on_next_line = "false"
has_fileheader = "false"
cls_level = 0 cls_level = 0
RS = "\r|\n" RS = "\r|\n"
} }
/@file/ { /@file/ {
# Break it, so SVN doesn't replace it filename = $3
print "/* $I" "d$ */" gsub("^" tolower(api) "_", "script_", filename)
print "" }
print "/*"
print " * This file is part of OpenTTD." /^([ ]*)\* @api/ {
print " * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2." # By default, classes are not selected
print " * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." if (cls_level == 0) api_selected = "false"
print " * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>."
print " */" gsub("^([ ]*)", "", $0)
print "" gsub("* @api ", "", $0)
print "/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */"
print "" if ($0 == "none") {
gsub("^" tolower(api) "_", "script_", $3) api_selected = "false"
print "#include \"../../script/api/" $3 "\"" } else if ($0 == "-all") {
api_selected = "false"
} else if (match($0, "-" tolower(api))) {
api_selected = "false"
} else if (match($0, tolower(api))) {
api_selected = "true"
}
} }
# Remove the old squirrel stuff # Remove the old squirrel stuff
@ -84,10 +126,16 @@ BEGIN {
# We only want to have public functions exported for now # We only want to have public functions exported for now
/^( *)class/ { /^( *)class/ {
if (cls_level == 0) { if (cls_level == 0) {
if (api_selected == "") {
print "Class '"$2"' has no @api. It won't be published to any API." > "/dev/stderr"
api_selected = "false"
}
public = "false" public = "false"
cls_param[0] = "" cls_param[0] = ""
cls_param[1] = 1 cls_param[1] = 1
cls_param[2] = "x" cls_param[2] = "x"
cls_in_api = api_selected
api_selected = ""
cls = $2 cls = $2
if (match($4, "public") || match($4, "protected") || match($4, "private")) { if (match($4, "public") || match($4, "protected") || match($4, "private")) {
super_cls = $5 super_cls = $5
@ -95,9 +143,14 @@ BEGIN {
super_cls = $4 super_cls = $4
} }
} else if (cls_level == 1) { } else if (cls_level == 1) {
if (api_selected == "") api_selected = cls_in_api
if (api_selected == "true") {
struct_size++ struct_size++
structs[struct_size] = cls "::" $2 structs[struct_size] = cls "::" $2
} }
api_selected = ""
}
cls_level++ cls_level++
next next
} }
@ -119,11 +172,6 @@ BEGIN {
} }
{ if (doxygen_skip == "true") next } { 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 # Ignore the comments
/^#/ { next; } /^#/ { next; }
/\/\*.*\*\// { comment = "false"; next; } /\/\*.*\*\// { comment = "false"; next; }
@ -134,20 +182,42 @@ BEGIN {
# We need to make specialized conversions for structs # We need to make specialized conversions for structs
/^( *)struct/ { /^( *)struct/ {
cls_level++ cls_level++
# Check if we want to publish this struct
if (api_selected == "") api_selected = cls_in_api
if (api_selected == "false") {
api_selected = ""
next
}
api_selected = ""
if (public == "false") next if (public == "false") next
if (cls_level != 1) next if (cls_level != 1) next
struct_size++ struct_size++
structs[struct_size] = cls "::" $2 structs[struct_size] = cls "::" $2
next next
} }
# We need to make specialized conversions for enums # We need to make specialized conversions for enums
/^( *)enum/ { /^( *)enum/ {
cls_level++ cls_level++
if (public == "false") next;
# Check if we want to publish this enum
if (api_selected == "") api_selected = cls_in_api
if (api_selected == "false") {
api_selected = ""
next
}
api_selected = ""
if (public == "false") next
in_enum = "true" in_enum = "true"
enum_size++ enum_size++
enums[enum_size] = cls "::" $2 enums[enum_size] = cls "::" $2
next next
} }
@ -168,6 +238,16 @@ BEGIN {
# Empty/white lines. When we may do the Squirrel export, do that export. # Empty/white lines. When we may do the Squirrel export, do that export.
/^([ ]*)$/ { /^([ ]*)$/ {
if (start_squirrel_define_on_next_line == "false") next if (start_squirrel_define_on_next_line == "false") next
if (cls_in_api != "true") {
reset_reader()
next
}
if (has_fileheader == "false") {
dump_fileheader()
has_fileheader = "true"
}
spaces = " "; spaces = " ";
public = "false" public = "false"
namespace_opened = "false" namespace_opened = "false"
@ -310,17 +390,9 @@ BEGIN {
print " SQ" api_cls ".PostRegister(engine);" print " SQ" api_cls ".PostRegister(engine);"
print "}" print "}"
enum_size = 0 reset_reader()
enum_value_size = 0
enum_string_to_error_size = 0 next
enum_error_to_string_size = 0
struct_size = 0
method_size = 0
static_method_size = 0
virtual_class = "false"
cls = ""
start_squirrel_define_on_next_line = "false"
cls_level = 0
} }
# Skip non-public functions # Skip non-public functions
@ -370,7 +442,13 @@ BEGIN {
# Add a method to the list # Add a method to the list
/^.*\(.*\).*$/ { /^.*\(.*\).*$/ {
if (cls_level != 1) next if (cls_level != 1) next
if (match($0, "~")) next if (match($0, "~")) {
if (api_selected != "") {
print "Destructor for '"cls"' has @api. Tag ignored." > "/dev/stderr"
api_selected = ""
}
next
}
is_static = match($0, "static") is_static = match($0, "static")
if (match($0, "virtual")) { if (match($0, "virtual")) {
@ -389,6 +467,10 @@ BEGIN {
funcname = $2 funcname = $2
if ($1 == cls && funcname == "") { if ($1 == cls && funcname == "") {
if (api_selected != "") {
print "Constructor for '"cls"' has @api. Tag ignored." > "/dev/stderr"
api_selected = ""
}
cls_param[0] = param_s cls_param[0] = param_s
if (param_s == "") next if (param_s == "") next
} else if (funcname == "") next } else if (funcname == "") next
@ -422,6 +504,14 @@ BEGIN {
} }
} }
# Check if we want to publish this function
if (api_selected == "") api_selected = cls_in_api
if (api_selected == "false") {
api_selected = ""
next
}
api_selected = ""
if ($1 == cls && funcname == "") { if ($1 == cls && funcname == "") {
cls_param[1] = len; cls_param[1] = len;
cls_param[2] = types; cls_param[2] = types;

View File

@ -26,13 +26,20 @@ apiuc=`echo ${apilc} | tr [a-z] [A-Z]`
if [ -z "$1" ]; then if [ -z "$1" ]; then
for f in `ls ../../script/api/*.hpp`; do for f in `ls ../../script/api/*.hpp`; do
bf=`basename $f | sed s/script/${apilc}/` bf=`basename ${f} | sed s/script/${apilc}/`
case "${bf}" in
# these files should not be changed by this script # ScriptController has custom code, and should not be generated
"ai_controller.hpp" | "ai_object.hpp" | "ai_types.hpp" | "ai_changelog.hpp" | "ai_info_docs.hpp" ) continue; if [ "`basename ${f}`" = "script_controller.hpp" ]; then continue; fi
esac
${AWK} -v api=${apiuc} -f squirrel_export.awk ${f} > ${bf}.tmp ${AWK} -v api=${apiuc} -f squirrel_export.awk ${f} > ${bf}.tmp
if ! [ -f "${bf}.sq" ] || [ -n "`diff -I '$Id' ${bf}.tmp ${bf}.sq 2> /dev/null || echo boo`" ]; then
if [ "`wc -l ${bf}.tmp | cut -d\ -f1`" = "0" ]; then
if [ -f "${bf}.sq" ]; then
echo "Deleted: ${bf}.sq"
svn del --force ${bf}.sq > /dev/null 2>&1
fi
rm -f ${bf}.tmp
elif ! [ -f "${bf}.sq" ] || [ -n "`diff -I '$Id' ${bf}.tmp ${bf}.sq 2> /dev/null || echo boo`" ]; then
mv ${bf}.tmp ${bf}.sq mv ${bf}.tmp ${bf}.sq
echo "Updated: ${bf}.sq" echo "Updated: ${bf}.sq"
svn add ${bf}.sq > /dev/null 2>&1 svn add ${bf}.sq > /dev/null 2>&1
@ -44,7 +51,13 @@ if [ -z "$1" ]; then
done done
else else
${AWK} -v api=${apiuc} -f squirrel_export.awk $1 > $1.tmp ${AWK} -v api=${apiuc} -f squirrel_export.awk $1 > $1.tmp
if ! [ -f "${f}.sq" ] || [ -n "`diff -I '$Id' $1.sq $1.tmp 2> /dev/null || echo boo`" ]; then if [ `wc -l $1.tmp | cut -d\ -f1` -eq "0" ]; then
if [ -f "$1.sq" ]; then
echo "Deleted: $1.sq"
svn del --force $1.sq > /dev/null 2>&1
fi
rm -f $1.tmp
elif ! [ -f "${f}.sq" ] || [ -n "`diff -I '$Id' $1.sq $1.tmp 2> /dev/null || echo boo`" ]; then
mv $1.tmp $1.sq mv $1.tmp $1.sq
echo "Updated: $1.sq" echo "Updated: $1.sq"
svn add $1.sq > /dev/null 2>&1 svn add $1.sq > /dev/null 2>&1

View File

@ -17,6 +17,7 @@
/** /**
* Class that keeps track of the costs, so you can request how much a block of * Class that keeps track of the costs, so you can request how much a block of
* commands did cost in total. Works in both Execute as in Test mode. * commands did cost in total. Works in both Execute as in Test mode.
* @api ai
* Example: * Example:
* <pre> * <pre>
* { * {

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all airport related functions. * Class that handles all airport related functions.
* @api ai
*/ */
class ScriptAirport : public ScriptObject { class ScriptAirport : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles some basic functions. * Class that handles some basic functions.
* @api ai
* *
* @note The random functions are not called Random and RandomRange, because * @note The random functions are not called Random and RandomRange, because
* RANDOM_DEBUG does some tricky stuff, which messes with those names. * RANDOM_DEBUG does some tricky stuff, which messes with those names.

View File

@ -16,6 +16,7 @@
/** /**
* Base class for stations and waypoints. * Base class for stations and waypoints.
* @api ai
*/ */
class ScriptBaseStation : public ScriptObject { class ScriptBaseStation : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all bridge related functions. * Class that handles all bridge related functions.
* @api ai
*/ */
class ScriptBridge : public ScriptObject { class ScriptBridge : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Create a list of bridges. * Create a list of bridges.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptBridgeList : public ScriptList { class ScriptBridgeList : public ScriptList {
@ -25,6 +26,7 @@ public:
/** /**
* Create a list of bridges that can be built on a specific length. * Create a list of bridges that can be built on a specific length.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptBridgeList_Length : public ScriptList { class ScriptBridgeList_Length : public ScriptList {

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all cargo related functions. * Class that handles all cargo related functions.
* @api ai
*/ */
class ScriptCargo : public ScriptObject { class ScriptCargo : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Creates a list of cargos that can be produced in the current game. * Creates a list of cargos that can be produced in the current game.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptCargoList : public ScriptList { class ScriptCargoList : public ScriptList {
@ -27,6 +28,7 @@ public:
* Creates a list of cargos that the given industry accepts. * Creates a list of cargos that the given industry accepts.
* @note This list also includes cargos that are temporarily not accepted * @note This list also includes cargos that are temporarily not accepted
* by this industry, @see ScriptIndustry::IsCargoAccepted. * by this industry, @see ScriptIndustry::IsCargoAccepted.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptCargoList_IndustryAccepting : public ScriptList { class ScriptCargoList_IndustryAccepting : public ScriptList {
@ -39,6 +41,7 @@ public:
/** /**
* Creates a list of cargos that the given industry can produce. * Creates a list of cargos that the given industry can produce.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptCargoList_IndustryProducing : public ScriptList { class ScriptCargoList_IndustryProducing : public ScriptList {
@ -51,6 +54,7 @@ public:
/** /**
* Creates a list of cargos that the given station accepts. * Creates a list of cargos that the given station accepts.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptCargoList_StationAccepting : public ScriptList { class ScriptCargoList_StationAccepting : public ScriptList {

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all company related functions. * Class that handles all company related functions.
* @api ai
*/ */
class ScriptCompany : public ScriptObject { class ScriptCompany : public ScriptObject {
public: public:

View File

@ -19,6 +19,7 @@
* The Controller, the class each Script should extend. It creates the Script, * The Controller, the class each Script should extend. It creates the Script,
* makes sure the logic kicks in correctly, and that GetTick() has a valid * makes sure the logic kicks in correctly, and that GetTick() has a valid
* value. * value.
* @api ai
*/ */
class ScriptController { class ScriptController {
friend class AIScanner; friend class AIScanner;

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all date related (calculation) functions. * Class that handles all date related (calculation) functions.
* @api ai
* *
* @note Months and days of month are 1-based; the first month of the * @note Months and days of month are 1-based; the first month of the
* year is 1 and the first day of the month is also 1. * year is 1 and the first day of the month is also 1.

View File

@ -17,6 +17,7 @@
/** /**
* Creates a list of the locations of the depots (and hangars) of which you are the owner. * Creates a list of the locations of the depots (and hangars) of which you are the owner.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptDepotList : public ScriptList { class ScriptDepotList : public ScriptList {

View File

@ -18,6 +18,7 @@
/** /**
* Class that handles all engine related functions. * Class that handles all engine related functions.
* @api ai
*/ */
class ScriptEngine : public ScriptObject { class ScriptEngine : public ScriptObject {
public: public:

View File

@ -17,6 +17,7 @@
/** /**
* Create a list of engines based on a vehicle type. * Create a list of engines based on a vehicle type.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptEngineList : public ScriptList { class ScriptEngineList : public ScriptList {

View File

@ -40,6 +40,7 @@
/** /**
* Class that handles all error related functions. * Class that handles all error related functions.
* @api ai
*/ */
class ScriptError : public ScriptObject { class ScriptError : public ScriptObject {
public: public:
@ -142,10 +143,9 @@ public:
*/ */
static char *GetLastErrorString(); static char *GetLastErrorString();
#ifndef EXPORT_SKIP
/** /**
* Get the error based on the OpenTTD StringID. * Get the error based on the OpenTTD StringID.
* @note DO NOT INVOKE THIS METHOD YOURSELF! * @api -all
* @param internal_string_id The string to convert. * @param internal_string_id The string to convert.
* @return The NoAI equivalent error message. * @return The NoAI equivalent error message.
*/ */
@ -153,7 +153,7 @@ public:
/** /**
* Map an internal OpenTTD error message to its NoAI equivalent. * Map an internal OpenTTD error message to its NoAI equivalent.
* @note DO NOT INVOKE THIS METHOD YOURSELF! The calls are autogenerated. * @api -all
* @param internal_string_id The OpenTTD StringID used for an error. * @param internal_string_id The OpenTTD StringID used for an error.
* @param ai_error_msg The NoAI equivalent error message. * @param ai_error_msg The NoAI equivalent error message.
*/ */
@ -161,12 +161,11 @@ public:
/** /**
* Map an internal OpenTTD error message to its NoAI equivalent. * Map an internal OpenTTD error message to its NoAI equivalent.
* @note DO NOT INVOKE THIS METHOD YOURSELF! The calls are autogenerated. * @api -all
* @param ai_error_msg The NoAI error message representation. * @param ai_error_msg The NoAI error message representation.
* @param message The string representation of this error message, used for debug purposes. * @param message The string representation of this error message, used for debug purposes.
*/ */
static void RegisterErrorMapString(ScriptErrorType ai_error_msg, const char *message); static void RegisterErrorMapString(ScriptErrorType ai_error_msg, const char *message);
#endif /* EXPORT_SKIP */
private: private:
typedef std::map<StringID, ScriptErrorType> ScriptErrorMap; ///< The type for mapping between error (internal OpenTTD) StringID to the AI error type. typedef std::map<StringID, ScriptErrorType> ScriptErrorMap; ///< The type for mapping between error (internal OpenTTD) StringID to the AI error type.

View File

@ -18,6 +18,7 @@
* Class that handles all event related functions. * Class that handles all event related functions.
* You can lookup the type, and than convert it to the real event-class. * You can lookup the type, and than convert it to the real event-class.
* That way you can request more detailed information about the event. * That way you can request more detailed information about the event.
* @api ai
*/ */
class ScriptEvent : public ScriptObject { class ScriptEvent : public ScriptObject {
public: public:
@ -72,6 +73,7 @@ protected:
/** /**
* Class that handles all event related functions. * Class that handles all event related functions.
* @api ai
* @note it is not needed to create an instance of ScriptEvent to access it, as * @note it is not needed to create an instance of ScriptEvent to access it, as
* all members are static, and all data is stored AI-wide. * all members are static, and all data is stored AI-wide.
*/ */
@ -89,20 +91,18 @@ public:
*/ */
static ScriptEvent *GetNextEvent(); static ScriptEvent *GetNextEvent();
#ifndef EXPORT_SKIP
/** /**
* Insert an event to the queue for the company. * Insert an event to the queue for the company.
* @param event The event to insert. * @param event The event to insert.
* @note DO NOT CALL YOURSELF; leave it to the internal AI programming. * @api -all
*/ */
static void InsertEvent(ScriptEvent *event); static void InsertEvent(ScriptEvent *event);
/** /**
* Free the event pointer. * Free the event pointer.
* @note DO NOT CALL YOURSELF; leave it to the internal AI programming. * @api -all
*/ */
static void FreeEventPointer(); static void FreeEventPointer();
#endif /* EXPORT_SKIP */
private: private:
/** /**

View File

@ -18,6 +18,7 @@
/** /**
* Event Vehicle Crash, indicating a vehicle of yours is crashed. * Event Vehicle Crash, indicating a vehicle of yours is crashed.
* It contains the crash site, the crashed vehicle and the reason for the crash. * It contains the crash site, the crashed vehicle and the reason for the crash.
* @api ai
*/ */
class ScriptEventVehicleCrashed : public ScriptEvent { class ScriptEventVehicleCrashed : public ScriptEvent {
public: public:
@ -78,6 +79,7 @@ private:
/** /**
* Event Subsidy Offered, indicating someone offered a subsidy. * Event Subsidy Offered, indicating someone offered a subsidy.
* @api ai
*/ */
class ScriptEventSubsidyOffer : public ScriptEvent { class ScriptEventSubsidyOffer : public ScriptEvent {
public: public:
@ -108,6 +110,7 @@ private:
/** /**
* Event Subsidy Offer Expired, indicating a subsidy will no longer be awarded. * Event Subsidy Offer Expired, indicating a subsidy will no longer be awarded.
* @api ai
*/ */
class ScriptEventSubsidyOfferExpired : public ScriptEvent { class ScriptEventSubsidyOfferExpired : public ScriptEvent {
public: public:
@ -138,6 +141,7 @@ private:
/** /**
* Event Subidy Awarded, indicating a subsidy is awarded to some company. * Event Subidy Awarded, indicating a subsidy is awarded to some company.
* @api ai
*/ */
class ScriptEventSubsidyAwarded : public ScriptEvent { class ScriptEventSubsidyAwarded : public ScriptEvent {
public: public:
@ -168,6 +172,7 @@ private:
/** /**
* Event Subsidy Expired, indicating a route that was once subsidized no longer is. * Event Subsidy Expired, indicating a route that was once subsidized no longer is.
* @api ai
*/ */
class ScriptEventSubsidyExpired : public ScriptEvent { class ScriptEventSubsidyExpired : public ScriptEvent {
public: public:
@ -200,6 +205,7 @@ private:
* Event Engine Preview, indicating a manufacturer offer you to test a new engine. * Event Engine Preview, indicating a manufacturer offer you to test a new engine.
* You can get the same information about the offered engine as a real user * You can get the same information about the offered engine as a real user
* would see in the offer window. And you can also accept the offer. * would see in the offer window. And you can also accept the offer.
* @api ai
*/ */
class ScriptEventEnginePreview : public ScriptEvent { class ScriptEventEnginePreview : public ScriptEvent {
public: public:
@ -288,6 +294,7 @@ private:
/** /**
* Event Company New, indicating a new company has been created. * Event Company New, indicating a new company has been created.
* @api ai
*/ */
class ScriptEventCompanyNew : public ScriptEvent { class ScriptEventCompanyNew : public ScriptEvent {
public: public:
@ -319,6 +326,7 @@ private:
/** /**
* Event Company In Trouble, indicating a company is in trouble and might go * Event Company In Trouble, indicating a company is in trouble and might go
* bankrupt soon. * bankrupt soon.
* @api ai
*/ */
class ScriptEventCompanyInTrouble : public ScriptEvent { class ScriptEventCompanyInTrouble : public ScriptEvent {
public: public:
@ -349,6 +357,7 @@ private:
/** /**
* Event Company Ask Merger, indicating a company can be bought (cheaply) by you. * Event Company Ask Merger, indicating a company can be bought (cheaply) by you.
* @api ai
*/ */
class ScriptEventCompanyAskMerger : public ScriptEvent { class ScriptEventCompanyAskMerger : public ScriptEvent {
public: public:
@ -396,6 +405,7 @@ private:
/** /**
* Event Company Merger, indicating a company has been bought by another * Event Company Merger, indicating a company has been bought by another
* company. * company.
* @api ai
*/ */
class ScriptEventCompanyMerger : public ScriptEvent { class ScriptEventCompanyMerger : public ScriptEvent {
public: public:
@ -438,6 +448,7 @@ private:
/** /**
* Event Company Bankrupt, indicating a company has gone bankrupt. * Event Company Bankrupt, indicating a company has gone bankrupt.
* @api ai
*/ */
class ScriptEventCompanyBankrupt : public ScriptEvent { class ScriptEventCompanyBankrupt : public ScriptEvent {
public: public:
@ -468,6 +479,7 @@ private:
/** /**
* Event Vehicle Lost, indicating a vehicle can't find its way to its destination. * Event Vehicle Lost, indicating a vehicle can't find its way to its destination.
* @api ai
*/ */
class ScriptEventVehicleLost : public ScriptEvent { class ScriptEventVehicleLost : public ScriptEvent {
public: public:
@ -498,6 +510,7 @@ private:
/** /**
* Event VehicleWaitingInDepot, indicating a vehicle has arrived a depot and is now waiting there. * Event VehicleWaitingInDepot, indicating a vehicle has arrived a depot and is now waiting there.
* @api ai
*/ */
class ScriptEventVehicleWaitingInDepot : public ScriptEvent { class ScriptEventVehicleWaitingInDepot : public ScriptEvent {
public: public:
@ -528,6 +541,7 @@ private:
/** /**
* Event Vehicle Unprofitable, indicating a vehicle lost money last year. * Event Vehicle Unprofitable, indicating a vehicle lost money last year.
* @api ai
*/ */
class ScriptEventVehicleUnprofitable : public ScriptEvent { class ScriptEventVehicleUnprofitable : public ScriptEvent {
public: public:
@ -558,6 +572,7 @@ private:
/** /**
* Event Industry Open, indicating a new industry has been created. * Event Industry Open, indicating a new industry has been created.
* @api ai
*/ */
class ScriptEventIndustryOpen : public ScriptEvent { class ScriptEventIndustryOpen : public ScriptEvent {
public: public:
@ -588,6 +603,7 @@ private:
/** /**
* Event Industry Close, indicating an industry is going to be closed. * Event Industry Close, indicating an industry is going to be closed.
* @api ai
*/ */
class ScriptEventIndustryClose : public ScriptEvent { class ScriptEventIndustryClose : public ScriptEvent {
public: public:
@ -618,6 +634,7 @@ private:
/** /**
* Event Engine Available, indicating a new engine is available. * Event Engine Available, indicating a new engine is available.
* @api ai
*/ */
class ScriptEventEngineAvailable : public ScriptEvent { class ScriptEventEngineAvailable : public ScriptEvent {
public: public:
@ -648,6 +665,7 @@ private:
/** /**
* Event Station First Vehicle, indicating a station has been visited by a vehicle for the first time. * Event Station First Vehicle, indicating a station has been visited by a vehicle for the first time.
* @api ai
*/ */
class ScriptEventStationFirstVehicle : public ScriptEvent { class ScriptEventStationFirstVehicle : public ScriptEvent {
public: public:
@ -687,6 +705,7 @@ private:
/** /**
* Event Disaster Zeppeliner Crashed, indicating a zeppeliner has crashed on an airport and is blocking the runway. * Event Disaster Zeppeliner Crashed, indicating a zeppeliner has crashed on an airport and is blocking the runway.
* @api ai
*/ */
class ScriptEventDisasterZeppelinerCrashed : public ScriptEvent { class ScriptEventDisasterZeppelinerCrashed : public ScriptEvent {
public: public:
@ -717,6 +736,7 @@ private:
/** /**
* Event Disaster Zeppeliner Cleared, indicating a previously crashed zeppeliner has been removed, and the airport is operating again. * Event Disaster Zeppeliner Cleared, indicating a previously crashed zeppeliner has been removed, and the airport is operating again.
* @api ai
*/ */
class ScriptEventDisasterZeppelinerCleared : public ScriptEvent { class ScriptEventDisasterZeppelinerCleared : public ScriptEvent {
public: public:
@ -747,6 +767,7 @@ private:
/** /**
* Event Town Founded, indicating a new town has been created. * Event Town Founded, indicating a new town has been created.
* @api ai
*/ */
class ScriptEventTownFounded : public ScriptEvent { class ScriptEventTownFounded : public ScriptEvent {
public: public:

View File

@ -20,6 +20,7 @@
* Execute. The original mode is stored and recovered from when ever the * Execute. The original mode is stored and recovered from when ever the
* instance is destroyed. * instance is destroyed.
* In Execute mode all commands you do are executed for real. * In Execute mode all commands you do are executed for real.
* @api ai
*/ */
class ScriptExecMode : public ScriptObject { class ScriptExecMode : public ScriptObject {
private: private:

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all game settings related functions. * Class that handles all game settings related functions.
* @api ai
* *
* @note ScriptGameSettings::IsValid and ScriptGameSettings::GetValue are functions * @note ScriptGameSettings::IsValid and ScriptGameSettings::GetValue are functions
* that rely on the settings as OpenTTD stores them in savegame and * that rely on the settings as OpenTTD stores them in savegame and

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all group related functions. * Class that handles all group related functions.
* @api ai
*/ */
class ScriptGroup : public ScriptObject { class ScriptGroup : public ScriptObject {
public: public:

View File

@ -17,6 +17,7 @@
/** /**
* Creates a list of groups of which you are the owner. * Creates a list of groups of which you are the owner.
* @note Neither ScriptGroup::GROUP_ALL nor ScriptGroup::GROUP_DEFAULT is in this list. * @note Neither ScriptGroup::GROUP_ALL nor ScriptGroup::GROUP_DEFAULT is in this list.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptGroupList : public ScriptList { class ScriptGroupList : public ScriptList {

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all industry related functions. * Class that handles all industry related functions.
* @api ai
*/ */
class ScriptIndustry : public ScriptObject { class ScriptIndustry : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Creates a list of industries that are currently on the map. * Creates a list of industries that are currently on the map.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptIndustryList : public ScriptList { class ScriptIndustryList : public ScriptList {
@ -25,6 +26,7 @@ public:
/** /**
* Creates a list of industries that accepts a given cargo. * Creates a list of industries that accepts a given cargo.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptIndustryList_CargoAccepting : public ScriptList { class ScriptIndustryList_CargoAccepting : public ScriptList {
@ -38,6 +40,7 @@ public:
/** /**
* Creates a list of industries that can produce a given cargo. * Creates a list of industries that can produce a given cargo.
* @note It also contains industries that currently produces 0 units of the cargo. * @note It also contains industries that currently produces 0 units of the cargo.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptIndustryList_CargoProducing : public ScriptList { class ScriptIndustryList_CargoProducing : public ScriptList {

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all industry-type related functions. * Class that handles all industry-type related functions.
* @api ai
*/ */
class ScriptIndustryType : public ScriptObject { class ScriptIndustryType : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Creates a list of valid industry types. * Creates a list of valid industry types.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptIndustryTypeList : public ScriptList { class ScriptIndustryTypeList : public ScriptList {

View File

@ -21,6 +21,7 @@ class ScriptListSorter;
/** /**
* Class that creates a list which can keep item/value pairs, which you can walk. * Class that creates a list which can keep item/value pairs, which you can walk.
* @api ai
*/ */
class ScriptList : public ScriptObject { class ScriptList : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all log related functions. * Class that handles all log related functions.
* @api ai
*/ */
class ScriptLog : public ScriptObject { class ScriptLog : public ScriptObject {
/* ScriptController needs access to Enum and Log, in order to keep the flow from /* ScriptController needs access to Enum and Log, in order to keep the flow from
@ -23,10 +24,10 @@ class ScriptLog : public ScriptObject {
friend class ScriptController; friend class ScriptController;
public: public:
#ifndef EXPORT_SKIP
/** /**
* Log levels; The value is also feed to DEBUG() lvl. * Log levels; The value is also feed to DEBUG() lvl.
* This has no use for you, as AI writer. * This has no use for you, as AI writer.
* @api -all
*/ */
enum ScriptLogType { enum ScriptLogType {
LOG_SQ_ERROR = 0, ///< Squirrel printed an error. LOG_SQ_ERROR = 0, ///< Squirrel printed an error.
@ -39,6 +40,7 @@ public:
/** /**
* Internal representation of the log-data inside the AI. * Internal representation of the log-data inside the AI.
* This has no use for you, as AI writer. * This has no use for you, as AI writer.
* @api -all
*/ */
struct LogData { struct LogData {
char **lines; ///< The log-lines. char **lines; ///< The log-lines.
@ -47,7 +49,6 @@ public:
int pos; ///< Current position in lines. int pos; ///< Current position in lines.
int used; ///< Total amount of used log-lines. int used; ///< Total amount of used log-lines.
}; };
#endif /* EXPORT_SKIP */
/** /**
* Print an Info message to the logs. * Print an Info message to the logs.
@ -67,13 +68,11 @@ public:
*/ */
static void Error(const char *message); static void Error(const char *message);
#ifndef EXPORT_SKIP
/** /**
* Free the log pointer. * Free the log pointer.
* @note DO NOT CALL YOURSELF; leave it to the internal AI programming. * @api -all
*/ */
static void FreeLogPointer(); static void FreeLogPointer();
#endif /* EXPORT_SKIP */
private: private:
/** /**

View File

@ -17,6 +17,7 @@
/** /**
* Class that handles all map related functions. * Class that handles all map related functions.
* @api ai
*/ */
class ScriptMap : public ScriptObject { class ScriptMap : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all marine related functions. * Class that handles all marine related functions.
* @api ai
*/ */
class ScriptMarine : public ScriptObject { class ScriptMarine : public ScriptObject {
public: public:

View File

@ -29,10 +29,10 @@ typedef bool (ScriptModeProc)();
* your script, as it doesn't publish any public functions. It is used * your script, as it doesn't publish any public functions. It is used
* internally to have a common place to handle general things, like internal * internally to have a common place to handle general things, like internal
* command processing, and command-validation checks. * command processing, and command-validation checks.
* @api none
*/ */
class ScriptObject : public SimpleCountedObject { class ScriptObject : public SimpleCountedObject {
friend class ScriptInstance; friend class ScriptInstance;
#ifndef DOXYGEN_AI_DOCS
protected: protected:
/** /**
* A class that handles the current active instance. By instantiating it at * A class that handles the current active instance. By instantiating it at
@ -239,7 +239,6 @@ private:
* @param group_id The new GroupID. * @param group_id The new GroupID.
*/ */
static void SetNewGroupID(GroupID group_id); static void SetNewGroupID(GroupID group_id);
#endif /* DOXYGEN_AI_DOCS */
}; };
#endif /* SCRIPT_OBJECT_HPP */ #endif /* SCRIPT_OBJECT_HPP */

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all order related functions. * Class that handles all order related functions.
* @api ai
*/ */
class ScriptOrder : public ScriptObject { class ScriptOrder : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all rail related functions. * Class that handles all rail related functions.
* @api ai
*/ */
class ScriptRail : public ScriptObject { class ScriptRail : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Creates a list of all available railtypes. * Creates a list of all available railtypes.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptRailTypeList : public ScriptList { class ScriptRailTypeList : public ScriptList {

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all road related functions. * Class that handles all road related functions.
* @api ai
*/ */
class ScriptRoad : public ScriptObject { class ScriptRoad : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all sign related functions. * Class that handles all sign related functions.
* @api ai
*/ */
class ScriptSign : public ScriptObject { class ScriptSign : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Create a list of signs your company has created. * Create a list of signs your company has created.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptSignList : public ScriptList { class ScriptSignList : public ScriptList {

View File

@ -17,6 +17,7 @@
/** /**
* Class that handles all station related functions. * Class that handles all station related functions.
* @api ai
*/ */
class ScriptStation : public ScriptBaseStation { class ScriptStation : public ScriptBaseStation {
public: public:

View File

@ -17,6 +17,7 @@
/** /**
* Creates a list of stations of which you are the owner. * Creates a list of stations of which you are the owner.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptStationList : public ScriptList { class ScriptStationList : public ScriptList {
@ -29,6 +30,7 @@ public:
/** /**
* Creates a list of stations which the vehicle has in its orders. * Creates a list of stations which the vehicle has in its orders.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptStationList_Vehicle : public ScriptList { class ScriptStationList_Vehicle : public ScriptList {

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all subsidy related functions. * Class that handles all subsidy related functions.
* @api ai
*/ */
class ScriptSubsidy : public ScriptObject { class ScriptSubsidy : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Creates a list of all current subsidies. * Creates a list of all current subsidies.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptSubsidyList : public ScriptList { class ScriptSubsidyList : public ScriptList {

View File

@ -22,6 +22,7 @@
* In Test mode all the commands you execute aren't really executed. The * In Test mode all the commands you execute aren't really executed. The
* system only checks if it would be able to execute your requests, and what * system only checks if it would be able to execute your requests, and what
* the cost would be. * the cost would be.
* @api ai
*/ */
class ScriptTestMode : public ScriptObject { class ScriptTestMode : public ScriptObject {
private: private:

View File

@ -17,6 +17,7 @@
/** /**
* Class that handles all tile related functions. * Class that handles all tile related functions.
* @api ai
*/ */
class ScriptTile : public ScriptObject { class ScriptTile : public ScriptObject {
public: public:

View File

@ -17,6 +17,7 @@
/** /**
* Creates an empty list, in which you can add tiles. * Creates an empty list, in which you can add tiles.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptTileList : public ScriptList { class ScriptTileList : public ScriptList {
@ -57,6 +58,7 @@ public:
/** /**
* Creates a list of tiles that will accept cargo for the given industry. * Creates a list of tiles that will accept cargo for the given industry.
* @note If a simular industry is close, it might happen that this industry receives the cargo. * @note If a simular industry is close, it might happen that this industry receives the cargo.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptTileList_IndustryAccepting : public ScriptTileList { class ScriptTileList_IndustryAccepting : public ScriptTileList {
@ -73,6 +75,7 @@ public:
/** /**
* Creates a list of tiles which the industry checks to see if a station is * Creates a list of tiles which the industry checks to see if a station is
* there to receive cargo produced by this industry. * there to receive cargo produced by this industry.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptTileList_IndustryProducing : public ScriptTileList { class ScriptTileList_IndustryProducing : public ScriptTileList {
@ -89,6 +92,7 @@ public:
/** /**
* Creates a list of tiles which have the requested StationType of the * Creates a list of tiles which have the requested StationType of the
* StationID. * StationID.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptTileList_StationType : public ScriptTileList { class ScriptTileList_StationType : public ScriptTileList {

View File

@ -17,6 +17,7 @@
/** /**
* Class that handles all town related functions. * Class that handles all town related functions.
* @api ai
*/ */
class ScriptTown : public ScriptObject { class ScriptTown : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Creates a list of towns that are currently on the map. * Creates a list of towns that are currently on the map.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptTownList : public ScriptList { class ScriptTownList : public ScriptList {
@ -25,6 +26,7 @@ public:
/** /**
* Creates a list of all TownEffects known in the game. * Creates a list of all TownEffects known in the game.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptTownEffectList : public ScriptList { class ScriptTownEffectList : public ScriptList {

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all tunnel related functions. * Class that handles all tunnel related functions.
* @api ai
*/ */
class ScriptTunnel : public ScriptObject { class ScriptTunnel : public ScriptObject {
public: public:

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all vehicle related functions. * Class that handles all vehicle related functions.
* @api ai
*/ */
class ScriptVehicle : public ScriptObject { class ScriptVehicle : public ScriptObject {
public: public:

View File

@ -17,6 +17,7 @@
/** /**
* Creates a list of vehicles of which you are the owner. * Creates a list of vehicles of which you are the owner.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptVehicleList : public ScriptList { class ScriptVehicleList : public ScriptList {
@ -26,6 +27,7 @@ public:
/** /**
* Creates a list of vehicles that have orders to a given station. * Creates a list of vehicles that have orders to a given station.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptVehicleList_Station : public ScriptList { class ScriptVehicleList_Station : public ScriptList {
@ -43,6 +45,7 @@ public:
* aircraft having a depot order on a hangar of that airport will be * aircraft having a depot order on a hangar of that airport will be
* returned. For all other vehicle types the tile has to be a depot or * returned. For all other vehicle types the tile has to be a depot or
* an empty list will be returned. * an empty list will be returned.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptVehicleList_Depot : public ScriptList { class ScriptVehicleList_Depot : public ScriptList {
@ -55,6 +58,7 @@ public:
/** /**
* Creates a list of vehicles that share orders. * Creates a list of vehicles that share orders.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptVehicleList_SharedOrders : public ScriptList { class ScriptVehicleList_SharedOrders : public ScriptList {
@ -67,6 +71,7 @@ public:
/** /**
* Creates a list of vehicles that are in a group. * Creates a list of vehicles that are in a group.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptVehicleList_Group : public ScriptList { class ScriptVehicleList_Group : public ScriptList {
@ -79,6 +84,7 @@ public:
/** /**
* Creates a list of vehicles that are in the default group. * Creates a list of vehicles that are in the default group.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptVehicleList_DefaultGroup : public ScriptList { class ScriptVehicleList_DefaultGroup : public ScriptList {

View File

@ -16,6 +16,7 @@
/** /**
* Class that handles all waypoint related functions. * Class that handles all waypoint related functions.
* @api ai
*/ */
class ScriptWaypoint : public ScriptBaseStation { class ScriptWaypoint : public ScriptBaseStation {
public: public:

View File

@ -17,6 +17,7 @@
/** /**
* Creates a list of waypoints of which you are the owner. * Creates a list of waypoints of which you are the owner.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptWaypointList : public ScriptList { class ScriptWaypointList : public ScriptList {
@ -29,6 +30,7 @@ public:
/** /**
* Creates a list of waypoints which the vehicle has in its orders. * Creates a list of waypoints which the vehicle has in its orders.
* @api ai
* @ingroup ScriptList * @ingroup ScriptList
*/ */
class ScriptWaypointList_Vehicle : public ScriptList { class ScriptWaypointList_Vehicle : public ScriptList {