y_remote_macros.inc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. Legal:
  3. Version: MPL 1.1
  4. The contents of this file are subject to the Mozilla Public License Version
  5. 1.1 the "License"; you may not use this file except in compliance with
  6. the License. You may obtain a copy of the License at
  7. http://www.mozilla.org/MPL/
  8. Software distributed under the License is distributed on an "AS IS" basis,
  9. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  10. for the specific language governing rights and limitations under the
  11. License.
  12. The Original Code is the YSI framework.
  13. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  14. Portions created by the Initial Developer are Copyright C 2011
  15. the Initial Developer. All Rights Reserved.
  16. Contributors:
  17. Y_Less
  18. koolk
  19. JoeBullet/Google63
  20. g_aSlice/Slice
  21. Misiur
  22. samphunter
  23. tianmeta
  24. maddinat0r
  25. spacemud
  26. Crayder
  27. Dayvison
  28. Ahmad45123
  29. Zeex
  30. irinel1996
  31. Yiin-
  32. Chaprnks
  33. Konstantinos
  34. Masterchen09
  35. Southclaws
  36. PatchwerkQWER
  37. m0k1
  38. paulommu
  39. udan111
  40. Thanks:
  41. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  42. ZeeX - Very productive conversations.
  43. koolk - IsPlayerinAreaEx code.
  44. TheAlpha - Danish translation.
  45. breadfish - German translation.
  46. Fireburn - Dutch translation.
  47. yom - French translation.
  48. 50p - Polish translation.
  49. Zamaroht - Spanish translation.
  50. Los - Portuguese translation.
  51. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  52. me to strive to better.
  53. Pixels^ - Running XScripters where the idea was born.
  54. Matite - Pestering me to release it and using it.
  55. Very special thanks to:
  56. Thiadmer - PAWN, whose limits continue to amaze me!
  57. Kye/Kalcor - SA:MP.
  58. SA:MP Team past, present and future - SA:MP.
  59. Optional plugins:
  60. Gamer_Z - GPS.
  61. Incognito - Streamer.
  62. Me - sscanf2, fixes2, Whirlpool.
  63. */
  64. #define REMOTE_FUNC__%0(%1) FUNC_PARSER(Y_REMOTE,NUM_CST_DEF:STR_CST_DEF:REF_DEF:ARR_CST:QAL:RET_VOD_STR_TAG:LEN:)(%0(%1))(%1)#()()()(%1)
  65. #define LOCAL_FUNC__%0(%1) (J@=0,I@=-1,_@%0(%1))
  66. #define BROADCAST_FUNC__%0(%1) (J@=1,I@=-1,_@%0(%1))
  67. #define TARGET_FUNC__%0<%2>%9(%1) (J@=1,I@=(%2),_@%0(%1))
  68. #if YSI_KEYWORD(remotefunc)
  69. #define remotefunc REMOTE_FUNC__
  70. #endif
  71. #if YSI_KEYWORD(localfunc)
  72. #define localfunc LOCAL_FUNC__
  73. #endif
  74. #if YSI_KEYWORD(broadcastfunc)
  75. #define broadcastfunc BROADCAST_FUNC__
  76. #endif
  77. #if YSI_KEYWORD(targetfunc)
  78. #define targetfunc TARGET_FUNC__
  79. #endif
  80. // This code uses "i" for normal variables and "d" for references. These are
  81. // both seen by "CallRemoteFunction" as the same thing, but we can
  82. // differentiate them.
  83. #define Y_REMOTE_NUM(%0,%1,%2)%8$%4#%5(%7)(%9) %8$%4#%5i(%7,%2)(%9,%1%2)
  84. #define Y_REMOTE_STR(%0,%1,%2,%3)%8$%4#%5(%7)(%9) %8$%4#%5s(%7,%2)(%9,%1%2[%3])
  85. #define Y_REMOTE_ARR(%0,%1,%2,%3)%8$%4#%5(%7)(%9) %8$%4#%5a(%7,%2)(%9,%1%2[%3])
  86. #define Y_REMOTE_REF(%0,%1,%2)%8$%4#%5(%7)(%9)(%3) %8$%4#%5d(%7,%2)(%9,%1%2)(%3,%2)
  87. #define Y_REMOTE_NUM_DEF(%0,%1,%2,%9)%8$%4#%5(%7)(%9) %8$%4#%5i(%7,%2)(%9,%1%2)
  88. #define Y_REMOTE_STR_DEF(%0,%1,%2,%3,%9)%8$%4#%5(%7)(%9) %8$%4#%5s(%7,%2)(%9,%1%2[%3])
  89. #define Y_REMOTE_REF_DEF(%0,%1,%2,%9)%8$%4#%5(%7)(%9)(%3) %8$%4#%5d(%7,%2)(%9,%1%2)(%3,%2)
  90. // Use this to force insert a space. Just "stock " doesn't work.
  91. #define Y_REMOTE_stock()%8$ %8$stock PP_NULL<>
  92. #define Y_REMOTE_static()%8$ %8$static PP_NULL<>
  93. #define Y_REMOTE_END(%9)%8$%4(%1)%3(,%7)(,%2)(%0)(%6) %8$%4 _@%9(%1)return F@(J@,I@),D@(YREMOTE_END:#@@%9,%3i,%7);@@%9(%2,__m)(%7)(%0)(%6)
  94. #define Y_REMOTE_END_STR(%9)%8$%4(%1)%3(,%7)(,%2)(%0)(%6) %8$%4 _@%9(%1)return F@(J@,I@),C@(YREMOTE_STR:#@@%9,%3i,%7);@@%9(%2,__m)(%7)(%0)(%6)
  95. #define Y_REMOTE_END_VOD(%9)%8$%4(%1)%3(,%7)(,%2)(%0)(%6) %8$%4 _@%9(%1)F@(J@,I@),D@(YREMOTE_VOD:#@@%9,%3i,%7);@@%9(%2,__m)(%7)(%0)(%6)
  96. #define Y_REMOTE_END_TAG(%5,%9)%8$%4(%1)%3(,%7)(,%2)(%0)(%6) %8$%4%5 _@%9(%1)return F@(J@,I@),%5D@(YREMOTE_TAG:#@@%9,%3i,%7);@@%9(%2,__m)(%7)(%0)(%6)%5
  97. #define Y_REMOTE_NUL(%9)%8$%4(%1)%3(%7)(%2)(%0)(%6) %8$%4 _@%9()return F@(J@,I@),D@(YREMOTE_END:#@@%9,#i);@@%9(__m)()()()
  98. #define Y_REMOTE_NUL_STR(%9)%8$%4(%1)%3(%7)(%2)(%0)(%6) %8$%4 _@%9()return F@(J@,I@),C@(YREMOTE_STR:#@@%9,#i);@@%9(__m)()()()
  99. #define Y_REMOTE_NUL_VOD(%9)%8$%4(%1)%3(%7)(%2)(%0)(%6) %8$%4 _@%9()F@(J@,I@),D@(YREMOTE_VOD:#@@%9,#i);@@%9(__m)()()()
  100. #define Y_REMOTE_NUL_TAG(%5,%9)%8$%4(%1)%3(%7)(%2)(%0)(%6) %8$%4%5 _@%9()return F@(J@,I@),%5D@(YREMOTE_TAG:#@@%9,#i);@@%9(__m)()()()%5
  101. #define YREMOTE_END:%0);@@%1(%2)(%3)(%4)(%6) %0);I@R:@@%1(%2);I@R:@@%1(%2)return I@R:((__m&@_)&&L@(%1(%3)%4));%1(%6)
  102. #define YREMOTE_STR:%0);@@%1(%2)(%3)(%4)(%6) %0);I@R:@@%1(%2);I@R:@@%1(%2)return I@R:((__m&@_)&&T@(%1(%3)%4));%1(%6)
  103. #define YREMOTE_VOD:%0);@@%1(%2)(%3)(%4)(%6) %0);I@R:@@%1(%2);I@R:@@%1(%2)return I@R:((__m&@_)&&(%1(%3),L@(0%4)));%1(%6)
  104. #define YREMOTE_TAG:%0);@@%1(%2)(%3)(%4)(%6)%5: %0);I@P:@@%1(%2);%5:%1(%6);I@P:@@%1(%2)return I@P:((__m&@_)&&L@(%1(%3)%4));%5:%1(%6)
  105. // If someone does:
  106. //
  107. // remotefunc X();
  108. //
  109. // Assume that this is purely a forwarding declaration. Make the function
  110. // uncallable.
  111. #define I@R:%9;%9;%9; static stock %9{}
  112. #define I@P:%9;%9;%9;%9; static stock %9{}