Files
@ r19448:41de09e68222
Branch filter:
Location: cpp/openttd-patchpack/source/src/script/api/doxygen_filter.awk - annotation
r19448:41de09e68222
6.2 KiB
application/x-awk
(svn r24365) -Fix-ish: add C(XX)FLAGS_BUILD to all the executables that are compiled for the build enviroment
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18752:7d19f6ab30ad r18752:7d19f6ab30ad r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18752:7d19f6ab30ad r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18752:7d19f6ab30ad r18520:b948d53210e6 r18752:7d19f6ab30ad r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18792:d321fdd7805e r18792:d321fdd7805e r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18775:9046421fec27 r18775:9046421fec27 r18775:9046421fec27 r18775:9046421fec27 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18661:ffdb4b1a55ef r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 r18520:b948d53210e6 | # $Id$
# This file is part of OpenTTD.
# 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.
# 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.
# 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/>.
#
# Awk script to automatically generate the code needed
# to export the script APIs to Squirrel.
#
# Note that arrays are 1 based...
#
BEGIN {
cls = ""
api_selected = ""
cls_in_api = ""
cls_level = 0
skip_function_body = "false"
skip_function_par = 0
RS = "\r|\n"
apis = tolower(api)
if (apis == "gs") apis = "game"
}
{
gsub(/Script/, api)
}
{
if (skip_function_body == "true") {
input = $0
gsub(/[^{]/, "", input)
skip_function_par += length(input)
if (skip_function_par > 0) {
input = $0
gsub(/[^}]/, "", input)
skip_function_par -= length(input)
if (skip_function_par == 0) skip_function_body = "false"
}
}
if (skip_function_body == "true") next
}
/@file/ {
gsub(/script/, apis)
}
/^([ ]*)\* @api/ {
if (api == "Script") {
api_selected = "true"
next
}
# By default, classes are not selected
if (cls_level == 0) api_selected = "false"
gsub("^([ ]*)", "", $0)
gsub("* @api ", "", $0)
if ($0 == "none") {
api_selected = "false"
} else if ($0 == "-all") {
api_selected = "false"
} else if (match($0, "-" apis)) {
api_selected = "false"
} else if (match($0, apis)) {
api_selected = "true"
}
next
}
# Ignore forward declarations of classes
/^( *)class(.*);/ { next; }
# We only want to have public functions exported for now
/^( *)class/ {
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"
cls_param[0] = ""
cls_param[1] = 1
cls_param[2] = "x"
cls_in_api = api_selected
api_selected = ""
cls = $2
if (cls_in_api == "true") {
print comment_buffer
print
print "public:"
comment_buffer = ""
}
} else if (cls_level == 1) {
if (api_selected == "") api_selected = cls_in_api
if (api_selected == "true") {
print comment_buffer
print
print "public:"
comment_buffer = ""
}
api_selected = ""
} else {
print "Classes nested too deep" > "/dev/stderr"
exit 1
}
cls_level++
next
}
/^( *)public/ { if (cls_level == 1) comment_buffer = ""; public = "true"; next; }
/^( *)protected/ { if (cls_level == 1) comment_buffer = ""; public = "false"; next; }
/^( *)private/ { if (cls_level == 1) comment_buffer = ""; public = "false"; next; }
# Ignore special doxygen blocks
/^#ifndef DOXYGEN_API/ { doxygen_skip = "true"; next; }
/^#ifdef DOXYGEN_API/ { doxygen_skip = "next"; next; }
/^#endif \/\* DOXYGEN_API \*\// { doxygen_skip = "false"; next; }
/^#else/ {
if (doxygen_skip == "next") {
doxygen_skip = "true";
} else {
doxygen_skip = "false";
}
next;
}
{ if (doxygen_skip == "true") next }
/^#/ {
next
}
# Store comments
/\/\*\*.*\*\// { comment_buffer = $0; comment = "false"; next; }
/\/\*.*\*\// { comment_buffer = ""; comment = "false"; next; }
/\/\*\*/ { comment_buffer = $0 "\n"; comment = "true"; next; }
/\/\*/ { comment_buffer = ""; comment = "false"; next; }
/\*\// { comment_buffer = comment_buffer $0; comment = "false"; next; }
{
if (comment == "true" && !match($0, /@api/))
{
if (match($0, /@game /) && api != "GS") next;
if (match($0, /@ai /) && api != "AI") next;
gsub("@game ", "", $0);
gsub("@ai ", "", $0);
comment_buffer = comment_buffer $0 "\n"; next;
}
}
# We need to make specialized conversions for structs
/^( *)struct/ {
comments_so_far = comment_buffer
comment_buffer = ""
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
print comments_so_far
print $0
next
}
# We need to make specialized conversions for enums
/^( *)enum/ {
comments_so_far = comment_buffer
comment_buffer = ""
cls_level++
# 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"
print comments_so_far
print $0
next
}
# Maybe the end of the class, if so we can start with the Squirrel export pretty soon
/};/ {
comment_buffer = ""
cls_level--
if (cls_level != 0) {
if (in_enum == "true") print
in_enum = "false"
next
}
if (cls == "") {
next
}
if (cls_in_api == "true") print
next;
}
# Empty/white lines
/^([ ]*)$/ {
print $0
next
}
# Skip non-public functions
{ if (public == "false") next }
# Add enums
{
if (in_enum == "true") {
print comment_buffer
comment_buffer = ""
gsub("=([^/]*),", ",", $0)
print $0
# Check if this a special error enum
if (match(enums[enum_size], ".*::ErrorMessages") != 0) {
# syntax:
# enum ErrorMessages {
# ERR_SOME_ERROR, // [STR_ITEM1, STR_ITEM2, ...]
# }
##TODO: don't print the STR_*
}
next
}
}
# Add a const (non-enum) value
/^[ ]*static const \w+ \w+ = -?\(?\w*\)?\w+;/ {
if (api_selected == "") api_selected = cls_in_api
if (api_selected == "false") {
api_selected = ""
comment_buffer = ""
next
}
print comment_buffer
print $0
comment_buffer = ""
next
}
# Add a method to the list
/^.*\(.*\).*$/ {
if (cls_level != 1) next
if (!match($0, ";")) {
gsub(/ :$/, ";")
skip_function_body = "true"
}
if (match($0, "~")) {
if (api_selected != "") {
print "Destructor for '"cls"' has @api. Tag ignored." > "/dev/stderr"
api_selected = ""
}
next
}
# Check if we want to publish this function
if (api_selected == "") api_selected = cls_in_api
if (api_selected == "false") {
api_selected = ""
comment_buffer = ""
next
}
api_selected = ""
print comment_buffer
print $0
comment_buffer = ""
next
}
|