|
@@ -308,6 +308,15 @@ luwra::push(lua, false);
|
|
|
|
|
|
|
|
// Push a string
|
|
// Push a string
|
|
|
luwra::push(lua, "Hello World");
|
|
luwra::push(lua, "Hello World");
|
|
|
|
|
+
|
|
|
|
|
+// Push a table
|
|
|
|
|
+luwra::push(lua, luwra::FieldVector {
|
|
|
|
|
+ {"one", 1},
|
|
|
|
|
+ {1, "one"},
|
|
|
|
|
+ {"nested", luwra::FieldVector {
|
|
|
|
|
+ {"more", "fields"}
|
|
|
|
|
+ }}
|
|
|
|
|
+});
|
|
|
</code></pre>
|
|
</code></pre>
|
|
|
|
|
|
|
|
<p>This produces the following stack layout:</p>
|
|
<p>This produces the following stack layout:</p>
|
|
@@ -322,24 +331,29 @@ luwra::push(lua, "Hello World");
|
|
|
<tbody>
|
|
<tbody>
|
|
|
<tr>
|
|
<tr>
|
|
|
<td>1</td>
|
|
<td>1</td>
|
|
|
-<td>-4</td>
|
|
|
|
|
|
|
+<td>-5</td>
|
|
|
<td><code>1338</code></td>
|
|
<td><code>1338</code></td>
|
|
|
</tr>
|
|
</tr>
|
|
|
<tr>
|
|
<tr>
|
|
|
<td>2</td>
|
|
<td>2</td>
|
|
|
-<td>-3</td>
|
|
|
|
|
|
|
+<td>-4</td>
|
|
|
<td><code>13.37</code></td>
|
|
<td><code>13.37</code></td>
|
|
|
</tr>
|
|
</tr>
|
|
|
<tr>
|
|
<tr>
|
|
|
<td>3</td>
|
|
<td>3</td>
|
|
|
-<td>-2</td>
|
|
|
|
|
|
|
+<td>-3</td>
|
|
|
<td><code>false</code></td>
|
|
<td><code>false</code></td>
|
|
|
</tr>
|
|
</tr>
|
|
|
<tr>
|
|
<tr>
|
|
|
<td>4</td>
|
|
<td>4</td>
|
|
|
-<td>-1</td>
|
|
|
|
|
|
|
+<td>-2</td>
|
|
|
<td><code>"Hello World"</code></td>
|
|
<td><code>"Hello World"</code></td>
|
|
|
</tr>
|
|
</tr>
|
|
|
|
|
+<tr>
|
|
|
|
|
+<td>5</td>
|
|
|
|
|
+<td>-1</td>
|
|
|
|
|
+<td><code>{one = 1, [1] = "one", nested = {more = "fields"}}</code></td>
|
|
|
|
|
+</tr>
|
|
|
</tbody>
|
|
</tbody>
|
|
|
</table>
|
|
</table>
|
|
|
<p>It is possible to provide a template parameter to <code>push</code> to enforce pushing a specific type.
|
|
<p>It is possible to provide a template parameter to <code>push</code> to enforce pushing a specific type.
|
|
@@ -352,7 +366,7 @@ stack layout from the previous example. This is how you would retrieve a value f
|
|
|
int value = luwra::read<int>(lua, 1);
|
|
int value = luwra::read<int>(lua, 1);
|
|
|
|
|
|
|
|
// Similiar with a relative index
|
|
// Similiar with a relative index
|
|
|
-int value = luwra::read<int>(lua, -4);
|
|
|
|
|
|
|
+int value = luwra::read<int>(lua, -5);
|
|
|
</code></pre>
|
|
</code></pre>
|
|
|
|
|
|
|
|
<h2 id="read-and-type-errors">Read and type errors</h2>
|
|
<h2 id="read-and-type-errors">Read and type errors</h2>
|