core_ScriptBinding.dox 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. // Warning! This file is not real C++ code!
  23. // It is designed to provide types, operators, and more that are needed by Doxygen
  24. // to create a TorqueScript reference.
  25. // As long as this file ends in .dox, compilers should ignore it, but Doxygen won't.
  26. // This means the psuedo-code in here will not be seen by your compiler but it will
  27. // be seen by the Doxygen code parser.
  28. // Add any constructs here that you want to use to "fake-out" Doxygen while creating
  29. // the Torquescript doc.
  30. //-----------------------------------------------------
  31. // TorqueScript Functions
  32. //-----------------------------------------------
  33. // Most functions will be defined in _ScriptBinding.h files.
  34. // Here we are only defining a doxygen group, called TorqueScriptFunctions,
  35. // for all functions to live within. This is necessary as Doxygen ignores global
  36. // functions unless they in a group. But it also helps organize the "modules" page of
  37. // the Doxygen output.
  38. // Clusters of functions -- such as vector functions or event scheduling functions --
  39. // should be kept within a subgroup of the TorqueScriptFunction umbrella group.
  40. // As groups are created, in various _ScriptBinding.h files, they should be marked as
  41. // @ingroup TorqueScriptFunctions like so:
  42. //
  43. // /*! @defgroup VectorMathFunctions Vector Math
  44. // @ingroup TorqueScriptFunctions
  45. // @{
  46. // */
  47. //
  48. // <functions, functions, functions!>
  49. //
  50. // /*! @} */ // group VectorMathFunctions
  51. /*!
  52. @defgroup TorqueScriptFunctions Function Categories
  53. */
  54. //-----------------------------------------------
  55. // TorqueScript Data Types
  56. //-----------------------------------------------
  57. // "Define" and document generic data types here. Doxygen does not really understand
  58. // how to define a language, so we need to fake it out with some C++ concept. We will
  59. // use "typedef" as it seems the most innocuous. Of course, typedef requires two arguments
  60. // so use "typedef type" then your data type.
  61. // Wrap all data types in a group. This will help organize Doxygen's output "module" page.
  62. /*!
  63. @defgroup TorqueScriptTypes Data Types
  64. @{
  65. */
  66. /*! Integers are whole numbers.
  67. ~~~
  68. 123
  69. 0xc001 // you can use 0x followed by hexadecimal digits
  70. ~~~
  71. */
  72. typedef type Integer;
  73. /*! Float, is a floating point number which can hold decimal values.
  74. ~~~
  75. 1.234
  76. 1234e-3 // you can use scientific notion
  77. ~~~
  78. */
  79. typedef type Float;
  80. /*! Text, such as names or phrases, are supported as strings.
  81. Numbers can also be stored in ::String format. Standard strings are stored in double-quotes.
  82. @par Example
  83. ~~~
  84. "abcd"
  85. ~~~
  86. @par Example
  87. ~~~
  88. $UserName = "Heather";
  89. ~~~
  90. Tagged strings are special in that they contain string data, but also have a special numeric tag associated with them. Tagged strings are used for sending string data across a network. The value of a tagged string is only sent once, regardless of how many times you actually do the sending.
  91. On subsequent sends, only the tag value is sent. Tagged values must be de-tagged when printing. You will not need to use a tagged string often unless you are in need of sending strings across a network often, like a chat system.
  92. @par Example
  93. ~~~
  94. $a = 'This is a tagged string';
  95. echo(" Tagged string: ", $a);
  96. echo("Detagged string: ", detag('$a'));
  97. ~~~
  98. The output will be similar to this:
  99. ~~~
  100. 24
  101. ____
  102. ~~~
  103. The second echo will be blank unless the string has been passed to you over a network.
  104. */
  105. typedef type String;
  106. /*! Boolean "numbers" have only two values - true or false.
  107. true (1)
  108. false (0)
  109. The constant `true` evaluates to the number 1 in TorqueScript, and the constant `false` evaluates to the number 0. However, non-zero values are also considered true. Think of booleans as "on/off" switches, often used in conditional statements.
  110. @par Example
  111. ~~~
  112. $lightsOn = true;
  113. if($lightsOn)
  114. echo("Lights are turned on");
  115. ~~~
  116. */
  117. typedef type Boolean;
  118. /*! Arrays are data structures used to store consecutive values of the same data type.
  119. + $TestArray[n] (Single-dimension)
  120. + $TestArray[m,n] (Multidimensional)
  121. + $TestArray[m_n] (Multidimensional)
  122. @par Example
  123. ~~~
  124. $userNames[0] = "Heather";
  125. $userNames[1] = "Nikki";
  126. $userNames[2] = "Mich";
  127. echo($userNames[0]);
  128. echo($userNames[1]);
  129. echo($userNames[2]);
  130. ~~~
  131. */
  132. typedef type Array;
  133. /*! Vector2 is a ::String of two numbers (::Float or ::Integer) separated by a space.
  134. It is a special case of a Vector. Note that TorqueScript does not check that you have exactly
  135. two elements. The type Vector2 is used here to remind you what is expected by a function, for instance.
  136. */
  137. typedef type Vector2;
  138. /*! Vector is a ::String of any number of values separated by spaces between each.
  139. ~~~
  140. %position = "25 32";
  141. %color = %red SPC %blue SPC %green SPC %alpha;
  142. ~~~
  143. */
  144. typedef type Vector;
  145. /*! Void is actually not a real type. It simply represents the absense of a type.
  146. */
  147. typedef type Void;
  148. /*! @} */ // data types
  149. //-----------------------------------------------
  150. // End TorqueScript Data Types
  151. //-----------------------------------------------
  152. //-----------------------------------------------
  153. // TorqueScript Operators
  154. //-----------------------------------------------
  155. // "Define" and document TorqueScript operators here. Doxygen does not really understand
  156. // how to define a language, so we need to fake it out with some C++ concept. As with
  157. // data types (above), we will use "typedef" as it seems the most innocuous. Of course,
  158. // typedef requires two arguments so use "typedef type" then your operator.
  159. // Wrap all operators in a group. This will help organize Doxygen's output "module" page.
  160. /*!
  161. @defgroup Operators Operators
  162. @{
  163. */
  164. /*! @defgroup StringOperators String Operators
  165. @{
  166. */
  167. /*! Concatenates two Strings into a single ::String separated by a space.
  168. Note: such a ::String can be decomposed with getWord()
  169. @par example
  170. ~~~
  171. %newString = "Hello" SPC "World";
  172. echo(%newString);
  173. OUTPUT:
  174. Hello World
  175. ~~~
  176. */
  177. typedef type SPC;
  178. /*! Concatenates two strings into a single ::String separated by a tab.
  179. Note: such a ::String can be decomposed with getField()
  180. @par example
  181. ~~~
  182. %newString = "Hello" TAB "World";
  183. echo(%newString);
  184. OUTPUT:
  185. Hello World
  186. ~~~
  187. */
  188. typedef type TAB;
  189. /*! Concatenates two strings into a single ::String with no separation.
  190. @par example
  191. ~~~
  192. %newString = "Hello" @ "World";
  193. echo(%newString);
  194. OUTPUT:
  195. HelloWorld
  196. ~~~
  197. */
  198. typedef type operator @;
  199. /*! Concatenates two strings into a single ::String separated by a new-line.
  200. @par example
  201. ~~~
  202. %newString = "Hello" NL "World";
  203. echo(%newString);
  204. OUTPUT:
  205. Hello
  206. World
  207. ~~~
  208. */
  209. typedef type NL;
  210. /*! @} */ // string operators
  211. /*! @defgroup mathOperators Arithmetic Operators
  212. @{
  213. */
  214. /*! @} */ // arithmetic operators
  215. /*! @defgroup constructionOperators Construction Operators
  216. @{
  217. */
  218. /*! create a new object
  219. @par Format
  220. @code
  221. %myID = new class([name])
  222. {
  223. [field = value;]
  224. ...
  225. };
  226. @endcode
  227. @par Where
  228. + *myID* is the return ID that can be used to access the object in the form `%%myID.myFunction`.\n
  229. + `new` is the keyword telling the engine to create an instance of the following *class*.\n
  230. + *class* is any class declared in the engine or in script that has been derived from SimObject.\n
  231. + *name* (optional) is the object's name for referencing in the form `name.myFunction` (without % or $ before it).\n
  232. + *field* - You may initialize static or dynamic class fields here, one at a time.\n
  233. @par Example
  234. @code
  235. // An SceneObject named 'Truck'
  236. // with two static fields and one dynamic field to define
  237. new SceneObject(Truck)
  238. {
  239. position = "0 0";
  240. size = "5 5";
  241. myField = 100;
  242. };
  243. // A nameless object (tracked by a variable), with no fields to set
  244. %myObject = new SimSet();
  245. @endcode
  246. */
  247. typedef type new;
  248. /*! @} */ // constructionOperators operators
  249. /*! @} */ // all operators
  250. //-----------------------------------------------
  251. // End TorqueScript Operators
  252. //-----------------------------------------------