Преглед на файлове

docs: Add examples for globals

Ole преди 9 години
родител
ревизия
a6bdcafac8
променени са 4 файла, в които са добавени 28 реда и са изтрити 1 реда
  1. 14 0
      docs/mkdocs/basics.md
  2. 13 0
      docs/output/basics/index.html
  3. 1 1
      docs/output/index.html
  4. 0 0
      docs/output/mkdocs/search_index.json

+ 14 - 0
docs/mkdocs/basics.md

@@ -100,3 +100,17 @@ converted to it? Most `Value<T>` specializations use Lua's `luaL_check*` functio
 the values from the stack. This means that no exceptions will be thrown - instead the error handling
 is delegated to the Lua VM. Have a look at the
 [error handling documentation](http://www.lua.org/manual/5.3/manual.html#4.6) for more information.
+
+# Globals
+In order to convenient register values in the global namespace, Luwra provides
+[setGlobal](/reference/namespaceluwra.html#afed27900ff117638937ad92e0217258d) and
+[getGlobal](/reference/namespaceluwra.html#af0a7dbbbdb339227c6ecaaa46422e05b).
+
+
+```c++
+// Register in the global namespace
+luwra::setGlobal(lua, "almostPi", 3.14);
+
+// Retrieve from globals
+double almostPi = luwra::getGlobal<double>(lua, "almostPi");
+```

+ 13 - 0
docs/output/basics/index.html

@@ -79,6 +79,9 @@
                     <li><a class="toctree-l4" href="#read-and-type-errors">Read and type errors</a></li>
                 
             
+                <li class="toctree-l3"><a href="#globals">Globals</a></li>
+                
+            
             </ul>
         
     </li>
@@ -375,6 +378,16 @@ converted to it? Most <code>Value&lt;T&gt;</code> specializations use Lua's <cod
 the values from the stack. This means that no exceptions will be thrown - instead the error handling
 is delegated to the Lua VM. Have a look at the
 <a href="http://www.lua.org/manual/5.3/manual.html#4.6">error handling documentation</a> for more information.</p>
+<h1 id="globals">Globals</h1>
+<p>In order to convenient register values in the global namespace, Luwra provides
+<a href="../reference/namespaceluwra.html#afed27900ff117638937ad92e0217258d">setGlobal</a> and
+<a href="../reference/namespaceluwra.html#af0a7dbbbdb339227c6ecaaa46422e05b">getGlobal</a>.</p>
+<pre><code class="c++">// Register in the global namespace
+luwra::setGlobal(lua, &quot;almostPi&quot;, 3.14);
+
+// Retrieve from globals
+double almostPi = luwra::getGlobal&lt;double&gt;(lua, &quot;almostPi&quot;);
+</code></pre>
               
             </div>
           </div>

+ 1 - 1
docs/output/index.html

@@ -193,5 +193,5 @@ your preference.</p>
 
 <!--
 MkDocs version : 0.15.3
-Build Date UTC : 2016-05-06 22:51:43.699998
+Build Date UTC : 2016-05-06 22:59:17.802925
 -->

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
docs/output/mkdocs/search_index.json


Някои файлове не бяха показани, защото твърде много файлове са промени