y_va.inc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #if defined _INC_y_va
  2. #endinput
  3. #endif
  4. #define _INC_y_va
  5. /**
  6. * <library name="y_va">
  7. * <section>
  8. * Description
  9. * </section>
  10. * This library currently provides two functions - va_printf and va_format
  11. * which perform printf and format using variable arguments passed to another
  12. * function.
  13. *
  14. * This is bsed on the variable parameter passing method based on code by Zeex.
  15. * See page 15 of the code optimisations topic.
  16. * <section>
  17. * Version
  18. * </section>
  19. * 1.0
  20. * </library>
  21. *//** *//*
  22. Legal:
  23. Version: MPL 1.1
  24. The contents of this file are subject to the Mozilla Public License Version
  25. 1.1 the "License"; you may not use this file except in compliance with
  26. the License. You may obtain a copy of the License at
  27. http://www.mozilla.org/MPL/
  28. Software distributed under the License is distributed on an "AS IS" basis,
  29. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  30. for the specific language governing rights and limitations under the
  31. License.
  32. The Original Code is the YSI framework.
  33. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  34. Portions created by the Initial Developer are Copyright C 2011
  35. the Initial Developer. All Rights Reserved.
  36. Contributors:
  37. Y_Less
  38. koolk
  39. JoeBullet/Google63
  40. g_aSlice/Slice
  41. Misiur
  42. samphunter
  43. tianmeta
  44. maddinat0r
  45. spacemud
  46. Crayder
  47. Dayvison
  48. Ahmad45123
  49. Zeex
  50. irinel1996
  51. Yiin-
  52. Chaprnks
  53. Konstantinos
  54. Masterchen09
  55. Southclaws
  56. PatchwerkQWER
  57. m0k1
  58. paulommu
  59. udan111
  60. Thanks:
  61. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  62. ZeeX - Very productive conversations.
  63. koolk - IsPlayerinAreaEx code.
  64. TheAlpha - Danish translation.
  65. breadfish - German translation.
  66. Fireburn - Dutch translation.
  67. yom - French translation.
  68. 50p - Polish translation.
  69. Zamaroht - Spanish translation.
  70. Los - Portuguese translation.
  71. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  72. me to strive to better.
  73. Pixels^ - Running XScripters where the idea was born.
  74. Matite - Pestering me to release it and using it.
  75. Very special thanks to:
  76. Thiadmer - PAWN, whose limits continue to amaze me!
  77. Kye/Kalcor - SA:MP.
  78. SA:MP Team past, present and future - SA:MP.
  79. Optional plugins:
  80. Gamer_Z - GPS.
  81. Incognito - Streamer.
  82. Me - sscanf2, fixes2, Whirlpool.
  83. */
  84. #if 0
  85. // Example:
  86. stock MyPrintf(const format[], {Float, File, _}:...)
  87. {
  88. // The triple underscore is used to mirror the triple dots in the
  89. // function definition. You can't easily tell it is three from a
  90. // glance, but it is.
  91. printf(format, ___1); // Or `___(1)`.
  92. print("Printed many things");
  93. return 42;
  94. }
  95. #endif
  96. #define ___ YVA2_DummyPush()
  97. // For optional parameter skips.
  98. #define YVA2_DummyPush()(%1) YVA2_DummyPush((%1) * 4)
  99. // Shortcuts.
  100. #define ___0 ___(0)
  101. #define ___1 ___(1)
  102. #define ___2 ___(2)
  103. #define ___3 ___(3)
  104. #define ___4 ___(4)
  105. #define ___5 ___(5)
  106. #define ___6 ___(6)
  107. #define ___7 ___(7)
  108. #define ___8 ___(8)
  109. #define ___9 ___(9)
  110. #include "..\YSI_Internal\y_globaltags"
  111. #define va_args<%0> GLOBAL_TAG_TYPES:...
  112. #define va_start<%0> ___(%0)
  113. // Detect Slice's va_formatex function, which now doesn't need to exist. This
  114. // is my first ever use of `#pragma deprecated`! Actually quite happy about
  115. // that - it's one of the few language features I've never used in earnest, so
  116. // its almost an occassion when that happens.
  117. #pragma deprecated Use formatex instead
  118. forward va_formatex(output[], size = sizeof(output), const fmat[], va_:STATIC_ARGS);
  119. // Backwards compatability.
  120. native va_printf (const format[], GLOBAL_TAG_TYPES:...) = printf;
  121. native va_CallRemoteFunction(const function[], const format[], GLOBAL_TAG_TYPES:...) = CallRemoteFunction;
  122. native va_CallLocalFunction (const function[], const format[], GLOBAL_TAG_TYPES:...) = CallLocalFunction;
  123. native va_SetTimerEx (const function[], interval, repeating, const format[], GLOBAL_TAG_TYPES:...) = SetTimerEx;
  124. native va_format (output[], len, const format[], GLOBAL_TAG_TYPES:...) = format;
  125. #include "..\YSI_Internal\y_version"
  126. #include "..\YSI_Internal\y_funcinc"
  127. #include "..\YSI_Core\y_utils"
  128. #include "y_va/impl"
  129. #if defined YSI_TESTS
  130. #include "..\YSI_Core\y_testing"
  131. #include "y_va/tests"
  132. #endif