index.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>Usage - Luwra</title>
  9. <link rel="shortcut icon" href="../img/favicon.ico">
  10. <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>
  11. <link rel="stylesheet" href="../css/theme.css" type="text/css" />
  12. <link rel="stylesheet" href="../css/theme_extra.css" type="text/css" />
  13. <link rel="stylesheet" href="../css/highlight.css">
  14. <script>
  15. // Current page data
  16. var mkdocs_page_name = "Usage";
  17. var mkdocs_page_input_path = "usage.md";
  18. var mkdocs_page_url = "/usage/";
  19. </script>
  20. <script src="../js/jquery-2.1.1.min.js"></script>
  21. <script src="../js/modernizr-2.8.3.min.js"></script>
  22. <script type="text/javascript" src="../js/highlight.pack.js"></script>
  23. <script src="../js/theme.js"></script>
  24. </head>
  25. <body class="wy-body-for-nav" role="document">
  26. <div class="wy-grid-for-nav">
  27. <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
  28. <div class="wy-side-nav-search">
  29. <a href=".." class="icon icon-home"> Luwra</a>
  30. <div role="search">
  31. <form id ="rtd-search-form" class="wy-form" action="../search.html" method="get">
  32. <input type="text" name="q" placeholder="Search docs" />
  33. </form>
  34. </div>
  35. </div>
  36. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  37. <ul class="current">
  38. <li>
  39. <li class="toctree-l1 ">
  40. <a class="" href="..">Home</a>
  41. </li>
  42. <li>
  43. <li>
  44. <li class="toctree-l1 current">
  45. <a class="current" href="./">Usage</a>
  46. <ul>
  47. <li class="toctree-l3"><a href="#integration">Integration</a></li>
  48. <li class="toctree-l3"><a href="#stack-interaction">Stack Interaction</a></li>
  49. <li class="toctree-l3"><a href="#from-c-to-lua">From C++ to Lua</a></li>
  50. </ul>
  51. </li>
  52. <li>
  53. </ul>
  54. </div>
  55. &nbsp;
  56. </nav>
  57. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  58. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  59. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  60. <a href="..">Luwra</a>
  61. </nav>
  62. <div class="wy-nav-content">
  63. <div class="rst-content">
  64. <div role="navigation" aria-label="breadcrumbs navigation">
  65. <ul class="wy-breadcrumbs">
  66. <li><a href="..">Docs</a> &raquo;</li>
  67. <li>Usage</li>
  68. <li class="wy-breadcrumbs-aside">
  69. <a href="https://github.com/vapourismo/luwra" class="icon icon-github"> Edit on GitHub</a>
  70. </li>
  71. </ul>
  72. <hr/>
  73. </div>
  74. <div role="main">
  75. <div class="section">
  76. <h1 id="integration">Integration</h1>
  77. <p>Luwra does not provide a standalone version of Lua nor does it capsule its features. This means that
  78. all functions and classes operate on
  79. <a href="http://www.lua.org/manual/5.3/manual.html#lua_State">lua_State</a> (or the alias
  80. <a href="../reference/namespaceluwra.html#a2c037b44385367826eb4e931b5b8197d">State</a>). Doing this allows you to
  81. integrate Luwra however you like.</p>
  82. <h1 id="stack-interaction">Stack Interaction</h1>
  83. <p>Although Luwra provides a variety of features, its main concern is efficient and safe interaction
  84. with the Lua stack.</p>
  85. <p>A fundamental aspect of this is the abstract template <a href="../reference/structluwra_1_1Value.html">Value</a>.
  86. Every type which can be pushed onto or read from the stack has a specialization of it.
  87. Useful implementations are provides out of the box:</p>
  88. <table>
  89. <thead>
  90. <tr>
  91. <th>C++ type</th>
  92. <th>Pushable</th>
  93. <th>Readable</th>
  94. <th>Lua type</th>
  95. </tr>
  96. </thead>
  97. <tbody>
  98. <tr>
  99. <td>bool</td>
  100. <td>yes</td>
  101. <td>yes</td>
  102. <td>boolean</td>
  103. </tr>
  104. <tr>
  105. <td>signed char</td>
  106. <td>yes</td>
  107. <td>yes</td>
  108. <td>number (integer since 5.3)</td>
  109. </tr>
  110. <tr>
  111. <td>signed short</td>
  112. <td>yes</td>
  113. <td>yes</td>
  114. <td>number (integer since 5.3)</td>
  115. </tr>
  116. <tr>
  117. <td>signed int</td>
  118. <td>yes</td>
  119. <td>yes</td>
  120. <td>number (integer since 5.3)</td>
  121. </tr>
  122. <tr>
  123. <td>signed long int</td>
  124. <td>yes</td>
  125. <td>yes</td>
  126. <td>number (integer since 5.3)</td>
  127. </tr>
  128. <tr>
  129. <td>signed long long int</td>
  130. <td>yes</td>
  131. <td>yes</td>
  132. <td>number (integer since 5.3)</td>
  133. </tr>
  134. <tr>
  135. <td>unsigned char</td>
  136. <td>yes</td>
  137. <td>yes</td>
  138. <td>number (integer since 5.3)</td>
  139. </tr>
  140. <tr>
  141. <td>unsigned short</td>
  142. <td>yes</td>
  143. <td>yes</td>
  144. <td>number (integer since 5.3)</td>
  145. </tr>
  146. <tr>
  147. <td>unsigned int</td>
  148. <td>yes</td>
  149. <td>yes</td>
  150. <td>number (integer since 5.3)</td>
  151. </tr>
  152. <tr>
  153. <td>unsigned long int</td>
  154. <td>yes</td>
  155. <td>yes</td>
  156. <td>number (integer since 5.3)</td>
  157. </tr>
  158. <tr>
  159. <td>unsigned long long int</td>
  160. <td>yes</td>
  161. <td>yes</td>
  162. <td>number (integer since 5.3)</td>
  163. </tr>
  164. <tr>
  165. <td>float</td>
  166. <td>yes</td>
  167. <td>yes</td>
  168. <td>number</td>
  169. </tr>
  170. <tr>
  171. <td>double</td>
  172. <td>yes</td>
  173. <td>yes</td>
  174. <td>number</td>
  175. </tr>
  176. <tr>
  177. <td>long double</td>
  178. <td>yes</td>
  179. <td>yes</td>
  180. <td>number</td>
  181. </tr>
  182. <tr>
  183. <td>const char*</td>
  184. <td>yes</td>
  185. <td>yes</td>
  186. <td>string</td>
  187. </tr>
  188. <tr>
  189. <td>std::string</td>
  190. <td>yes</td>
  191. <td>yes</td>
  192. <td>string</td>
  193. </tr>
  194. <tr>
  195. <td>std::nullptr_t</td>
  196. <td>yes</td>
  197. <td>yes</td>
  198. <td>nil</td>
  199. </tr>
  200. <tr>
  201. <td>std::tuple&lt;T&gt;</td>
  202. <td>yes</td>
  203. <td>no</td>
  204. <td><em>depends on the tuple contents</em></td>
  205. </tr>
  206. <tr>
  207. <td><a href="http://www.lua.org/manual/5.3/manual.html#lua_CFunction">lua_CFunction</a></td>
  208. <td>yes</td>
  209. <td>no</td>
  210. <td>function</td>
  211. </tr>
  212. <tr>
  213. <td><a href="../reference/structluwra_1_1Value_3_01NativeFunction_3_01R_07A_8_8_8_08_4_01_4.html">NativeFunction&lt;R(A...)&gt;</a></td>
  214. <td>no</td>
  215. <td>yes</td>
  216. <td>function</td>
  217. </tr>
  218. <tr>
  219. <td><a href="../reference/structluwra_1_1Value_3_01FieldVector_01_4.html">FieldVector</a></td>
  220. <td>yes</td>
  221. <td>no</td>
  222. <td>table</td>
  223. </tr>
  224. </tbody>
  225. </table>
  226. <p><strong>Note:</strong> Some numeric types have a different size than their matching Lua type - they will be
  227. truncated during push or read operations.</p>
  228. <h1 id="from-c-to-lua">From C++ to Lua</h1>
  229. <p>When pushing values onto the stack you can either use
  230. <a href="../reference/structluwra_1_1Value.html#aa376d68285606c206562b822e8187384">Value&lt;T&gt;::push</a> or the more
  231. convenient <a href="../reference/namespaceluwra.html#ae8e7eab11fc2cf3f258ffd81571066fa">push</a>.
  232. See these examples:</p>
  233. <pre><code class="c++">// Push an integer
  234. luwra::push(lua, 1338);
  235. // Push a number
  236. luwra::push(lua, 13.37);
  237. // Push a boolean
  238. luwra::push(lua, false);
  239. // Push a string
  240. luwra::push(lua, &quot;Hello World&quot;);
  241. </code></pre>
  242. </div>
  243. </div>
  244. <footer>
  245. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  246. <a href=".." class="btn btn-neutral" title="Home"><span class="icon icon-circle-arrow-left"></span> Previous</a>
  247. </div>
  248. <hr/>
  249. <div role="contentinfo">
  250. <!-- Copyright etc -->
  251. </div>
  252. Built with <a href="http://www.mkdocs.org">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  253. </footer>
  254. </div>
  255. </div>
  256. </section>
  257. </div>
  258. <div class="rst-versions" role="note" style="cursor: pointer">
  259. <span class="rst-current-version" data-toggle="rst-current-version">
  260. <a href="https://github.com/vapourismo/luwra" class="icon icon-github" style="float: left; color: #fcfcfc"> GitHub</a>
  261. <span><a href=".." style="color: #fcfcfc;">&laquo; Previous</a></span>
  262. </span>
  263. </div>
  264. </body>
  265. </html>