|
|
@@ -72,6 +72,8 @@
|
|
|
|
|
|
<li class="toctree-l3"><a href="#stack-interaction">Stack Interaction</a></li>
|
|
|
|
|
|
+ <li><a class="toctree-l4" href="#extending-supported-types">Extending supported types</a></li>
|
|
|
+
|
|
|
<li><a class="toctree-l4" href="#pushing-c-values">Pushing C++ values</a></li>
|
|
|
|
|
|
<li><a class="toctree-l4" href="#reading-lua-values">Reading Lua values</a></li>
|
|
|
@@ -310,6 +312,27 @@ Useful implementations are provided out of the box:</p>
|
|
|
</table>
|
|
|
<p><strong>Note:</strong> Some numeric types have a different size than their matching Lua type - they will be
|
|
|
truncated during push or read operations.</p>
|
|
|
+<h2 id="extending-supported-types">Extending supported types</h2>
|
|
|
+<p>If you are missing a type that cannot be used as a <a href="../user-types">user type</a>, you can add a
|
|
|
+specialization of <a href="../reference/structluwra_1_1Value.html">Value</a>. All you need to do is modify the following snippet for your
|
|
|
+type <code>T</code>.</p>
|
|
|
+<pre><code class="c++">namespace luwra {
|
|
|
+ template <>
|
|
|
+ struct Value<T> {
|
|
|
+ static inline
|
|
|
+ T read(State* state, int index) {
|
|
|
+ return /* Return the instance of T that you have read at the given index */;
|
|
|
+ }
|
|
|
+
|
|
|
+ static inline
|
|
|
+ size_t push(State* state, const T& value) {
|
|
|
+ // Push the given value on top of the stack
|
|
|
+ return /* Return how many values you have pushed onto the stack */;
|
|
|
+ }
|
|
|
+ };
|
|
|
+}
|
|
|
+</code></pre>
|
|
|
+
|
|
|
<h2 id="pushing-c-values">Pushing C++ values</h2>
|
|
|
<p>When pushing values onto the stack you can either use <a href="../reference/structluwra_1_1Value.html#aa376d68285606c206562b822e8187384">Value<T>::push</a> or
|
|
|
the more convenient <a href="../reference/namespaceluwra.html#ae8e7eab11fc2cf3f258ffd81571066fa">push</a>.</p>
|