1 module dlua.luaconf; 2 import dlua; 3 4 5 /* 6 ** $Id: luaconf.h,v 1.259.1.1 2017/04/19 17:29:57 roberto Exp $ 7 ** Configuration file for Lua 8 ** See Copyright Notice in lua.h 9 */ 10 11 import core.stdc.limits; 12 import core.stdc.stdint; 13 import core.stdc.stdlib; 14 import core.stdc.stdio; 15 import core.stdc.locale; 16 17 extern (C): 18 19 /* 20 ** =================================================================== 21 ** Search for "@@" to find all configurable definitions. 22 ** =================================================================== 23 */ 24 25 /* 26 ** {==================================================================== 27 ** System Configuration: macros to adapt (if needed) Lua to some 28 ** particular platform, for instance compiling it with 32-bit numbers or 29 ** restricting it to C89. 30 ** ===================================================================== 31 */ 32 33 /* 34 @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. You 35 ** can also define LUA_32BITS in the make file, but changing here you 36 ** ensure that all software connected to Lua will be compiled with the 37 ** same configuration. 38 */ 39 /* #define LUA_32BITS */ 40 41 /* 42 @@ LUA_USE_C89 controls the use of non-ISO-C89 features. 43 ** Define it if you want Lua to avoid the use of a few C99 features 44 ** or Windows-specific features on Windows. 45 */ 46 /* #define LUA_USE_C89 */ 47 48 /* 49 ** By default, Lua on Windows use (some) specific Windows features 50 */ 51 52 /* enable goodies for regular Windows */ 53 54 /* enable support for DLL */ 55 /* broadly, Windows is C89 */ 56 57 /* needs an extra library: -ldl */ 58 /* needs some extra libraries */ 59 60 /* MacOS does not need -ldl */ 61 /* needs an extra library: -lreadline */ 62 63 /* 64 @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for 65 ** C89 ('long' and 'double'); Windows always has '__int64', so it does 66 ** not need to use this case. 67 */ 68 69 /* 70 @@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'. 71 */ 72 /* avoid undefined shifts */ 73 enum LUAI_BITSINT = 32; 74 75 /* 'int' always must have at least 16 bits */ 76 77 /* 78 @@ LUA_INT_TYPE defines the type for Lua integers. 79 @@ LUA_FLOAT_TYPE defines the type for Lua floats. 80 ** Lua should work fine with any mix of these options (if supported 81 ** by your C compiler). The usual configurations are 64-bit integers 82 ** and 'double' (the default), 32-bit integers and 'float' (for 83 ** restricted platforms), and 'long'/'double' (for C compilers not 84 ** compliant with C99, which may not have support for 'long long'). 85 */ 86 87 /* predefined options for LUA_INT_TYPE */ 88 enum LUA_INT_INT = 1; 89 enum LUA_INT_LONG = 2; 90 enum LUA_INT_LONGLONG = 3; 91 92 /* predefined options for LUA_FLOAT_TYPE */ 93 enum LUA_FLOAT_FLOAT = 1; 94 enum LUA_FLOAT_DOUBLE = 2; 95 enum LUA_FLOAT_LONGDOUBLE = 3; 96 97 /* { */ 98 /* 99 ** 32-bit integers and 'float' 100 */ 101 /* use 'int' if big enough */ 102 103 /* otherwise use 'long' */ 104 105 /* }{ */ 106 /* 107 ** largest types available for C89 ('long' and 'double') 108 */ 109 110 /* } */ 111 112 /* 113 ** default configuration for 64-bit Lua ('long long' and 'double') 114 */ 115 116 enum LUA_INT_TYPE = LUA_INT_LONGLONG; 117 118 enum LUA_FLOAT_TYPE = LUA_FLOAT_DOUBLE; 119 120 /* }================================================================== */ 121 122 /* 123 ** {================================================================== 124 ** Configuration for Paths. 125 ** =================================================================== 126 */ 127 128 /* 129 ** LUA_PATH_SEP is the character that separates templates in a path. 130 ** LUA_PATH_MARK is the string that marks the substitution points in a 131 ** template. 132 ** LUA_EXEC_DIR in a Windows path is replaced by the executable's 133 ** directory. 134 */ 135 enum LUA_PATH_SEP = ";"; 136 enum LUA_PATH_MARK = "?"; 137 enum LUA_EXEC_DIR = "!"; 138 139 /* 140 @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for 141 ** Lua libraries. 142 @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for 143 ** C libraries. 144 ** CHANGE them if your machine has a non-conventional directory 145 ** hierarchy or if you want to install your libraries in 146 ** non-conventional directories. 147 */ 148 /* { */ 149 /* 150 ** In Windows, any exclamation mark ('!') in the path is replaced by the 151 ** path of the directory of the executable file of the current process. 152 */ 153 154 /* }{ */ 155 156 enum LUA_ROOT = "/usr/"; 157 /* } */ 158 159 /* 160 @@ LUA_DIRSEP is the directory separator (for submodules). 161 ** CHANGE it if your machine does not use "/" as the directory separator 162 ** and is not Windows. (On Windows Lua automatically uses "\".) 163 */ 164 165 enum LUA_DIRSEP = "/"; 166 167 /* }================================================================== */ 168 169 /* 170 ** {================================================================== 171 ** Marks for exported symbols in the C code 172 ** =================================================================== 173 */ 174 175 /* 176 @@ LUA_API is a mark for all core API functions. 177 @@ LUALIB_API is a mark for all auxiliary library functions. 178 @@ LUAMOD_API is a mark for all standard library opening functions. 179 ** CHANGE them if you need to define those functions in some special way. 180 ** For instance, if you want to create one Windows DLL with the core and 181 ** the libraries, you may want to use the following definition (define 182 ** LUA_BUILD_AS_DLL to get it). 183 */ 184 /* { */ 185 186 /* { */ 187 188 /* }{ */ 189 190 /* } */ 191 192 /* }{ */ 193 194 /* } */ 195 196 /* more often than not the libs go together with the core */ 197 // enum LUALIB_API = LUA_API; 198 // enum LUAMOD_API = LUALIB_API; 199 200 /* 201 @@ LUAI_FUNC is a mark for all extern functions that are not to be 202 ** exported to outside modules. 203 @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables 204 ** that are not to be exported to outside modules (LUAI_DDEF for 205 ** definitions and LUAI_DDEC for declarations). 206 ** CHANGE them if you need to mark them in some special way. Elf/gcc 207 ** (versions 3.2 and later) mark them as "hidden" to optimize access 208 ** when Lua is compiled as a shared library. Not all elf targets support 209 ** this attribute. Unfortunately, gcc does not offer a way to check 210 ** whether the target offers that support, and those without support 211 ** give a warning about it. To avoid these warnings, change to the 212 ** default definition. 213 */ /* { */ 214 /* }{ */ 215 216 /* } */ 217 218 // enum LUAI_DDEC = LUAI_FUNC; /* empty */ 219 220 /* }================================================================== */ 221 222 /* 223 ** {================================================================== 224 ** Compatibility with previous versions 225 ** =================================================================== 226 */ 227 228 /* 229 @@ LUA_COMPAT_5_2 controls other macros for compatibility with Lua 5.2. 230 @@ LUA_COMPAT_5_1 controls other macros for compatibility with Lua 5.1. 231 ** You can define it to get all options, or change specific options 232 ** to fit your specific needs. 233 */ 234 /* { */ 235 236 /* 237 @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated 238 ** functions in the mathematical library. 239 */ 240 241 /* 242 @@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'. 243 */ 244 245 /* 246 @@ LUA_COMPAT_IPAIRS controls the effectiveness of the __ipairs metamethod. 247 */ 248 249 /* 250 @@ LUA_COMPAT_APIINTCASTS controls the presence of macros for 251 ** manipulating other integer types (lua_pushunsigned, lua_tounsigned, 252 ** luaL_checkint, luaL_checklong, etc.) 253 */ 254 255 /* } */ 256 257 /* { */ 258 259 /* Incompatibilities from 5.2 -> 5.3 */ 260 261 /* 262 @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. 263 ** You can replace it with 'table.unpack'. 264 */ 265 266 /* 267 @@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'. 268 ** You can replace it with 'package.searchers'. 269 */ 270 271 /* 272 @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall. 273 ** You can call your C function directly (with light C functions). 274 */ 275 276 /* 277 @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. 278 ** You can rewrite 'log10(x)' as 'log(x, 10)'. 279 */ 280 281 /* 282 @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base 283 ** library. You can rewrite 'loadstring(s)' as 'load(s)'. 284 */ 285 286 /* 287 @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. 288 */ 289 290 /* 291 @@ The following macros supply trivial compatibility for some 292 ** changes in the API. The macros themselves document how to 293 ** change your code to avoid using them. 294 */ 295 296 /* 297 @@ LUA_COMPAT_MODULE controls compatibility with previous 298 ** module functions 'module' (Lua) and 'luaL_register' (C). 299 */ 300 301 /* } */ 302 303 /* 304 @@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a 305 @@ a float mark ('.0'). 306 ** This macro is not on by default even in compatibility mode, 307 ** because this is not really an incompatibility. 308 */ 309 /* #define LUA_COMPAT_FLOATSTRING */ 310 311 /* }================================================================== */ 312 313 /* 314 ** {================================================================== 315 ** Configuration for Numbers. 316 ** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_* 317 ** satisfy your needs. 318 ** =================================================================== 319 */ 320 321 /* 322 @@ LUA_NUMBER is the floating-point type used by Lua. 323 @@ LUAI_UACNUMBER is the result of a 'default argument promotion' 324 @@ over a floating number. 325 @@ l_mathlim(x) corrects limit name 'x' to the proper float type 326 ** by prefixing it with one of FLT/DBL/LDBL. 327 @@ LUA_NUMBER_FRMLEN is the length modifier for writing floats. 328 @@ LUA_NUMBER_FMT is the format for writing floats. 329 @@ lua_number2str converts a float to a string. 330 @@ l_mathop allows the addition of an 'l' or 'f' to all math operations. 331 @@ l_floor takes the floor of a float. 332 @@ lua_str2number converts a decimal numeric string to a number. 333 */ 334 335 /* The following definitions are good for most cases here */ 336 337 extern (D) auto l_floor(T)(auto ref T x) 338 { 339 return l_mathop(floor)(x); 340 } 341 342 extern (D) auto lua_number2str(T0, T1, T2)(auto ref T0 s, auto ref T1 sz, auto ref T2 n) 343 { 344 return l_sprintf(s, sz, LUA_NUMBER_FMT, double()); 345 } 346 347 /* 348 @@ lua_numbertointeger converts a float number to an integer, or 349 ** returns 0 if float is not within the range of a lua_Integer. 350 ** (The range comparisons are tricky because of rounding. The tests 351 ** here assume a two-complement representation, where MININTEGER always 352 ** has an exact representation as a float; MAXINTEGER may not have one, 353 ** and therefore its conversion to float may have an ill-defined value.) 354 */ 355 356 /* now the variable definitions */ /* { single float */ /* }{ long double */ /* }{ double */ 357 358 enum LUA_NUMBER;// = double; 359 360 extern (D) string l_mathlim(T)(auto ref T n) 361 { 362 import std.conv : to; 363 364 return "DBL_" ~ to!string(n); 365 } 366 367 enum LUAI_UACNUMBER;// = double; 368 369 enum LUA_NUMBER_FRMLEN = ""; 370 enum LUA_NUMBER_FMT = "%.14g"; 371 372 extern (D) auto l_mathop(T)(auto ref T op) 373 { 374 return op; 375 } 376 377 alias lua_str2number = strtod; 378 379 /* }{ */ 380 381 /* } */ 382 383 /* 384 @@ LUA_INTEGER is the integer type used by Lua. 385 ** 386 @@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. 387 ** 388 @@ LUAI_UACINT is the result of a 'default argument promotion' 389 @@ over a lUA_INTEGER. 390 @@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers. 391 @@ LUA_INTEGER_FMT is the format for writing integers. 392 @@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. 393 @@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. 394 @@ lua_integer2str converts an integer to a string. 395 */ 396 397 /* The following definitions are good for most cases here */ 398 399 enum LUAI_UACINT;// = LUA_INTEGER; 400 401 extern (D) auto lua_integer2str(T0, T1, T2)(auto ref T0 s, auto ref T1 sz, auto ref T2 n) 402 { 403 return l_sprintf(s, sz, LUA_INTEGER_FMT, long()); 404 } 405 406 /* 407 ** use LUAI_UACINT here to avoid problems with promotions (which 408 ** can turn a comparison between unsigneds into a signed comparison) 409 */ 410 411 /* now the variable definitions */ /* { int */ /* }{ long */ /* }{ long long */ 412 413 /* use presence of macro LLONG_MAX as proxy for C99 compliance */ /* { */ 414 /* use ISO C99 stuff */ 415 416 enum LUA_INTEGER; //= long; 417 enum LUA_INTEGER_FRMLEN = "ll"; 418 419 enum LUA_MAXINTEGER = LLONG_MAX; 420 enum LUA_MININTEGER = LLONG_MIN; 421 422 /* }{ */ 423 /* in Windows, can use specific Windows types */ 424 425 /* }{ */ 426 427 /* } */ 428 429 /* }{ */ 430 431 /* } */ 432 433 /* }================================================================== */ 434 435 /* 436 ** {================================================================== 437 ** Dependencies with C99 and other C details 438 ** =================================================================== 439 */ 440 441 /* 442 @@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89. 443 ** (All uses in Lua have only one format item.) 444 */ 445 446 alias l_sprintf = snprintf; 447 448 /* 449 @@ lua_strx2number converts an hexadecimal numeric string to a number. 450 ** In C99, 'strtod' does that conversion. Otherwise, you can 451 ** leave 'lua_strx2number' undefined and Lua will provide its own 452 ** implementation. 453 */ 454 455 alias lua_strx2number = lua_str2number; 456 457 /* 458 @@ lua_pointer2str converts a pointer to a readable string in a 459 ** non-specified way. 460 */ 461 extern (D) auto lua_pointer2str(T0, T1, T2)(auto ref T0 buff, auto ref T1 sz, auto ref T2 p) 462 { 463 return l_sprintf(buff, sz, "%p", p); 464 } 465 466 /* 467 @@ lua_number2strx converts a float to an hexadecimal numeric string. 468 ** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that. 469 ** Otherwise, you can leave 'lua_number2strx' undefined and Lua will 470 ** provide its own implementation. 471 */ 472 473 /* 474 ** 'strtof' and 'opf' variants for math functions are not valid in 475 ** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the 476 ** availability of these variants. ('math.h' is already included in 477 ** all files that use these macros.) 478 */ 479 480 /* variants not available */ 481 482 /* no variant */ 483 484 /* 485 @@ LUA_KCONTEXT is the type of the context ('ctx') for continuation 486 ** functions. It must be a numerical type; Lua will use 'intptr_t' if 487 ** available, otherwise it will use 'ptrdiff_t' (the nearest thing to 488 ** 'intptr_t' in C89) 489 */ 490 alias LUA_KCONTEXT = intptr_t; /* even in C99 this type is optional */ 491 492 // enum LUA_KCONTEXT = intptr_t; 493 494 /* 495 @@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). 496 ** Change that if you do not want to use C locales. (Code using this 497 ** macro must include header 'locale.h'.) 498 */ 499 500 extern (D) auto lua_getlocaledecpoint() 501 { 502 return localeconv().decimal_point[0]; 503 } 504 505 /* }================================================================== */ 506 507 /* 508 ** {================================================================== 509 ** Language Variations 510 ** ===================================================================== 511 */ 512 513 /* 514 @@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some 515 ** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from 516 ** numbers to strings. Define LUA_NOCVTS2N to turn off automatic 517 ** coercion from strings to numbers. 518 */ 519 /* #define LUA_NOCVTN2S */ 520 /* #define LUA_NOCVTS2N */ 521 522 /* 523 @@ LUA_USE_APICHECK turns on several consistency checks on the C API. 524 ** Define it as a help when debugging C code. 525 */ 526 527 /* }================================================================== */ 528 529 /* 530 ** {================================================================== 531 ** Macros that affect the API and must be stable (that is, must be the 532 ** same when you compile Lua and when you compile code that links to 533 ** Lua). You probably do not want/need to change them. 534 ** ===================================================================== 535 */ 536 537 /* 538 @@ LUAI_MAXSTACK limits the size of the Lua stack. 539 ** CHANGE it if you need a different limit. This limit is arbitrary; 540 ** its only purpose is to stop Lua from consuming unlimited stack 541 ** space (and to reserve some numbers for pseudo-indices). 542 */ 543 enum LUAI_MAXSTACK = 1000000; 544 545 /* 546 @@ LUA_EXTRASPACE defines the size of a raw memory area associated with 547 ** a Lua state with very fast access. 548 ** CHANGE it if you need a different size. 549 */ 550 enum LUA_EXTRASPACE = ptrdiff_t.sizeof; 551 552 /* 553 @@ LUA_IDSIZE gives the maximum size for the description of the source 554 @@ of a function in debug information. 555 ** CHANGE it if you want a different size. 556 */ 557 enum LUA_IDSIZE = 60; 558 559 /* 560 @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. 561 ** CHANGE it if it uses too much C-stack space. (For long double, 562 ** 'string.format("%.99f", -1e4932)' needs 5034 bytes, so a 563 ** smaller buffer would force a memory allocation for each call to 564 ** 'string.format'.) 565 */ 566 567 enum LUAL_BUFFERSIZE = cast(int) 0x80 * ptrdiff_t.sizeof * lua_Integer.sizeof; 568 569 /* }================================================================== */ 570 571 /* 572 @@ LUA_QL describes how error messages quote program elements. 573 ** Lua does not use these macros anymore; they are here for 574 ** compatibility only. 575 */ 576 // enum LUA_QS = LUA_QL("%s"); 577 578 /* =================================================================== */ 579 580 /* 581 ** Local configuration. You can use this space to add your redefinitions 582 ** without modifying the main part of the file. 583 */ 584