y_remote.inc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*----------------------------------------------------------------------------*\
  2. ==========
  3. y_remote
  4. ==========
  5. Description:
  6. Wrapper for "__CallRemoteFunction". Enforces some features like no returns
  7. and arrays being followed by their length.
  8. Legal:
  9. Version: MPL 1.1
  10. The contents of this file are subject to the Mozilla Public License Version
  11. 1.1 (the "License"); you may not use this file except in compliance with
  12. the License. You may obtain a copy of the License at
  13. http://www.mozilla.org/MPL/
  14. Software distributed under the License is distributed on an "AS IS" basis,
  15. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  16. for the specific language governing rights and limitations under the
  17. License.
  18. The Original Code is the YSI master systems include.
  19. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  20. Portions created by the Initial Developer are Copyright (C) 2011
  21. the Initial Developer. All Rights Reserved.
  22. Contributors:
  23. ZeeX, koolk, JoeBullet/Google63, g_aSlice/Slice
  24. Thanks:
  25. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  26. ZeeX - Very productive conversations.
  27. koolk - IsPlayerinAreaEx code.
  28. TheAlpha - Danish translation.
  29. breadfish - German translation.
  30. Fireburn - Dutch translation.
  31. yom - French translation.
  32. 50p - Polish translation.
  33. Zamaroht - Spanish translation.
  34. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes
  35. for me to strive to better.
  36. Pixels^ - Running XScripters where the idea was born.
  37. Matite - Pestering me to release it and using it.
  38. Very special thanks to:
  39. Thiadmer - PAWN, whose limits continue to amaze me!
  40. Kye/Kalcor - SA:MP.
  41. SA:MP Team past, present and future - SA:MP.
  42. Version:
  43. 1.0
  44. Changelog:
  45. -
  46. Functions:
  47. Public:
  48. -
  49. Core:
  50. -
  51. Stock:
  52. -
  53. Static:
  54. -
  55. Inline:
  56. -
  57. API:
  58. -
  59. Hooks:
  60. -
  61. Callbacks:
  62. -
  63. Definitions:
  64. -
  65. Enums:
  66. -
  67. Macros:
  68. remote - Define a function to be called remotely (use like "stock").
  69. broadcastfunc - Call the function, but in all scripts.
  70. local - Call the function by name, not address, in the current script.
  71. Tags:
  72. -
  73. Variables:
  74. Global:
  75. -
  76. Static:
  77. -
  78. Commands:
  79. -
  80. Compile options:
  81. -
  82. Operators:
  83. -
  84. Natives:
  85. -
  86. \*----------------------------------------------------------------------------*/
  87. #include "internal\y_version"
  88. #include "internal\y_shortfunc"
  89. #include "y_utils"
  90. // IMPORTANT NOTE! To avoid polluting the global name space (any more that is),
  91. // "y_inline" uses @Ru, @Rv, @Rw, @Rx and @Ry, as both files are low usage.
  92. // "y_testing" uses @Rf-@Ro.
  93. //#define remote remote%0(%1) stock%0@(%1)if(J@)W@(#%0,@Ra:@Rb:@Rc:#i#,I@);
  94. //#define remote%0(%1) stock%0@(%1) {return I@==-1?(J@?(W@(_:@Rz:#%0##,_YM@CR:%1,,))
  95. //#define remote%0(%1) stock%0@(%1)return I@==-1?(J@?(W@(_:@Rz:#%0##,_YM@CR:%1,,)):(P@(#%0))):(W@(#%0_@));%0_@(__m,%1);%0(%1);public %0_@(__m,%1)
  96. #define remotefunc%0(%1) stock%0_(%1)return J@?(W@(_:@Rz:#%0@##,_YM@CR:%1,,)):(%0());%0@(__m);public %0@(__m)if(__m==-1||__m==_@)%0();%0(%1)
  97. //:(P@(#%0##%1,,))):(W@(#%0_@##%1,,));%0(%1);}//_YM@CT:%0_@(%1,_YM@CU);public _YM@CT:%0_@(%1,_YM@CU)//if(_@==_:_YM@CV:_YM@CU)%0(%1,,);public%0(%1)
  98. //if(FALSE){}else
  99. //#define _YM@CR:%0,%1)):P@(%0##%2,%3))): @Ra:@Rb:@Rc:##|||%0|||%1)):P@(%0##,##|||%2|||%3))):
  100. // One macro to rule them all. Instead of doing the parameter validation and
  101. // extraction multiple times, we just do it once and copy the values when we're
  102. // done with them all. The macro is designed to be almost entirely right if the
  103. // function has no parameters.
  104. #define _YM@CR:%0,%1) @Ra:@Rb:@Rc:##|||%0|||%1)
  105. #define @Ra:@Rb:@Rc:#%0#%1|||%3[%4]%9|||%5,%6) @Rd:@Re:#%0#%1|||%3|||%5,%6)
  106. #define @Rd:@Re:#%0#%1|||%2string:%3|||%5,%6) @Ra:@Rb:@Rc:#%0s#%1,%3|||%5|||%6)
  107. #define @Re:#%0#%1|||%3|||%5,%6,%7) @Ra:@Rb:@Rc:#%0a#%1,%3|||%5|||%6,%7)
  108. #define @Rb:@Rc:#%0#%1|||%3|||%5,%6) @Ra:@Rb:@Rc:#%0i#%1,%3|||%5|||%6)
  109. #define @Rc:#%0#,%1||||||)):(%2());%3(__m);%5(__m)if(%7)%8();%4(%6) #%0i,%1,I@)):(%2(%1));%3(%6,__m);%5(%6,__m)if(%7)%8(%1);%4(%6)
  110. #define @Rz:#%0##,_YM@CR:,,) #%0,#i,I@)
  111. //#define __m,) __m)
  112. #define localfunc%0(%1) (J@=0,I@=-1,%0_(%1))
  113. #define broadcastfunc%0(%1) (J@=1,I@=-1,%0_(%1))
  114. // This cunningly supports "target<master> func()" and "target func<master>()".
  115. #define targetfunc%3<%2>%0(%1) (J@=1,I@=(%2),%3%0_(%1))
  116. /*#define @Rp:#%0##,_YM@CR:,I@,,) #%0##,#i,I@)
  117. #define local%0(%1) (J@=0,%0@(%1))
  118. #define broadcastfunc%0(%1) (J@=1,I@=-1,%0@(%1))
  119. #define target%0(%1)<%2> (J@=1,I@=(%2),%0@(%1))
  120. #define _YM@CT:%0(,%1) _YM@CT:%0(__m)
  121. //#define @Rq:@Rr:@Rs:@Rt:__m)%0(%1|||%2string:%3[%4]%9|||%7,%8) @Rq:@Rr:@Rs:@Rt:__m)%0(%1,%3|||%7|||%8)
  122. //#define @Rr:@Rs:@Rt:__m)%0(%1|||%3[%4]%9|||%7,%8) @Rq:@Rr:@Rs:@Rt:__m)%0(%1,%3|||%7|||%8)
  123. //#define @Rs:@Rt:__m)%0(%1|||%3|||%7,%8) @Rq:@Rr:@Rs:@Rt:__m)%0(%1,%3|||%7|||%8)
  124. //#define @Rt:__m)%0(%1||||||) __m)%0(%1)
  125. #define _YM@CV:_YM@CU)%0(,,) __m)%0()
  126. #define _YM@CU)%0(%1,%2) @Rq:@Rr:@Rs:@Rt:__m)%0(|||%1|||%2)*/
  127. /*#define remote%0(%1) stock%0@(%1)if(J@)W@(_:@Rz:#%0##,_YM@CR:%1,,);else P@(_:@Rz:#%0##,_YM@CR:%1,,);%0(%1);public%0(%1)//if(FALSE){}else
  128. #define _YM@CR:%0,%1) @Ra:@Rb:@Rc:##|||%0|||%1)
  129. #define @Ra:@Rb:@Rc:#%0#%1|||%3[%4]|||%5,%6) @Rd:@Re:#%0#%1|||%3|||%5,%6)
  130. #define @Rd:@Re:#%0#%1|||%2string:%3|||%5,%6) @Ra:@Rb:@Rc:#%0s#%1,%3|||%5|||%6)
  131. #define @Re:#%0#%1|||%3|||%5,%6,%7) @Ra:@Rb:@Rc:#%0a#%1,%3|||%5|||%6,%7)
  132. #define @Rb:@Rc:#%0#%1|||%3|||%5,%6) @Ra:@Rb:@Rc:#%0i#%1,%3|||%5|||%6)
  133. #define @Rc:%0||||||) %0)
  134. #define @Rz:#%0##,_YM@CR:,,) #%0##,#i,I@)*/
  135. //if(I@==-1){if(J@);else ;}else ;
  136. //return I@==-1?(J@?():()):();
  137. //target Moo(5, 6)<7>;
  138. //target Moo<7>(5, 6);
  139. //target<7> Moo(5, 6);