xref: /freebsd/contrib/lutok/api-docs/html/a00065.html (revision 132f818ddbf457ee67d502cd89b5a18e0a34713d)
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
3<head>
4<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5<meta http-equiv="X-UA-Compatible" content="IE=11"/>
6<meta name="generator" content="Doxygen 1.9.6"/>
7<meta name="viewport" content="width=device-width, initial-scale=1"/>
8<title>Lutok: anonymous_namespace{state.cpp} Namespace Reference</title>
9<link href="tabs.css" rel="stylesheet" type="text/css"/>
10<script type="text/javascript" src="jquery.js"></script>
11<script type="text/javascript" src="dynsections.js"></script>
12<link href="search/search.css" rel="stylesheet" type="text/css"/>
13<script type="text/javascript" src="search/searchdata.js"></script>
14<script type="text/javascript" src="search/search.js"></script>
15<link href="doxygen.css" rel="stylesheet" type="text/css" />
16</head>
17<body>
18<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
19<div id="titlearea">
20<table cellspacing="0" cellpadding="0">
21 <tbody>
22 <tr id="projectrow">
23  <td id="projectalign">
24   <div id="projectname">Lutok<span id="projectnumber">&#160;0.6.2</span>
25   </div>
26  </td>
27 </tr>
28 </tbody>
29</table>
30</div>
31<!-- end header part -->
32<!-- Generated by Doxygen 1.9.6 -->
33<script type="text/javascript">
34/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
35var searchBox = new SearchBox("searchBox", "search/",'.html');
36/* @license-end */
37</script>
38<script type="text/javascript" src="menudata.js"></script>
39<script type="text/javascript" src="menu.js"></script>
40<script type="text/javascript">
41/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
42$(function() {
43  initMenu('',true,false,'search.php','Search');
44  $(document).ready(function() { init_search(); });
45});
46/* @license-end */
47</script>
48<div id="main-nav"></div>
49<!-- window showing the filter options -->
50<div id="MSearchSelectWindow"
51     onmouseover="return searchBox.OnSearchSelectShow()"
52     onmouseout="return searchBox.OnSearchSelectHide()"
53     onkeydown="return searchBox.OnSearchSelectKey(event)">
54</div>
55
56<!-- iframe showing the search results (closed by default) -->
57<div id="MSearchResultsWindow">
58<div id="MSearchResults">
59<div class="SRPage">
60<div id="SRIndex">
61<div id="SRResults"></div>
62<div class="SRStatus" id="Loading">Loading...</div>
63<div class="SRStatus" id="Searching">Searching...</div>
64<div class="SRStatus" id="NoMatches">No Matches</div>
65</div>
66</div>
67</div>
68</div>
69
70</div><!-- top -->
71<div class="header">
72  <div class="summary">
73<a href="#func-members">Functions</a>  </div>
74  <div class="headertitle"><div class="title">anonymous_namespace{state.cpp} Namespace Reference</div></div>
75</div><!--header-->
76<div class="contents">
77<table class="memberdecls">
78<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
79Functions</h2></td></tr>
80<tr class="memitem:ac895a6a4aab5ec5597bdfb62adf0f85c"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00065.html#ac895a6a4aab5ec5597bdfb62adf0f85c">protected_getglobal</a> (lua_State *state)</td></tr>
81<tr class="memdesc:ac895a6a4aab5ec5597bdfb62adf0f85c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Wrapper around lua_getglobal to run in a protected environment.  <br /></td></tr>
82<tr class="separator:ac895a6a4aab5ec5597bdfb62adf0f85c"><td class="memSeparator" colspan="2">&#160;</td></tr>
83<tr class="memitem:a901e28feef6c6a7c94edf906139464a4"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00065.html#a901e28feef6c6a7c94edf906139464a4">protected_gettable</a> (lua_State *state)</td></tr>
84<tr class="memdesc:a901e28feef6c6a7c94edf906139464a4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Wrapper around lua_gettable to run in a protected environment.  <br /></td></tr>
85<tr class="separator:a901e28feef6c6a7c94edf906139464a4"><td class="memSeparator" colspan="2">&#160;</td></tr>
86<tr class="memitem:a8163cc0f7d5dfba820e335e02769bd91"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00065.html#a8163cc0f7d5dfba820e335e02769bd91">protected_next</a> (lua_State *state)</td></tr>
87<tr class="memdesc:a8163cc0f7d5dfba820e335e02769bd91"><td class="mdescLeft">&#160;</td><td class="mdescRight">Wrapper around lua_next to run in a protected environment.  <br /></td></tr>
88<tr class="separator:a8163cc0f7d5dfba820e335e02769bd91"><td class="memSeparator" colspan="2">&#160;</td></tr>
89<tr class="memitem:a931ec64a97c5b8ff24bd12b1318c4bf5"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00065.html#a931ec64a97c5b8ff24bd12b1318c4bf5">protected_setglobal</a> (lua_State *state)</td></tr>
90<tr class="memdesc:a931ec64a97c5b8ff24bd12b1318c4bf5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Wrapper around lua_setglobal to run in a protected environment.  <br /></td></tr>
91<tr class="separator:a931ec64a97c5b8ff24bd12b1318c4bf5"><td class="memSeparator" colspan="2">&#160;</td></tr>
92<tr class="memitem:a42654c15fd147850ad03cd891d1d7193"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00065.html#a42654c15fd147850ad03cd891d1d7193">protected_settable</a> (lua_State *state)</td></tr>
93<tr class="memdesc:a42654c15fd147850ad03cd891d1d7193"><td class="mdescLeft">&#160;</td><td class="mdescRight">Wrapper around lua_settable to run in a protected environment.  <br /></td></tr>
94<tr class="separator:a42654c15fd147850ad03cd891d1d7193"><td class="memSeparator" colspan="2">&#160;</td></tr>
95<tr class="memitem:ac12be03daffcd5d46ac51da378577e51"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00065.html#ac12be03daffcd5d46ac51da378577e51">call_cxx_function_from_c</a> (<a class="el" href="a00029.html#a8c623ca426c30c5fab4df2cb21635f17">lutok::cxx_function</a> function, lua_State *raw_state)  throw ()</td></tr>
96<tr class="memdesc:ac12be03daffcd5d46ac51da378577e51"><td class="mdescLeft">&#160;</td><td class="mdescRight">Calls a C++ Lua function from a C calling environment.  <br /></td></tr>
97<tr class="separator:ac12be03daffcd5d46ac51da378577e51"><td class="memSeparator" colspan="2">&#160;</td></tr>
98<tr class="memitem:a86e6a7c405a8feea00907b99c4d084ca"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00065.html#a86e6a7c405a8feea00907b99c4d084ca">cxx_closure_trampoline</a> (lua_State *raw_state)</td></tr>
99<tr class="memdesc:a86e6a7c405a8feea00907b99c4d084ca"><td class="mdescLeft">&#160;</td><td class="mdescRight">Lua glue to call a C++ closure.  <br /></td></tr>
100<tr class="separator:a86e6a7c405a8feea00907b99c4d084ca"><td class="memSeparator" colspan="2">&#160;</td></tr>
101<tr class="memitem:af3c459196ed8b373a8376b5abeedd472"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00065.html#af3c459196ed8b373a8376b5abeedd472">cxx_function_trampoline</a> (lua_State *raw_state)</td></tr>
102<tr class="memdesc:af3c459196ed8b373a8376b5abeedd472"><td class="mdescLeft">&#160;</td><td class="mdescRight">Lua glue to call a C++ function.  <br /></td></tr>
103<tr class="separator:af3c459196ed8b373a8376b5abeedd472"><td class="memSeparator" colspan="2">&#160;</td></tr>
104</table>
105<h2 class="groupheader">Function Documentation</h2>
106<a id="ac12be03daffcd5d46ac51da378577e51" name="ac12be03daffcd5d46ac51da378577e51"></a>
107<h2 class="memtitle"><span class="permalink"><a href="#ac12be03daffcd5d46ac51da378577e51">&#9670;&#160;</a></span>call_cxx_function_from_c()</h2>
108
109<div class="memitem">
110<div class="memproto">
111<table class="mlabels">
112  <tr>
113  <td class="mlabels-left">
114      <table class="memname">
115        <tr>
116          <td class="memname">static int anonymous_namespace{state.cpp}::call_cxx_function_from_c </td>
117          <td>(</td>
118          <td class="paramtype"><a class="el" href="a00029.html#a8c623ca426c30c5fab4df2cb21635f17">lutok::cxx_function</a>&#160;</td>
119          <td class="paramname"><em>function</em>, </td>
120        </tr>
121        <tr>
122          <td class="paramkey"></td>
123          <td></td>
124          <td class="paramtype">lua_State *&#160;</td>
125          <td class="paramname"><em>raw_state</em>&#160;</td>
126        </tr>
127        <tr>
128          <td></td>
129          <td>)</td>
130          <td></td><td></td>
131        </tr>
132        <tr>
133          <td align="right">throw </td><td>(</td><td colspan="2"></td>
134        </tr>
135        <tr>
136          <td align="right"></td><td>)</td><td></td><td></td>
137        </tr>
138      </table>
139  </td>
140  <td class="mlabels-right">
141<span class="mlabels"><span class="mlabel">static</span></span>  </td>
142  </tr>
143</table>
144</div><div class="memdoc">
145
146<p>Calls a C++ Lua function from a C calling environment. </p>
147<p>Any errors reported by the C++ function are caught and reported to the caller as Lua errors.</p>
148<dl class="params"><dt>Parameters</dt><dd>
149  <table class="params">
150    <tr><td class="paramname">function</td><td>The C++ function to call. </td></tr>
151    <tr><td class="paramname">raw_state</td><td>The raw Lua state.</td></tr>
152  </table>
153  </dd>
154</dl>
155<dl class="section return"><dt>Returns</dt><dd>The number of return values pushed onto the Lua stack by the function. </dd></dl>
156
157</div>
158</div>
159<a id="a86e6a7c405a8feea00907b99c4d084ca" name="a86e6a7c405a8feea00907b99c4d084ca"></a>
160<h2 class="memtitle"><span class="permalink"><a href="#a86e6a7c405a8feea00907b99c4d084ca">&#9670;&#160;</a></span>cxx_closure_trampoline()</h2>
161
162<div class="memitem">
163<div class="memproto">
164<table class="mlabels">
165  <tr>
166  <td class="mlabels-left">
167      <table class="memname">
168        <tr>
169          <td class="memname">static int anonymous_namespace{state.cpp}::cxx_closure_trampoline </td>
170          <td>(</td>
171          <td class="paramtype">lua_State *&#160;</td>
172          <td class="paramname"><em>raw_state</em></td><td>)</td>
173          <td></td>
174        </tr>
175      </table>
176  </td>
177  <td class="mlabels-right">
178<span class="mlabels"><span class="mlabel">static</span></span>  </td>
179  </tr>
180</table>
181</div><div class="memdoc">
182
183<p>Lua glue to call a C++ closure. </p>
184<p>This Lua binding is actually a closure that we have constructed from the state.push_cxx_closure() method. The closure contains the same upvalues provided by the user plus an extra upvalue that contains the address of the C++ function we have to call. All we do here is safely delegate the execution to the wrapped C++ closure.</p>
185<dl class="params"><dt>Parameters</dt><dd>
186  <table class="params">
187    <tr><td class="paramname">raw_state</td><td>The Lua C API state.</td></tr>
188  </table>
189  </dd>
190</dl>
191<dl class="section return"><dt>Returns</dt><dd>The number of return values of the called closure. </dd></dl>
192
193</div>
194</div>
195<a id="af3c459196ed8b373a8376b5abeedd472" name="af3c459196ed8b373a8376b5abeedd472"></a>
196<h2 class="memtitle"><span class="permalink"><a href="#af3c459196ed8b373a8376b5abeedd472">&#9670;&#160;</a></span>cxx_function_trampoline()</h2>
197
198<div class="memitem">
199<div class="memproto">
200<table class="mlabels">
201  <tr>
202  <td class="mlabels-left">
203      <table class="memname">
204        <tr>
205          <td class="memname">static int anonymous_namespace{state.cpp}::cxx_function_trampoline </td>
206          <td>(</td>
207          <td class="paramtype">lua_State *&#160;</td>
208          <td class="paramname"><em>raw_state</em></td><td>)</td>
209          <td></td>
210        </tr>
211      </table>
212  </td>
213  <td class="mlabels-right">
214<span class="mlabels"><span class="mlabel">static</span></span>  </td>
215  </tr>
216</table>
217</div><div class="memdoc">
218
219<p>Lua glue to call a C++ function. </p>
220<p>This Lua binding is actually a closure that we have constructed from the state.push_cxx_function() method. The closure has a single upvalue that contains the address of the C++ function we have to call. All we do here is safely delegate the execution to the wrapped C++ function.</p>
221<dl class="params"><dt>Parameters</dt><dd>
222  <table class="params">
223    <tr><td class="paramname">raw_state</td><td>The Lua C API state.</td></tr>
224  </table>
225  </dd>
226</dl>
227<dl class="section return"><dt>Returns</dt><dd>The number of return values of the called function. </dd></dl>
228
229</div>
230</div>
231<a id="ac895a6a4aab5ec5597bdfb62adf0f85c" name="ac895a6a4aab5ec5597bdfb62adf0f85c"></a>
232<h2 class="memtitle"><span class="permalink"><a href="#ac895a6a4aab5ec5597bdfb62adf0f85c">&#9670;&#160;</a></span>protected_getglobal()</h2>
233
234<div class="memitem">
235<div class="memproto">
236<table class="mlabels">
237  <tr>
238  <td class="mlabels-left">
239      <table class="memname">
240        <tr>
241          <td class="memname">static int anonymous_namespace{state.cpp}::protected_getglobal </td>
242          <td>(</td>
243          <td class="paramtype">lua_State *&#160;</td>
244          <td class="paramname"><em>state</em></td><td>)</td>
245          <td></td>
246        </tr>
247      </table>
248  </td>
249  <td class="mlabels-right">
250<span class="mlabels"><span class="mlabel">static</span></span>  </td>
251  </tr>
252</table>
253</div><div class="memdoc">
254
255<p>Wrapper around lua_getglobal to run in a protected environment. </p>
256<dl class="section pre"><dt>Precondition</dt><dd>stack(-1) is the name of the global to get. </dd></dl>
257<dl class="section post"><dt>Postcondition</dt><dd>stack(-1) is the value of the global.</dd></dl>
258<dl class="params"><dt>Parameters</dt><dd>
259  <table class="params">
260    <tr><td class="paramname">state</td><td>The Lua C API state.</td></tr>
261  </table>
262  </dd>
263</dl>
264<dl class="section return"><dt>Returns</dt><dd>The number of return values pushed onto the stack. </dd></dl>
265
266</div>
267</div>
268<a id="a901e28feef6c6a7c94edf906139464a4" name="a901e28feef6c6a7c94edf906139464a4"></a>
269<h2 class="memtitle"><span class="permalink"><a href="#a901e28feef6c6a7c94edf906139464a4">&#9670;&#160;</a></span>protected_gettable()</h2>
270
271<div class="memitem">
272<div class="memproto">
273<table class="mlabels">
274  <tr>
275  <td class="mlabels-left">
276      <table class="memname">
277        <tr>
278          <td class="memname">static int anonymous_namespace{state.cpp}::protected_gettable </td>
279          <td>(</td>
280          <td class="paramtype">lua_State *&#160;</td>
281          <td class="paramname"><em>state</em></td><td>)</td>
282          <td></td>
283        </tr>
284      </table>
285  </td>
286  <td class="mlabels-right">
287<span class="mlabels"><span class="mlabel">static</span></span>  </td>
288  </tr>
289</table>
290</div><div class="memdoc">
291
292<p>Wrapper around lua_gettable to run in a protected environment. </p>
293<dl class="section pre"><dt>Precondition</dt><dd>stack(-2) is the table to get the element from. </dd>
294<dd>
295stack(-1) is the table index. </dd></dl>
296<dl class="section post"><dt>Postcondition</dt><dd>stack(-1) is the value of stack(-2)[stack(-1)].</dd></dl>
297<dl class="params"><dt>Parameters</dt><dd>
298  <table class="params">
299    <tr><td class="paramname">state</td><td>The Lua C API state.</td></tr>
300  </table>
301  </dd>
302</dl>
303<dl class="section return"><dt>Returns</dt><dd>The number of return values pushed onto the stack. </dd></dl>
304
305</div>
306</div>
307<a id="a8163cc0f7d5dfba820e335e02769bd91" name="a8163cc0f7d5dfba820e335e02769bd91"></a>
308<h2 class="memtitle"><span class="permalink"><a href="#a8163cc0f7d5dfba820e335e02769bd91">&#9670;&#160;</a></span>protected_next()</h2>
309
310<div class="memitem">
311<div class="memproto">
312<table class="mlabels">
313  <tr>
314  <td class="mlabels-left">
315      <table class="memname">
316        <tr>
317          <td class="memname">static int anonymous_namespace{state.cpp}::protected_next </td>
318          <td>(</td>
319          <td class="paramtype">lua_State *&#160;</td>
320          <td class="paramname"><em>state</em></td><td>)</td>
321          <td></td>
322        </tr>
323      </table>
324  </td>
325  <td class="mlabels-right">
326<span class="mlabels"><span class="mlabel">static</span></span>  </td>
327  </tr>
328</table>
329</div><div class="memdoc">
330
331<p>Wrapper around lua_next to run in a protected environment. </p>
332<dl class="section pre"><dt>Precondition</dt><dd>stack(-2) is the table to get the next element from. </dd>
333<dd>
334stack(-1) is the last processed key. </dd></dl>
335<dl class="section post"><dt>Postcondition</dt><dd>stack(-1) is the value of next(stack(-2), stack(-1)).</dd></dl>
336<dl class="params"><dt>Parameters</dt><dd>
337  <table class="params">
338    <tr><td class="paramname">state</td><td>The Lua C API state.</td></tr>
339  </table>
340  </dd>
341</dl>
342<dl class="section return"><dt>Returns</dt><dd>The number of return values pushed onto the stack. </dd></dl>
343
344</div>
345</div>
346<a id="a931ec64a97c5b8ff24bd12b1318c4bf5" name="a931ec64a97c5b8ff24bd12b1318c4bf5"></a>
347<h2 class="memtitle"><span class="permalink"><a href="#a931ec64a97c5b8ff24bd12b1318c4bf5">&#9670;&#160;</a></span>protected_setglobal()</h2>
348
349<div class="memitem">
350<div class="memproto">
351<table class="mlabels">
352  <tr>
353  <td class="mlabels-left">
354      <table class="memname">
355        <tr>
356          <td class="memname">static int anonymous_namespace{state.cpp}::protected_setglobal </td>
357          <td>(</td>
358          <td class="paramtype">lua_State *&#160;</td>
359          <td class="paramname"><em>state</em></td><td>)</td>
360          <td></td>
361        </tr>
362      </table>
363  </td>
364  <td class="mlabels-right">
365<span class="mlabels"><span class="mlabel">static</span></span>  </td>
366  </tr>
367</table>
368</div><div class="memdoc">
369
370<p>Wrapper around lua_setglobal to run in a protected environment. </p>
371<dl class="section pre"><dt>Precondition</dt><dd>stack(-2) is the name of the global to set. </dd>
372<dd>
373stack(-1) is the value to set the global to.</dd></dl>
374<dl class="params"><dt>Parameters</dt><dd>
375  <table class="params">
376    <tr><td class="paramname">state</td><td>The Lua C API state.</td></tr>
377  </table>
378  </dd>
379</dl>
380<dl class="section return"><dt>Returns</dt><dd>The number of return values pushed onto the stack. </dd></dl>
381
382</div>
383</div>
384<a id="a42654c15fd147850ad03cd891d1d7193" name="a42654c15fd147850ad03cd891d1d7193"></a>
385<h2 class="memtitle"><span class="permalink"><a href="#a42654c15fd147850ad03cd891d1d7193">&#9670;&#160;</a></span>protected_settable()</h2>
386
387<div class="memitem">
388<div class="memproto">
389<table class="mlabels">
390  <tr>
391  <td class="mlabels-left">
392      <table class="memname">
393        <tr>
394          <td class="memname">static int anonymous_namespace{state.cpp}::protected_settable </td>
395          <td>(</td>
396          <td class="paramtype">lua_State *&#160;</td>
397          <td class="paramname"><em>state</em></td><td>)</td>
398          <td></td>
399        </tr>
400      </table>
401  </td>
402  <td class="mlabels-right">
403<span class="mlabels"><span class="mlabel">static</span></span>  </td>
404  </tr>
405</table>
406</div><div class="memdoc">
407
408<p>Wrapper around lua_settable to run in a protected environment. </p>
409<dl class="section pre"><dt>Precondition</dt><dd>stack(-3) is the table to set the element into. </dd>
410<dd>
411stack(-2) is the table index. </dd>
412<dd>
413stack(-1) is the value to set.</dd></dl>
414<dl class="params"><dt>Parameters</dt><dd>
415  <table class="params">
416    <tr><td class="paramname">state</td><td>The Lua C API state.</td></tr>
417  </table>
418  </dd>
419</dl>
420<dl class="section return"><dt>Returns</dt><dd>The number of return values pushed onto the stack. </dd></dl>
421
422</div>
423</div>
424</div><!-- contents -->
425<!-- start footer part -->
426<hr class="footer"/><address class="footer"><small>
427Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.6
428</small></address>
429</body>
430</html>
431