PageRenderTime 71ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 2ms

/docs/wxlua/doxygen/html/wxlstate_8cpp_source.html

https://bitbucket.org/missdeer/luapack
HTML | 4250 lines | 4249 code | 0 blank | 1 comment | 0 complexity | 9800ca9bd30bf697b6a3754baaf54733 MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.0, CC-BY-SA-3.0, ISC, LGPL-2.1, GPL-2.0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <title>wxLua: /mnt/share/devel/lua/wxLua/modules/wxlua/src/wxlstate.cpp Source File</title>
  6. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  7. <link href="doxygen.css" rel="stylesheet" type="text/css"/>
  8. </head>
  9. <body>
  10. <!-- Generated by Doxygen 1.6.3 -->
  11. <div class="navigation" id="top">
  12. <div class="tabs">
  13. <ul>
  14. <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
  15. <li><a href="annotated.html"><span>Classes</span></a></li>
  16. <li class="current"><a href="files.html"><span>Files</span></a></li>
  17. <li><a href="dirs.html"><span>Directories</span></a></li>
  18. </ul>
  19. </div>
  20. <div class="tabs">
  21. <ul>
  22. <li><a href="files.html"><span>File&nbsp;List</span></a></li>
  23. <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
  24. </ul>
  25. </div>
  26. <div class="navpath"><a class="el" href="dir_15d5a205ad383328522db6a6be296af1.html">modules</a>&nbsp;&raquo;&nbsp;<a class="el" href="dir_b59b58daa92d206701e75411b2cef894.html">wxlua</a>&nbsp;&raquo;&nbsp;<a class="el" href="dir_83fe9eb5cda99cf12108735ec0aac68a.html">src</a>
  27. </div>
  28. </div>
  29. <div class="contents">
  30. <h1>wxlstate.cpp</h1><a href="wxlstate_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/////////////////////////////////////////////////////////////////////////////</span>
  31. <a name="l00002"></a>00002 <span class="comment"></span><span class="comment">// Name: wxlstate.cpp</span>
  32. <a name="l00003"></a>00003 <span class="comment">// Purpose: wxLuaState, a wxWidgets interface to Lua</span>
  33. <a name="l00004"></a>00004 <span class="comment">// Author: Ray Gilbert, John Labenski, J Winwood (Reuben Thomas for bitlib at bottom)</span>
  34. <a name="l00005"></a>00005 <span class="comment">// Created: 14/11/2001</span>
  35. <a name="l00006"></a>00006 <span class="comment">// Copyright: (c) 2001-2002 Lomtick Software. All rights reserved.</span>
  36. <a name="l00007"></a>00007 <span class="comment">// Licence: wxWidgets licence</span><span class="comment"></span>
  37. <a name="l00008"></a>00008 <span class="comment">/////////////////////////////////////////////////////////////////////////////</span>
  38. <a name="l00009"></a>00009 <span class="comment"></span>
  39. <a name="l00010"></a>00010 <span class="comment">// For compilers that support precompilation, includes &quot;wx/wx.h&quot;</span>
  40. <a name="l00011"></a>00011 <span class="preprocessor">#include &quot;wx/wxprec.h&quot;</span>
  41. <a name="l00012"></a>00012
  42. <a name="l00013"></a>00013 <span class="preprocessor">#ifdef __BORLANDC__</span>
  43. <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor"> #pragma hdrstop</span>
  44. <a name="l00015"></a>00015 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
  45. <a name="l00016"></a>00016 <span class="preprocessor"></span>
  46. <a name="l00017"></a>00017 <span class="comment">// for all others, include the necessary headers</span>
  47. <a name="l00018"></a>00018 <span class="preprocessor">#ifndef WX_PRECOMP</span>
  48. <a name="l00019"></a>00019 <span class="preprocessor"></span><span class="preprocessor"> #include &quot;wx/wx.h&quot;</span>
  49. <a name="l00020"></a>00020 <span class="preprocessor">#endif</span>
  50. <a name="l00021"></a>00021 <span class="preprocessor"></span>
  51. <a name="l00022"></a>00022 <span class="preprocessor">#include &quot;<a class="code" href="wxlstate_8h.html">wxlua/include/wxlstate.h</a>&quot;</span>
  52. <a name="l00023"></a>00023 <span class="preprocessor">#include &quot;<a class="code" href="wxlcallb_8h.html">wxlua/include/wxlcallb.h</a>&quot;</span>
  53. <a name="l00024"></a>00024 <span class="preprocessor">#include &quot;wx/tokenzr.h&quot;</span>
  54. <a name="l00025"></a>00025
  55. <a name="l00026"></a>00026 <span class="comment">//#include &quot;wxluadebug/include/wxldebug.h&quot; // for debugging only</span>
  56. <a name="l00027"></a>00027
  57. <a name="l00028"></a><a class="code" href="wxlstate_8cpp.html#a0ef6804bd2cb63f4fa705727f8871cbd">00028</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#a0ef6804bd2cb63f4fa705727f8871cbd">wxlua_lreg_types_key</a> = <span class="stringliteral">&quot;wxLua metatable class types&quot;</span>;
  58. <a name="l00029"></a><a class="code" href="wxlstate_8cpp.html#ac4ac0a3575fafde31e659ced85f69c4d">00029</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#ac4ac0a3575fafde31e659ced85f69c4d">wxlua_lreg_refs_key</a> = <span class="stringliteral">&quot;wxLua Lua object refs&quot;</span>;
  59. <a name="l00030"></a><a class="code" href="wxlstate_8cpp.html#a30c2d5556a4a278368b48fe0b7bb3fda">00030</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#a30c2d5556a4a278368b48fe0b7bb3fda">wxlua_lreg_debug_refs_key</a> = <span class="stringliteral">&quot;wxLuaDebugData refs&quot;</span>;
  60. <a name="l00031"></a><a class="code" href="wxlstate_8cpp.html#a0bcf696ed6d6e2b4218e9a8852a164ef">00031</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#a0bcf696ed6d6e2b4218e9a8852a164ef">wxlua_lreg_classes_key</a> = <span class="stringliteral">&quot;wxLuaBindClass structs&quot;</span>;
  61. <a name="l00032"></a><a class="code" href="wxlstate_8cpp.html#a274b8b7aae6f647e3e69d098962b7b1d">00032</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#a274b8b7aae6f647e3e69d098962b7b1d">wxlua_lreg_derivedmethods_key</a> = <span class="stringliteral">&quot;wxLua derived class methods&quot;</span>;
  62. <a name="l00033"></a><a class="code" href="wxlstate_8cpp.html#a921299ed63513972e3bda3678fc835c0">00033</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#a921299ed63513972e3bda3678fc835c0">wxlua_lreg_wxluastate_key</a> = <span class="stringliteral">&quot;wxLuaState&quot;</span>;
  63. <a name="l00034"></a><a class="code" href="wxlstate_8cpp.html#a80a0d4c84529abdcf6b46237431832ce">00034</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#a80a0d4c84529abdcf6b46237431832ce">wxlua_lreg_wxluabindings_key</a> = <span class="stringliteral">&quot;wxLuaBindings&quot;</span>;
  64. <a name="l00035"></a><a class="code" href="wxlstate_8cpp.html#af255531a04d81a0d82556c0d1fe8e7e7">00035</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#af255531a04d81a0d82556c0d1fe8e7e7">wxlua_lreg_weakobjects_key</a> = <span class="stringliteral">&quot;wxLua objects pushed&quot;</span>;
  65. <a name="l00036"></a><a class="code" href="wxlstate_8cpp.html#a7ec5afec8a64a29e28fefec4a1105790">00036</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#a7ec5afec8a64a29e28fefec4a1105790">wxlua_lreg_gcobjects_key</a> = <span class="stringliteral">&quot;wxLua gc objects to delete&quot;</span>;
  66. <a name="l00037"></a><a class="code" href="wxlstate_8cpp.html#a034985fb7df51670c3b6a024329496fa">00037</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#a034985fb7df51670c3b6a024329496fa">wxlua_lreg_evtcallbacks_key</a> = <span class="stringliteral">&quot;wxLuaEventCallbacks&quot;</span>;
  67. <a name="l00038"></a><a class="code" href="wxlstate_8cpp.html#ae13b14073477671929c41823f198c33d">00038</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#ae13b14073477671929c41823f198c33d">wxlua_lreg_windestroycallbacks_key</a> = <span class="stringliteral">&quot;wxLuaWinDestoyCallbacks&quot;</span>;
  68. <a name="l00039"></a><a class="code" href="wxlstate_8cpp.html#aab2351a78a8949184e1910cc1f9e7463">00039</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#aab2351a78a8949184e1910cc1f9e7463">wxlua_lreg_topwindows_key</a> = <span class="stringliteral">&quot;wxLua top level wxWindows&quot;</span>;
  69. <a name="l00040"></a><a class="code" href="wxlstate_8cpp.html#a91d0a86787b3a1de5921590ce6a0b3e8">00040</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#a91d0a86787b3a1de5921590ce6a0b3e8">wxlua_lreg_callbaseclassfunc_key</a> = <span class="stringliteral">&quot;wxLua CallBaseClassFunc&quot;</span>;
  70. <a name="l00041"></a><a class="code" href="wxlstate_8cpp.html#af24ccc441c899b3028cfc5d4099c739a">00041</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#af24ccc441c899b3028cfc5d4099c739a">wxlua_lreg_wxeventtype_key</a> = <span class="stringliteral">&quot;wxLua wxEventType&quot;</span>;
  71. <a name="l00042"></a><a class="code" href="wxlstate_8cpp.html#aba1ad42faf08e4b50bca48b5ba9d8ece">00042</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#aba1ad42faf08e4b50bca48b5ba9d8ece">wxlua_lreg_wxluastatedata_key</a> = <span class="stringliteral">&quot;wxLuaStateData&quot;</span>;
  72. <a name="l00043"></a><a class="code" href="wxlstate_8cpp.html#ab84cb2515893ab069d7d165208e68aad">00043</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#ab84cb2515893ab069d7d165208e68aad">wxlua_lreg_regtable_key</a> = <span class="stringliteral">&quot;wxLua LUA_REGISTRYINDEX tables&quot;</span>;
  73. <a name="l00044"></a>00044
  74. <a name="l00045"></a><a class="code" href="wxlstate_8cpp.html#a663c0f4ffbb1923edf3055b4c8c81ff9">00045</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#a663c0f4ffbb1923edf3055b4c8c81ff9">wxlua_metatable_type_key</a> = <span class="stringliteral">&quot;wxLua metatable class type&quot;</span>;
  75. <a name="l00046"></a><a class="code" href="wxlstate_8cpp.html#a8719cfeea23ebd1cb309de8296777da6">00046</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="wxlstate_8h.html#a8719cfeea23ebd1cb309de8296777da6">wxlua_metatable_wxluabindclass_key</a> = <span class="stringliteral">&quot;wxLua metatable wxLuaBindClass&quot;</span>;
  76. <a name="l00047"></a>00047
  77. <a name="l00048"></a>00048 <a class="code" href="classwxLuaState.html">wxLuaState</a> <a class="code" href="wxlstate_8h.html#aef06b6591011cd68b9e370d5e702d255">wxNullLuaState</a>(<span class="keyword">false</span>);
  78. <a name="l00049"></a>00049
  79. <a name="l00050"></a>00050 <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlstate_8cpp.html#ab03a3095ab5d0f4a427b4c5b10aa4e5c">luaopen_bit</a>(lua_State *L); <span class="comment">// implemented at bottom of file</span>
  80. <a name="l00051"></a>00051
  81. <a name="l00052"></a>00052 <span class="comment">// ----------------------------------------------------------------------------</span>
  82. <a name="l00053"></a>00053 <span class="comment">// C functions for Lua used in wxLuaState</span>
  83. <a name="l00054"></a>00054 <span class="comment">// ----------------------------------------------------------------------------</span>
  84. <a name="l00055"></a>00055
  85. <a name="l00056"></a>00056 <span class="comment">// The print function that we push into Lua replacing &quot;print(...)&quot;</span>
  86. <a name="l00057"></a>00057 <span class="comment">// to generate wxLuaEvent(wxEVT_LUA_PRINT, ...)</span>
  87. <a name="l00058"></a>00058 <span class="comment">// Code copied from Lua&#39;s luaB_print() function in lbaselib.c</span>
  88. <a name="l00059"></a><a class="code" href="wxlstate_8cpp.html#a7c982cbdf126f61b0868fe40baf150c4">00059</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlstate_8cpp.html#a7c982cbdf126f61b0868fe40baf150c4">wxlua_printFunction</a>( lua_State *L )
  89. <a name="l00060"></a>00060 {
  90. <a name="l00061"></a>00061 <a class="code" href="classwxLuaState.html">wxLuaState</a> wxlState(L); <span class="comment">// doesn&#39;t have to be ok</span>
  91. <a name="l00062"></a>00062
  92. <a name="l00063"></a>00063 wxString msg;
  93. <a name="l00064"></a>00064 <span class="keywordtype">int</span> i, n = lua_gettop(L);
  94. <a name="l00065"></a>00065
  95. <a name="l00066"></a>00066 <span class="comment">// Use the Lua tostring() function to print them as Lua would</span>
  96. <a name="l00067"></a>00067 lua_getglobal(L, <span class="stringliteral">&quot;tostring&quot;</span>);
  97. <a name="l00068"></a>00068
  98. <a name="l00069"></a>00069 <span class="keywordflow">if</span> (!lua_isfunction(L, -1))
  99. <a name="l00070"></a>00070 {
  100. <a name="l00071"></a>00071 <span class="comment">// This code is also used in wxledit.cpp, wxLuaShell::RunString()</span>
  101. <a name="l00072"></a>00072 msg = wxT(<span class="stringliteral">&quot;wxLua ERROR: Unable to print() without the tostring() function. Did you remove it?&quot;</span>);
  102. <a name="l00073"></a>00073 lua_pop(L, 1); <span class="comment">// pop the nil or whatever replaced tostring()</span>
  103. <a name="l00074"></a>00074 n = 0; <span class="comment">// don&#39;t let for loop run</span>
  104. <a name="l00075"></a>00075 }
  105. <a name="l00076"></a>00076
  106. <a name="l00077"></a>00077 <span class="keywordflow">for</span> (i = 1; i &lt;= n; ++i)
  107. <a name="l00078"></a>00078 {
  108. <a name="l00079"></a>00079 <span class="keywordflow">if</span> (i &gt; 1) msg.Append(wxT(<span class="stringliteral">&quot;\t&quot;</span>)); <span class="comment">// Lua uses a tab too in luaB_print</span>
  109. <a name="l00080"></a>00080
  110. <a name="l00081"></a>00081 <span class="keyword">const</span> <span class="keywordtype">char</span> *s;
  111. <a name="l00082"></a>00082 lua_pushvalue(L, -1); <span class="comment">/* function to be called */</span>
  112. <a name="l00083"></a>00083 lua_pushvalue(L, i); <span class="comment">/* value to print */</span>
  113. <a name="l00084"></a>00084 lua_call(L, 1, 1);
  114. <a name="l00085"></a>00085 s = lua_tostring(L, -1); <span class="comment">/* get result */</span>
  115. <a name="l00086"></a>00086 <span class="keywordflow">if</span> (s == NULL)
  116. <a name="l00087"></a>00087 {
  117. <a name="l00088"></a>00088 <span class="comment">// FIXME use wxlua_error here? right now wxlua_error doesn&#39;t do anything special - JL</span>
  118. <a name="l00089"></a>00089 <span class="keywordflow">return</span> luaL_error(L, LUA_QL(<span class="stringliteral">&quot;tostring&quot;</span>) <span class="stringliteral">&quot; must return a string to &quot;</span>
  119. <a name="l00090"></a>00090 LUA_QL(<span class="stringliteral">&quot;print&quot;</span>));
  120. <a name="l00091"></a>00091 }
  121. <a name="l00092"></a>00092 msg += <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(s);
  122. <a name="l00093"></a>00093 lua_pop(L, 1); <span class="comment">/* pop result */</span>
  123. <a name="l00094"></a>00094 }
  124. <a name="l00095"></a>00095
  125. <a name="l00096"></a>00096 <span class="keywordflow">if</span> (!msg.IsEmpty() &amp;&amp; wxlState.<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>())
  126. <a name="l00097"></a>00097 {
  127. <a name="l00098"></a>00098 <a class="code" href="classwxLuaEvent.html">wxLuaEvent</a> event(wxEVT_LUA_PRINT, wxlState.<a class="code" href="classwxLuaState.html#a92715872ca9f5f4b6e77344410963350">GetId</a>(), wxlState);
  128. <a name="l00099"></a>00099 <span class="keyword">event</span>.SetString(msg);
  129. <a name="l00100"></a>00100 wxlState.<a class="code" href="classwxLuaState.html#a1f0e0a065e8c3ea25c0ebe5c7258f7ae">SendEvent</a>(event);
  130. <a name="l00101"></a>00101 }
  131. <a name="l00102"></a>00102 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!msg.IsEmpty())
  132. <a name="l00103"></a>00103 wxPrintf(wxT(<span class="stringliteral">&quot;%s\n&quot;</span>), msg.c_str()); <span class="comment">// Lua puts a \n too</span>
  133. <a name="l00104"></a>00104
  134. <a name="l00105"></a>00105 <span class="keywordflow">return</span> 0; <span class="comment">// no items put onto stack</span>
  135. <a name="l00106"></a>00106 }
  136. <a name="l00107"></a>00107
  137. <a name="l00108"></a><a class="code" href="wxlstate_8cpp.html#a9eab35a72e3a0d8e1a669fb831a5272d">00108</a> <span class="keywordtype">void</span> LUACALL <a class="code" href="wxlstate_8cpp.html#a9eab35a72e3a0d8e1a669fb831a5272d">wxlua_debugHookFunction</a>(lua_State *L, lua_Debug *LDebug)
  138. <a name="l00109"></a>00109 {
  139. <a name="l00110"></a>00110 <span class="comment">// NULL when shutting down.</span>
  140. <a name="l00111"></a>00111 <a class="code" href="classwxLuaStateData.html">wxLuaStateData</a>* wxlStateData = <a class="code" href="wxlstate_8h.html#a4c7701b4b056e2f84f380be559bb2482">wxlua_getwxluastatedata</a>(L);
  141. <a name="l00112"></a>00112 <span class="keywordflow">if</span> (!wxlStateData) <span class="keywordflow">return</span>;
  142. <a name="l00113"></a>00113
  143. <a name="l00114"></a>00114 <span class="comment">// FIXME - for select event types we don&#39;t want to do anything</span>
  144. <a name="l00115"></a>00115 wxEventType evtType = <a class="code" href="wxlstate_8h.html#a5442b3e5a2f8dca8fb920c00279385ac">wxlua_getwxeventtype</a>(L);
  145. <a name="l00116"></a>00116 <span class="keywordflow">if</span> ((evtType != wxEVT_NULL))
  146. <a name="l00117"></a>00117 <span class="comment">//(evtType == wxEVT_IDLE) &amp;&amp; (evtType == wxEVT_PAINT) &amp;&amp;</span>
  147. <a name="l00118"></a>00118 <span class="comment">//(evtType == wxEVT_DESTROY) &amp;&amp; (evtType == wxEVT_CLOSE_WINDOW))</span>
  148. <a name="l00119"></a>00119 <span class="keywordflow">return</span>;
  149. <a name="l00120"></a>00120
  150. <a name="l00121"></a>00121 <span class="comment">// they want to break the program, restore old debug hook, then error out</span>
  151. <a name="l00122"></a>00122 <span class="keywordflow">if</span> (wxlStateData-&gt;<a class="code" href="classwxLuaStateData.html#abb85e04d6c6dd5a5b31ec55c3c3fdd8f">m_debug_hook_break</a>)
  152. <a name="l00123"></a>00123 {
  153. <a name="l00124"></a>00124 <span class="comment">// It&#39;s ok that we get the wxLuaState here since we&#39;re stopping anyway.</span>
  154. <a name="l00125"></a>00125 <a class="code" href="classwxLuaState.html">wxLuaState</a> wxlState(L);
  155. <a name="l00126"></a>00126
  156. <a name="l00127"></a>00127 <span class="comment">// restore hook to previous state</span>
  157. <a name="l00128"></a>00128 wxlState.<a class="code" href="classwxLuaState.html#a61b2c790f1b50df9c8b41ef6cc8e58e9">ClearDebugHookBreak</a>();
  158. <a name="l00129"></a>00129 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, wxlStateData-&gt;<a class="code" href="classwxLuaStateData.html#a375859ee7c4407fb3c5588b39705de2d">m_debug_hook_break_msg</a>);
  159. <a name="l00130"></a>00130 <span class="keywordflow">return</span>;
  160. <a name="l00131"></a>00131 }
  161. <a name="l00132"></a>00132
  162. <a name="l00133"></a>00133 <span class="comment">// Assume they&#39;ve set the wxEvtHandler, ok if not, but it wouldn&#39;t make sense</span>
  163. <a name="l00134"></a>00134 <span class="comment">// We use wxLuaState::SendEvent() because it sets wxEvent::SetEventObject() for us.</span>
  164. <a name="l00135"></a>00135 <span class="keywordflow">if</span> (wxlStateData-&gt;<a class="code" href="classwxLuaStateData.html#adee2d0bdd61585268fc43c18bd0d1116">m_lua_debug_hook_send_evt</a>)
  165. <a name="l00136"></a>00136 {
  166. <a name="l00137"></a>00137 <a class="code" href="classwxLuaState.html">wxLuaState</a> wxlState(L);
  167. <a name="l00138"></a>00138
  168. <a name="l00139"></a>00139 <span class="keywordtype">int</span> ret = 0;
  169. <a name="l00140"></a>00140 ret = lua_getinfo(L, <span class="stringliteral">&quot;l&quot;</span>, LDebug); <span class="comment">// line (ldebug.currentline)</span>
  170. <a name="l00141"></a>00141
  171. <a name="l00142"></a>00142 <a class="code" href="classwxLuaEvent.html">wxLuaEvent</a> event(wxEVT_LUA_DEBUG_HOOK, wxlState.<a class="code" href="classwxLuaState.html#a92715872ca9f5f4b6e77344410963350">GetId</a>(), wxlState);
  172. <a name="l00143"></a>00143 <span class="keyword">event</span>.m_lua_Debug = LDebug;
  173. <a name="l00144"></a>00144 <span class="keyword">event</span>.SetInt(LDebug-&gt;currentline);
  174. <a name="l00145"></a>00145 wxlState.<a class="code" href="classwxLuaState.html#a1f0e0a065e8c3ea25c0ebe5c7258f7ae">SendEvent</a>( event );
  175. <a name="l00146"></a>00146 <span class="keywordflow">if</span> (event.m_debug_hook_break)
  176. <a name="l00147"></a>00147 wxlState.<a class="code" href="classwxLuaState.html#a4925fb35a1622f81fc9c5dc5820e27d8">wxlua_Error</a>(<span class="stringliteral">&quot;Lua interpreter stopped.&quot;</span>);
  177. <a name="l00148"></a>00148 }
  178. <a name="l00149"></a>00149
  179. <a name="l00150"></a>00150 <span class="comment">// Try to yield *after* sending event to allow C++ gui update</span>
  180. <a name="l00151"></a>00151 <span class="keywordflow">if</span> (wxlStateData-&gt;<a class="code" href="classwxLuaStateData.html#a16aa632cff2de6c2ee2e2cab9a03b9a1">m_lua_debug_hook_yield</a> &gt; 0)
  181. <a name="l00152"></a>00152 {
  182. <a name="l00153"></a>00153 <span class="comment">// yield based on number of ms passed NOT every hook event</span>
  183. <a name="l00154"></a>00154 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> last_time = wxlStateData-&gt;<a class="code" href="classwxLuaStateData.html#aa7500e45a81ca35fc3fe1b66c2aa38fd">m_last_debug_hook_time</a>;
  184. <a name="l00155"></a>00155 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> cur_time = wxGetLocalTimeMillis().GetLo();
  185. <a name="l00156"></a>00156
  186. <a name="l00157"></a>00157 <span class="keywordflow">if</span> ((cur_time &gt; last_time + wxlStateData-&gt;<a class="code" href="classwxLuaStateData.html#a16aa632cff2de6c2ee2e2cab9a03b9a1">m_lua_debug_hook_yield</a>) ||
  187. <a name="l00158"></a>00158 (cur_time &lt; last_time)) <span class="comment">// wrapped</span>
  188. <a name="l00159"></a>00159 {
  189. <a name="l00160"></a>00160 wxlStateData-&gt;<a class="code" href="classwxLuaStateData.html#aa7500e45a81ca35fc3fe1b66c2aa38fd">m_last_debug_hook_time</a> = cur_time;
  190. <a name="l00161"></a>00161
  191. <a name="l00162"></a>00162 <span class="keywordtype">bool</span> painting = (evtType == wxEVT_PAINT);
  192. <a name="l00163"></a>00163
  193. <a name="l00164"></a>00164 <span class="comment">/*</span>
  194. <a name="l00165"></a>00165 <span class="comment"> wxLongToLongHashMap::iterator it;</span>
  195. <a name="l00166"></a>00166 <span class="comment"> wxLongToLongHashMap* hashMap = &amp;wxlState.GetLuaStateRefData()-&gt;m_wxlStateData-&gt;m_trackedObjects;</span>
  196. <a name="l00167"></a>00167 <span class="comment"> for (it = hashMap-&gt;begin(); it != hashMap-&gt;end(); ++it)</span>
  197. <a name="l00168"></a>00168 <span class="comment"> {</span>
  198. <a name="l00169"></a>00169 <span class="comment"> wxObject* obj = (wxObject*)it-&gt;second;</span>
  199. <a name="l00170"></a>00170 <span class="comment"> if (obj &amp;&amp; wxDynamicCast(obj, wxPaintDC))</span>
  200. <a name="l00171"></a>00171 <span class="comment"> {</span>
  201. <a name="l00172"></a>00172 <span class="comment"> painting = true;</span>
  202. <a name="l00173"></a>00173 <span class="comment"> break;</span>
  203. <a name="l00174"></a>00174 <span class="comment"> }</span>
  204. <a name="l00175"></a>00175 <span class="comment"> }</span>
  205. <a name="l00176"></a>00176 <span class="comment">*/</span>
  206. <a name="l00177"></a>00177
  207. <a name="l00178"></a>00178 <span class="keywordflow">if</span> (!painting)
  208. <a name="l00179"></a>00179 wxYield(); <span class="comment">//IfNeeded();</span>
  209. <a name="l00180"></a>00180 }
  210. <a name="l00181"></a>00181 }
  211. <a name="l00182"></a>00182 }
  212. <a name="l00183"></a>00183
  213. <a name="l00184"></a>00184 <span class="comment">// ----------------------------------------------------------------------------</span>
  214. <a name="l00185"></a>00185
  215. <a name="l00186"></a><a class="code" href="wxlstate_8cpp.html#a7185a0c6fb640503f4921f15811ff4ac">00186</a> <span class="keywordtype">void</span> <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(lua_State* L, <span class="keywordtype">void</span>* lightuserdata_reg_key, <span class="keywordtype">int</span> narr, <span class="keywordtype">int</span> nrec)
  216. <a name="l00187"></a>00187 {
  217. <a name="l00188"></a>00188 <span class="comment">// clear the old ref to the table, even though it&#39;s weak kv</span>
  218. <a name="l00189"></a>00189 <span class="comment">// it doesn&#39;t get cleared until the gc runs</span>
  219. <a name="l00190"></a>00190 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#ab84cb2515893ab069d7d165208e68aad">wxlua_lreg_regtable_key</a>); <span class="comment">// push key</span>
  220. <a name="l00191"></a>00191 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// get table</span>
  221. <a name="l00192"></a>00192 lua_pushlightuserdata(L, lightuserdata_reg_key); <span class="comment">// push key</span>
  222. <a name="l00193"></a>00193 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// get table or nil</span>
  223. <a name="l00194"></a>00194 <span class="keywordflow">if</span> (lua_istable(L, -1))
  224. <a name="l00195"></a>00195 {
  225. <a name="l00196"></a>00196 lua_pushnil(L); <span class="comment">// push value</span>
  226. <a name="l00197"></a>00197 lua_rawset(L, -3); <span class="comment">// clear t[key] = nil</span>
  227. <a name="l00198"></a>00198 lua_pop(L, 1); <span class="comment">// pop wxlua_lreg_regtable_key table</span>
  228. <a name="l00199"></a>00199 }
  229. <a name="l00200"></a>00200 <span class="keywordflow">else</span>
  230. <a name="l00201"></a>00201 lua_pop(L, 2); <span class="comment">// pop nil and wxlua_lreg_regtable_key table</span>
  231. <a name="l00202"></a>00202
  232. <a name="l00203"></a>00203 <span class="comment">// Add new LUA_REGISTRYINDEX[&amp;wxlua_lreg_regtable_key][lightuserdata_reg_key table] = lightuserdata_reg_key</span>
  233. <a name="l00204"></a>00204 lua_pushlightuserdata(L, lightuserdata_reg_key); <span class="comment">// push key</span>
  234. <a name="l00205"></a>00205 lua_createtable(L, narr, nrec); <span class="comment">// push value</span>
  235. <a name="l00206"></a>00206 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#ab84cb2515893ab069d7d165208e68aad">wxlua_lreg_regtable_key</a>); <span class="comment">// push key</span>
  236. <a name="l00207"></a>00207 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// get wxlua_lreg_regtable_key table</span>
  237. <a name="l00208"></a>00208 lua_pushvalue(L, -2); <span class="comment">// push key (copy of the new table)</span>
  238. <a name="l00209"></a>00209 lua_pushvalue(L, -4); <span class="comment">// push value (copy of lightuserdata key)</span>
  239. <a name="l00210"></a>00210 lua_rawset(L, -3); <span class="comment">// set t[key] = value; pops key and value</span>
  240. <a name="l00211"></a>00211 lua_pop(L, 1); <span class="comment">// pop wxlua_lreg_regtable_key table</span>
  241. <a name="l00212"></a>00212 lua_rawset(L, LUA_REGISTRYINDEX); <span class="comment">// set the value</span>
  242. <a name="l00213"></a>00213 }
  243. <a name="l00214"></a>00214
  244. <a name="l00215"></a>00215 <span class="comment">// ----------------------------------------------------------------------------</span>
  245. <a name="l00216"></a>00216 <span class="comment">// Lua helper functions</span>
  246. <a name="l00217"></a>00217 <span class="comment">// ----------------------------------------------------------------------------</span>
  247. <a name="l00218"></a>00218
  248. <a name="l00219"></a><a class="code" href="wxlstate_8cpp.html#ab2ae5dfea9cc867ed46ed094ce4e768f">00219</a> wxString <a class="code" href="wxlstate_8h.html#ab2ae5dfea9cc867ed46ed094ce4e768f">wxlua_LUA_ERR_msg</a>(<span class="keywordtype">int</span> LUA_ERRx)
  249. <a name="l00220"></a>00220 {
  250. <a name="l00221"></a>00221 <span class="keywordflow">switch</span> (LUA_ERRx)
  251. <a name="l00222"></a>00222 {
  252. <a name="l00223"></a>00223 <span class="keywordflow">case</span> 0 : <span class="keywordflow">return</span> wxEmptyString;
  253. <a name="l00224"></a>00224 <span class="keywordflow">case</span> LUA_YIELD : <span class="keywordflow">return</span> wxT(<span class="stringliteral">&quot;Lua: Thread is suspended&quot;</span>);
  254. <a name="l00225"></a>00225 <span class="keywordflow">case</span> LUA_ERRRUN : <span class="keywordflow">return</span> wxT(<span class="stringliteral">&quot;Lua: Error while running chunk&quot;</span>);
  255. <a name="l00226"></a>00226 <span class="keywordflow">case</span> LUA_ERRSYNTAX : <span class="keywordflow">return</span> wxT(<span class="stringliteral">&quot;Lua: Syntax error during pre-compilation&quot;</span>);
  256. <a name="l00227"></a>00227 <span class="keywordflow">case</span> LUA_ERRMEM : <span class="keywordflow">return</span> wxT(<span class="stringliteral">&quot;Lua: Memory allocation error&quot;</span>);
  257. <a name="l00228"></a>00228 <span class="keywordflow">case</span> LUA_ERRERR : <span class="keywordflow">return</span> wxT(<span class="stringliteral">&quot;Lua: Generic error or an error occurred while running the error handler&quot;</span>);
  258. <a name="l00229"></a>00229 <span class="keywordflow">case</span> LUA_ERRFILE : <span class="keywordflow">return</span> wxT(<span class="stringliteral">&quot;Lua: Error occurred while opening file&quot;</span>);
  259. <a name="l00230"></a>00230 }
  260. <a name="l00231"></a>00231
  261. <a name="l00232"></a>00232 <span class="keywordflow">return</span> wxT(<span class="stringliteral">&quot;Lua: Unknown LUA_ERRx error value&quot;</span>);
  262. <a name="l00233"></a>00233 }
  263. <a name="l00234"></a>00234
  264. <a name="l00235"></a><a class="code" href="wxlstate_8cpp.html#a0c9eeb57ad65f8e174030f03af466331">00235</a> <span class="keywordtype">bool</span> <a class="code" href="wxlstate_8h.html#a34d4dc64c6615a3e7c4fea5f6fb5840f">wxlua_errorinfo</a>(lua_State* L, <span class="keywordtype">int</span> status, <span class="keywordtype">int</span> top, wxString* errorMsg_, <span class="keywordtype">int</span>* line_num_)
  265. <a name="l00236"></a>00236 {
  266. <a name="l00237"></a>00237 <span class="keywordflow">if</span> (status == 0)
  267. <a name="l00238"></a>00238 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  268. <a name="l00239"></a>00239
  269. <a name="l00240"></a>00240 <span class="keywordtype">int</span> newtop = lua_gettop(L);
  270. <a name="l00241"></a>00241
  271. <a name="l00242"></a>00242 wxString errorMsg = <a class="code" href="wxlstate_8h.html#ab2ae5dfea9cc867ed46ed094ce4e768f">wxlua_LUA_ERR_msg</a>(status);
  272. <a name="l00243"></a>00243
  273. <a name="l00244"></a>00244 <span class="keywordflow">switch</span>(status)
  274. <a name="l00245"></a>00245 {
  275. <a name="l00246"></a>00246 <span class="keywordflow">case</span> LUA_ERRMEM:
  276. <a name="l00247"></a>00247 <span class="keywordflow">case</span> LUA_ERRERR:
  277. <a name="l00248"></a>00248 {
  278. <a name="l00249"></a>00249 <span class="keywordflow">if</span> (newtop &gt; top)
  279. <a name="l00250"></a>00250 errorMsg += wxT(<span class="stringliteral">&quot;\n&quot;</span>);
  280. <a name="l00251"></a>00251 <span class="keywordflow">break</span>;
  281. <a name="l00252"></a>00252 }
  282. <a name="l00253"></a>00253 <span class="keywordflow">case</span> LUA_ERRRUN:
  283. <a name="l00254"></a>00254 <span class="keywordflow">case</span> LUA_ERRFILE:
  284. <a name="l00255"></a>00255 <span class="keywordflow">case</span> LUA_ERRSYNTAX:
  285. <a name="l00256"></a>00256 <span class="keywordflow">default</span>:
  286. <a name="l00257"></a>00257 {
  287. <a name="l00258"></a>00258 <span class="keywordflow">if</span> (newtop &gt; top)
  288. <a name="l00259"></a>00259 errorMsg += wxT(<span class="stringliteral">&quot;\n&quot;</span>) + <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(lua_tostring(L, -1));
  289. <a name="l00260"></a>00260 <span class="keywordflow">break</span>;
  290. <a name="l00261"></a>00261 }
  291. <a name="l00262"></a>00262 }
  292. <a name="l00263"></a>00263
  293. <a name="l00264"></a>00264 errorMsg += wxT(<span class="stringliteral">&quot;\n&quot;</span>);
  294. <a name="l00265"></a>00265
  295. <a name="l00266"></a>00266 <span class="comment">// Why can&#39;t I fill a lua_Debug here? Try to get the line number</span>
  296. <a name="l00267"></a>00267 <span class="comment">// by parsing the error message that looks like this, 3 is linenumber</span>
  297. <a name="l00268"></a>00268 <span class="comment">// [string &quot;a = 1(&quot;]:3: unexpected symbol near `&lt;eof&gt;&#39;</span>
  298. <a name="l00269"></a>00269 wxString lineStr = errorMsg;
  299. <a name="l00270"></a>00270 <span class="keywordtype">long</span> line_num = -1;
  300. <a name="l00271"></a>00271 <span class="keywordflow">while</span>(!lineStr.IsEmpty())
  301. <a name="l00272"></a>00272 {
  302. <a name="l00273"></a>00273 <span class="comment">// search through the str to find &#39;]:LONG:&#39; pattern</span>
  303. <a name="l00274"></a>00274 lineStr = lineStr.AfterFirst(wxT(<span class="charliteral">&#39;]&#39;</span>));
  304. <a name="l00275"></a>00275 <span class="keywordflow">if</span> ((lineStr.Length() &gt; 0) &amp;&amp; (lineStr.GetChar(0) == wxT(<span class="charliteral">&#39;:&#39;</span>)))
  305. <a name="l00276"></a>00276 {
  306. <a name="l00277"></a>00277 lineStr = lineStr.AfterFirst(wxT(<span class="charliteral">&#39;:&#39;</span>));
  307. <a name="l00278"></a>00278 <span class="keywordflow">if</span> (lineStr.IsEmpty() || lineStr.BeforeFirst(wxT(<span class="charliteral">&#39;:&#39;</span>)).ToLong(&amp;line_num))
  308. <a name="l00279"></a>00279 <span class="keywordflow">break</span>;
  309. <a name="l00280"></a>00280 }
  310. <a name="l00281"></a>00281 }
  311. <a name="l00282"></a>00282
  312. <a name="l00283"></a>00283 lua_settop(L, top); <span class="comment">// pops the message if any</span>
  313. <a name="l00284"></a>00284
  314. <a name="l00285"></a>00285 <span class="keywordflow">if</span> (errorMsg_) *errorMsg_ = errorMsg;
  315. <a name="l00286"></a>00286 <span class="keywordflow">if</span> (line_num_) *line_num_ = (int)line_num;
  316. <a name="l00287"></a>00287
  317. <a name="l00288"></a>00288 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  318. <a name="l00289"></a>00289 }
  319. <a name="l00290"></a>00290
  320. <a name="l00291"></a><a class="code" href="wxlstate_8cpp.html#a1abe07e896f1e813fc28da0e0d92961a">00291</a> <span class="keywordtype">void</span> LUACALL <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(lua_State *L, <span class="keyword">const</span> <span class="keywordtype">char</span> *errorMsg)
  321. <a name="l00292"></a>00292 {
  322. <a name="l00293"></a>00293 <span class="comment">// Use luaL_error(L, s) and not &quot;lua_pushstring(L, s); lua_error(L)&quot; since</span>
  323. <a name="l00294"></a>00294 <span class="comment">// luaL_error() provides the file and line number too.</span>
  324. <a name="l00295"></a>00295 luaL_error(L, <span class="stringliteral">&quot;%s&quot;</span>, errorMsg);
  325. <a name="l00296"></a>00296 }
  326. <a name="l00297"></a>00297
  327. <a name="l00298"></a><a class="code" href="wxlstate_8cpp.html#aba05dfc5f8a48e264d7463a7c6fee965">00298</a> <span class="keywordtype">void</span> LUACALL <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(lua_State *L, <span class="keywordtype">int</span> stack_idx, <span class="keyword">const</span> wxString&amp; expectedType)
  328. <a name="l00299"></a>00299 {
  329. <a name="l00300"></a>00300 wxString argType = <a class="code" href="wxlstate_8h.html#acf6d708626f3c7194d1f2aebb7a73b6e">wxlua_luaL_typename</a>(L, stack_idx);
  330. <a name="l00301"></a>00301
  331. <a name="l00302"></a>00302 wxString msg(wxString::Format(_(<span class="stringliteral">&quot;wxLua: Expected %s for parameter %d, but got a &#39;%s&#39;.&quot;</span>),
  332. <a name="l00303"></a>00303 expectedType.c_str(), stack_idx, argType.c_str()));
  333. <a name="l00304"></a>00304
  334. <a name="l00305"></a>00305 <a class="code" href="wxlstate_8h.html#a34376827e7b3466173127fba976217d0">wxlua_argerrormsg</a>(L, msg);
  335. <a name="l00306"></a>00306 }
  336. <a name="l00307"></a>00307
  337. <a name="l00308"></a><a class="code" href="wxlstate_8cpp.html#aa4db1ed30ef56e312dcf5e9cca75bcb2">00308</a> <span class="keywordtype">void</span> LUACALL <a class="code" href="wxlstate_8h.html#a34376827e7b3466173127fba976217d0">wxlua_argerrormsg</a>(lua_State *L, <span class="keyword">const</span> wxString&amp; msg_)
  338. <a name="l00309"></a>00309 {
  339. <a name="l00310"></a>00310 wxString funcArgs(wxT(<span class="stringliteral">&quot;\n&quot;</span>));
  340. <a name="l00311"></a>00311 wxString argMsg = <a class="code" href="wxlbind_8h.html#a15f78fa970b76c7963c3e11f90d988ca">wxlua_getLuaArgsMsg</a>(L, 1, lua_gettop(L));
  341. <a name="l00312"></a>00312
  342. <a name="l00313"></a>00313 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod = (<a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a> *)lua_touserdata(L, lua_upvalueindex(1)); <span class="comment">// lightuserdata</span>
  343. <a name="l00314"></a>00314 <span class="keywordflow">if</span> (wxlMethod != NULL)
  344. <a name="l00315"></a>00315 {
  345. <a name="l00316"></a>00316 <span class="comment">// Guarantee that this is a wxLuaBindMethod of ours so we don&#39;t crash.</span>
  346. <a name="l00317"></a>00317 <span class="comment">// Since we&#39;re going to error out we don&#39;t have to be quick about it.</span>
  347. <a name="l00318"></a>00318
  348. <a name="l00319"></a>00319 <span class="comment">// check if this method is part of a class</span>
  349. <a name="l00320"></a>00320 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = <a class="code" href="classwxLuaBinding.html#a7ee5e4f66198a0ef9e8cc4c2a6d0318e">wxLuaBinding::FindBindClass</a>(wxlMethod);
  350. <a name="l00321"></a>00321
  351. <a name="l00322"></a>00322 <span class="comment">// if not, check if it&#39;s a global C style function</span>
  352. <a name="l00323"></a>00323 <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding = NULL;
  353. <a name="l00324"></a>00324 <span class="keywordflow">if</span> (wxlClass == NULL)
  354. <a name="l00325"></a>00325 binding = <a class="code" href="classwxLuaBinding.html#a463d056fe9bcb54f0408a8ae523ba64e">wxLuaBinding::FindMethodBinding</a>(wxlMethod);
  355. <a name="l00326"></a>00326
  356. <a name="l00327"></a>00327 <span class="keywordflow">if</span> ((wxlClass != NULL) || (binding != NULL))
  357. <a name="l00328"></a>00328 funcArgs += <a class="code" href="wxlbind_8h.html#a0cf1f6600d0f80e2135c6788a4afc39f">wxlua_getBindMethodArgsMsg</a>(L, wxlMethod);
  358. <a name="l00329"></a>00329 }
  359. <a name="l00330"></a>00330
  360. <a name="l00331"></a>00331 wxString msg = msg_ + wxT(<span class="stringliteral">&quot;\nFunction called: &#39;&quot;</span>) + argMsg + wxT(<span class="stringliteral">&quot;&#39;&quot;</span>) + funcArgs;
  361. <a name="l00332"></a>00332 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, msg);
  362. <a name="l00333"></a>00333 }
  363. <a name="l00334"></a>00334
  364. <a name="l00335"></a><a class="code" href="wxlstate_8cpp.html#adde66f46b163a0fc59e09904cf355792">00335</a> <span class="keywordtype">void</span>* LUACALL <a class="code" href="wxlstate_8h.html#ac5a0a65665274df59adbed667480e93e">wxlua_touserdata</a>(lua_State *L, <span class="keywordtype">int</span> stack_idx, <span class="keywordtype">bool</span> null_ptr <span class="comment">/*= false*/</span>)
  365. <a name="l00336"></a>00336 {
  366. <a name="l00337"></a>00337 <span class="keywordtype">void</span> *pdata = NULL;
  367. <a name="l00338"></a>00338 <span class="keywordtype">void</span> **ptr = (<span class="keywordtype">void</span> **)lua_touserdata(L, stack_idx);
  368. <a name="l00339"></a>00339
  369. <a name="l00340"></a>00340 <span class="keywordflow">if</span> (ptr != NULL)
  370. <a name="l00341"></a>00341 {
  371. <a name="l00342"></a>00342 pdata = *ptr; <span class="comment">// get the pointer the userdata holds</span>
  372. <a name="l00343"></a>00343 <span class="keywordflow">if</span> (null_ptr) <span class="comment">// NULL ptr so Lua won&#39;t try to gc it</span>
  373. <a name="l00344"></a>00344 *ptr = NULL;
  374. <a name="l00345"></a>00345 }
  375. <a name="l00346"></a>00346
  376. <a name="l00347"></a>00347 <span class="keywordflow">return</span> pdata;
  377. <a name="l00348"></a>00348 }
  378. <a name="l00349"></a>00349
  379. <a name="l00350"></a>00350 <span class="comment">// ----------------------------------------------------------------------------</span>
  380. <a name="l00351"></a>00351 <span class="comment">// wxluaR_XXX - functions operate on tables in Lua&#39;s LUA_REGISTRYINDEX</span>
  381. <a name="l00352"></a>00352 <span class="comment">// ----------------------------------------------------------------------------</span>
  382. <a name="l00353"></a>00353
  383. <a name="l00354"></a><a class="code" href="wxlstate_8cpp.html#a08525c218f0a90e660c0f816906da29e">00354</a> <span class="preprocessor">#define ABS_LUA_STKIDX(n, added_items) ((n) &gt; 0 ? (n) : (n)-(added_items))</span>
  384. <a name="l00355"></a>00355 <span class="preprocessor"></span>
  385. <a name="l00356"></a>00356 <span class="comment">// Note about luaL_ref() and luaL_unref().</span>
  386. <a name="l00357"></a>00357 <span class="comment">// ref creates integer numbers from 1 to ...</span>
  387. <a name="l00358"></a>00358 <span class="comment">// unref uses t[0] to hold the last unused reference and when you call unref</span>
  388. <a name="l00359"></a>00359 <span class="comment">// again the next unused ref points back to the first and t[0] points to the</span>
  389. <a name="l00360"></a>00360 <span class="comment">// last unrefed key.</span>
  390. <a name="l00361"></a>00361 <span class="comment">// eg. create 5 refs, get refs 1,2,3,4,5, then call unref on 3 then 4 then</span>
  391. <a name="l00362"></a>00362 <span class="comment">// call ref 3 times and the new references will be 4, 3, 6</span>
  392. <a name="l00363"></a>00363
  393. <a name="l00364"></a><a class="code" href="wxlstate_8cpp.html#a0879809a008c75f8b26fb9ee326efdbd">00364</a> <span class="keywordtype">int</span> <a class="code" href="wxlstate_8h.html#acbf0a32ad4b828026bd7f643557646d0">wxluaR_ref</a>(lua_State* L, <span class="keywordtype">int</span> stack_idx, <span class="keywordtype">void</span>* lightuserdata_reg_key)
  394. <a name="l00365"></a>00365 {
  395. <a name="l00366"></a>00366 <span class="comment">// nothing on stack to insert and don&#39;t bother inserting nil</span>
  396. <a name="l00367"></a>00367 <span class="keywordflow">if</span> (lua_isnoneornil(L, stack_idx))
  397. <a name="l00368"></a>00368 <span class="keywordflow">return</span> LUA_REFNIL;
  398. <a name="l00369"></a>00369
  399. <a name="l00370"></a>00370 lua_pushlightuserdata(L, lightuserdata_reg_key); <span class="comment">// push key</span>
  400. <a name="l00371"></a>00371 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  401. <a name="l00372"></a>00372
  402. <a name="l00373"></a>00373 lua_pushvalue(L, <a class="code" href="wxlstate_8cpp.html#a08525c218f0a90e660c0f816906da29e">ABS_LUA_STKIDX</a>(stack_idx,1)); <span class="comment">// push value to store</span>
  403. <a name="l00374"></a>00374
  404. <a name="l00375"></a>00375 <span class="keywordtype">int</span> ref_idx = luaL_ref(L, -2); <span class="comment">// t[ref_idx] = value; pops value</span>
  405. <a name="l00376"></a>00376
  406. <a name="l00377"></a>00377 <span class="comment">// We also store t[value] = table_idx for this table for faster lookup</span>
  407. <a name="l00378"></a>00378 <span class="keywordflow">if</span> (lightuserdata_reg_key == &amp;<a class="code" href="wxlstate_8h.html#a30c2d5556a4a278368b48fe0b7bb3fda">wxlua_lreg_debug_refs_key</a>)
  408. <a name="l00379"></a>00379 {
  409. <a name="l00380"></a>00380 lua_pushvalue(L, <a class="code" href="wxlstate_8cpp.html#a08525c218f0a90e660c0f816906da29e">ABS_LUA_STKIDX</a>(stack_idx,1)); <span class="comment">// push key</span>
  410. <a name="l00381"></a>00381 lua_pushnumber(L, ref_idx); <span class="comment">// push value</span>
  411. <a name="l00382"></a>00382 lua_rawset(L, -3); <span class="comment">// set t[key] = value; pops key and value</span>
  412. <a name="l00383"></a>00383 }
  413. <a name="l00384"></a>00384
  414. <a name="l00385"></a>00385 lua_pop(L, 1); <span class="comment">// pop table</span>
  415. <a name="l00386"></a>00386
  416. <a name="l00387"></a>00387 <span class="keywordflow">return</span> ref_idx;
  417. <a name="l00388"></a>00388 }
  418. <a name="l00389"></a>00389
  419. <a name="l00390"></a><a class="code" href="wxlstate_8cpp.html#a78110a111c2f4e0a94231d344611ce20">00390</a> <span class="keywordtype">bool</span> <a class="code" href="wxlstate_8h.html#a0578d177f35b4dd05177067425410009">wxluaR_unref</a>(lua_State* L, <span class="keywordtype">int</span> ref_idx, <span class="keywordtype">void</span>* lightuserdata_reg_key)
  420. <a name="l00391"></a>00391 {
  421. <a name="l00392"></a>00392 <span class="keywordflow">if</span> (ref_idx == LUA_REFNIL) <span class="comment">// nothing to remove</span>
  422. <a name="l00393"></a>00393 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  423. <a name="l00394"></a>00394
  424. <a name="l00395"></a>00395 lua_pushlightuserdata(L, lightuserdata_reg_key); <span class="comment">// push key</span>
  425. <a name="l00396"></a>00396 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  426. <a name="l00397"></a>00397
  427. <a name="l00398"></a>00398 <span class="comment">// Also remove the t[value] = table_idx for this table</span>
  428. <a name="l00399"></a>00399 <span class="keywordflow">if</span> (lightuserdata_reg_key == &amp;<a class="code" href="wxlstate_8h.html#a30c2d5556a4a278368b48fe0b7bb3fda">wxlua_lreg_debug_refs_key</a>)
  429. <a name="l00400"></a>00400 {
  430. <a name="l00401"></a>00401 lua_pushnumber(L, ref_idx); <span class="comment">// push key</span>
  431. <a name="l00402"></a>00402 lua_rawget(L, -2); <span class="comment">// get t[key] = value; pop key, push value;</span>
  432. <a name="l00403"></a>00403
  433. <a name="l00404"></a>00404 lua_pushnil(L);
  434. <a name="l00405"></a>00405 lua_rawset(L, -3); <span class="comment">// t[value] = nil; pops key and value</span>
  435. <a name="l00406"></a>00406 }
  436. <a name="l00407"></a>00407
  437. <a name="l00408"></a>00408 luaL_unref(L, -1, ref_idx); <span class="comment">// remove key and value in refs table</span>
  438. <a name="l00409"></a>00409 <span class="comment">// note: this key will be used for the next wxluaR_ref()</span>
  439. <a name="l00410"></a>00410
  440. <a name="l00411"></a>00411 lua_pop(L, 1); <span class="comment">// pop table</span>
  441. <a name="l00412"></a>00412
  442. <a name="l00413"></a>00413 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  443. <a name="l00414"></a>00414 }
  444. <a name="l00415"></a>00415
  445. <a name="l00416"></a><a class="code" href="wxlstate_8cpp.html#a72d9705f9b5d46e0183888f4846d8e82">00416</a> <span class="keywordtype">bool</span> LUACALL <a class="code" href="wxlstate_8h.html#ae7108b396d79179f517a7dc478c2cb43">wxluaR_getref</a>(lua_State *L, <span class="keywordtype">int</span> ref_idx, <span class="keywordtype">void</span>* lightuserdata_reg_key)
  446. <a name="l00417"></a>00417 {
  447. <a name="l00418"></a>00418 <span class="keywordflow">if</span> (ref_idx == LUA_REFNIL) <span class="comment">// nothing to get</span>
  448. <a name="l00419"></a>00419 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  449. <a name="l00420"></a>00420
  450. <a name="l00421"></a>00421 lua_pushlightuserdata(L, lightuserdata_reg_key); <span class="comment">// push key</span>
  451. <a name="l00422"></a>00422 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  452. <a name="l00423"></a>00423
  453. <a name="l00424"></a>00424 lua_rawgeti(L, -1, ref_idx); <span class="comment">// get t[ref_idx] = value; push value</span>
  454. <a name="l00425"></a>00425
  455. <a name="l00426"></a>00426 <span class="keywordflow">if</span> (lua_isnil(L, -1)) <span class="comment">// not a valid table key</span>
  456. <a name="l00427"></a>00427 {
  457. <a name="l00428"></a>00428 lua_pop(L, 2); <span class="comment">// pop nil and table</span>
  458. <a name="l00429"></a>00429 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  459. <a name="l00430"></a>00430 }
  460. <a name="l00431"></a>00431
  461. <a name="l00432"></a>00432 lua_remove(L, -2); <span class="comment">// remove table, leaving value on top</span>
  462. <a name="l00433"></a>00433
  463. <a name="l00434"></a>00434 <span class="keywordflow">return</span> <span class="keyword">true</span>; <span class="comment">// return if table has a valid value and it&#39;s on the stack</span>
  464. <a name="l00435"></a>00435 }
  465. <a name="l00436"></a>00436
  466. <a name="l00437"></a><a class="code" href="wxlstate_8cpp.html#a982adf5274da2c4c7ea0411751a0e143">00437</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlstate_8h.html#a982adf5274da2c4c7ea0411751a0e143">wxluaR_isrefed</a>(lua_State* L, <span class="keywordtype">int</span> stack_idx, <span class="keywordtype">void</span>* lightuserdata_reg_key)
  467. <a name="l00438"></a>00438 {
  468. <a name="l00439"></a>00439 <span class="keywordtype">int</span> ref_idx = LUA_NOREF;
  469. <a name="l00440"></a>00440
  470. <a name="l00441"></a>00441 lua_pushlightuserdata(L, lightuserdata_reg_key); <span class="comment">// push key</span>
  471. <a name="l00442"></a>00442 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  472. <a name="l00443"></a>00443
  473. <a name="l00444"></a>00444 <span class="keywordflow">if</span> (lightuserdata_reg_key == &amp;<a class="code" href="wxlstate_8h.html#a30c2d5556a4a278368b48fe0b7bb3fda">wxlua_lreg_debug_refs_key</a>)
  474. <a name="l00445"></a>00445 {
  475. <a name="l00446"></a>00446 <span class="comment">// For this table we&#39;ve pushed the value for a faster lookup</span>
  476. <a name="l00447"></a>00447 lua_pushvalue(L, <a class="code" href="wxlstate_8cpp.html#a08525c218f0a90e660c0f816906da29e">ABS_LUA_STKIDX</a>(stack_idx,1)); <span class="comment">// push key (the value)</span>
  477. <a name="l00448"></a>00448 lua_rawget(L, -2); <span class="comment">// get t[key] = value; pop key push value</span>
  478. <a name="l00449"></a>00449 ref_idx = (int)lua_tonumber(L, -1);
  479. <a name="l00450"></a>00450
  480. <a name="l00451"></a>00451 <span class="keywordflow">if</span> ((ref_idx == 0) &amp;&amp; !lua_isnumber(L, -1)) <span class="comment">// if !isnumber it returns 0 (faster)</span>
  481. <a name="l00452"></a>00452 ref_idx = LUA_NOREF;
  482. <a name="l00453"></a>00453
  483. <a name="l00454"></a>00454 lua_pop(L, 2); <span class="comment">// pop object we pushed and the ref table</span>
  484. <a name="l00455"></a>00455 }
  485. <a name="l00456"></a>00456 <span class="keywordflow">else</span>
  486. <a name="l00457"></a>00457 {
  487. <a name="l00458"></a>00458 <span class="comment">// otherwise search through all the values</span>
  488. <a name="l00459"></a>00459 lua_pushnil(L);
  489. <a name="l00460"></a>00460 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
  490. <a name="l00461"></a>00461 {
  491. <a name="l00462"></a>00462 <span class="comment">// value = -1, key = -2, table = -3, object = stack_idx before 3 added items</span>
  492. <a name="l00463"></a>00463 <span class="keywordflow">if</span> (lua_equal(L, -1, <a class="code" href="wxlstate_8cpp.html#a08525c218f0a90e660c0f816906da29e">ABS_LUA_STKIDX</a>(stack_idx,3)))
  493. <a name="l00464"></a>00464 {
  494. <a name="l00465"></a>00465 ref_idx = (int)lua_tonumber(L, -2);
  495. <a name="l00466"></a>00466 lua_pop(L, 2); <span class="comment">// pop key, value</span>
  496. <a name="l00467"></a>00467 <span class="keywordflow">break</span>;
  497. <a name="l00468"></a>00468 }
  498. <a name="l00469"></a>00469 <span class="keywordflow">else</span>
  499. <a name="l00470"></a>00470 lua_pop(L, 1); <span class="comment">// pop value, lua_next will pop key at end</span>
  500. <a name="l00471"></a>00471 }
  501. <a name="l00472"></a>00472
  502. <a name="l00473"></a>00473 lua_pop(L, 1); <span class="comment">// pop ref table</span>
  503. <a name="l00474"></a>00474 }
  504. <a name="l00475"></a>00475
  505. <a name="l00476"></a>00476 <span class="keywordflow">return</span> ref_idx;
  506. <a name="l00477"></a>00477 }
  507. <a name="l00478"></a>00478
  508. <a name="l00479"></a>00479 <span class="comment">// ----------------------------------------------------------------------------</span>
  509. <a name="l00480"></a>00480 <span class="comment">// wxluaO_XXX - functions operate on the &quot;Objects&quot;</span>
  510. <a name="l00481"></a>00481 <span class="comment">// ----------------------------------------------------------------------------</span>
  511. <a name="l00482"></a>00482
  512. <a name="l00483"></a><a class="code" href="wxlstate_8cpp.html#a0f23c00339db80dbf392740133c531aa">00483</a> <span class="keywordtype">void</span> LUACALL <a class="code" href="wxlstate_8h.html#a0f23c00339db80dbf392740133c531aa">wxluaO_addgcobject</a>(lua_State *L, wxObject* wxobj)
  513. <a name="l00484"></a>00484 {
  514. <a name="l00485"></a>00485 <a class="code" href="wxlstate_8h.html#a0f23c00339db80dbf392740133c531aa">wxluaO_addgcobject</a>(L, (<span class="keywordtype">void</span>*)wxobj, wxobj);
  515. <a name="l00486"></a>00486 }
  516. <a name="l00487"></a><a class="code" href="wxlstate_8cpp.html#aaa101a23bc11989af633e43595bcec0b">00487</a> <span class="keywordtype">void</span> LUACALL <a class="code" href="wxlstate_8h.html#a0f23c00339db80dbf392740133c531aa">wxluaO_addgcobject</a>(lua_State *L, <span class="keywordtype">void</span> *obj_ptr, wxObject* wxobj)
  517. <a name="l00488"></a>00488 {
  518. <a name="l00489"></a>00489 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a7ec5afec8a64a29e28fefec4a1105790">wxlua_lreg_gcobjects_key</a>); <span class="comment">// push key</span>
  519. <a name="l00490"></a>00490 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  520. <a name="l00491"></a>00491
  521. <a name="l00492"></a>00492 <span class="comment">// Check if it&#39;s already tracked since that means the weak udata table isn&#39;t working right</span>
  522. <a name="l00493"></a>00493 lua_pushlightuserdata(L, obj_ptr); <span class="comment">// push key</span>
  523. <a name="l00494"></a>00494 lua_rawget(L, -2); <span class="comment">// get t[key] = value, pops key</span>
  524. <a name="l00495"></a>00495 <span class="keywordflow">if</span> (!lua_isnil(L, -1))
  525. <a name="l00496"></a>00496 {
  526. <a name="l00497"></a>00497 lua_pop(L, 2); <span class="comment">// pop table and value</span>
  527. <a name="l00498"></a>00498 wxFAIL_MSG(wxT(<span class="stringliteral">&quot;Tracking an object twice in wxluaO_addgcobject: &quot;</span>) + wxString(wxobj-&gt;GetClassInfo()-&gt;GetClassName()));
  528. <a name="l00499"></a>00499 <span class="keywordflow">return</span>;
  529. <a name="l00500"></a>00500 }
  530. <a name="l00501"></a>00501 lua_pop(L, 1); <span class="comment">// pop nil</span>
  531. <a name="l00502"></a>00502
  532. <a name="l00503"></a>00503 <span class="comment">// Then add it</span>
  533. <a name="l00504"></a>00504 lua_pushlightuserdata(L, obj_ptr); <span class="comment">// push key</span>
  534. <a name="l00505"></a>00505 lua_pushlightuserdata(L, wxobj); <span class="comment">// push value</span>
  535. <a name="l00506"></a>00506 lua_rawset(L, -3); <span class="comment">// set t[key] = value, pops key and value</span>
  536. <a name="l00507"></a>00507
  537. <a name="l00508"></a>00508 lua_pop(L, 1); <span class="comment">// pop table</span>
  538. <a name="l00509"></a>00509 }
  539. <a name="l00510"></a>00510
  540. <a name="l00511"></a><a class="code" href="wxlstate_8cpp.html#aba83aa14c215deca6e72da965f29c4a4">00511</a> <span class="keywordtype">bool</span> LUACALL <a class="code" href="wxlstate_8h.html#aba83aa14c215deca6e72da965f29c4a4">wxluaO_deletegcobject</a>(lua_State *L, <span class="keywordtype">void</span>* udata, <span class="keywordtype">void</span> *obj_ptr, <span class="keywordtype">int</span> flags)
  541. <a name="l00512"></a>00512 {
  542. <a name="l00513"></a>00513 <span class="keywordflow">if</span> (obj_ptr == NULL) <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// can happen</span>
  543. <a name="l00514"></a>00514
  544. <a name="l00515"></a>00515 <span class="keywordtype">bool</span> delete_all = <a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(flags, <a class="code" href="wxlstate_8h.html#a29f0120153918cc4e7b7b91913b0bef1ade247b3e5ef9e545a9512ebaefa1bab8">WXLUA_DELETE_OBJECT_ALL</a>);
  545. <a name="l00516"></a>00516
  546. <a name="l00517"></a>00517 <span class="comment">// Remove the weak ref to it</span>
  547. <a name="l00518"></a>00518 <span class="keywordtype">int</span> udata_count = <a class="code" href="wxlstate_8h.html#a76fa03ffe7ba99804c524d86e17260db">wxluaO_untrackweakobject</a>(L, delete_all ? NULL : udata, obj_ptr);
  548. <a name="l00519"></a>00519
  549. <a name="l00520"></a>00520 <span class="keywordflow">if</span> (delete_all || (udata_count &lt; 1))
  550. <a name="l00521"></a>00521 {
  551. <a name="l00522"></a>00522 <a class="code" href="wxlstate_8h.html#abfb64621a5e2ba46114e81a28731c79f">wxlua_removederivedmethods</a>(L, obj_ptr);
  552. <a name="l00523"></a>00523
  553. <a name="l00524"></a>00524 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a7ec5afec8a64a29e28fefec4a1105790">wxlua_lreg_gcobjects_key</a>); <span class="comment">// push key</span>
  554. <a name="l00525"></a>00525 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  555. <a name="l00526"></a>00526
  556. <a name="l00527"></a>00527 lua_pushlightuserdata(L, obj_ptr); <span class="comment">// push key</span>
  557. <a name="l00528"></a>00528 lua_rawget(L, -2); <span class="comment">// get t[key] = value, pops key</span>
  558. <a name="l00529"></a>00529
  559. <a name="l00530"></a>00530 <span class="keywordflow">if</span> (lua_islightuserdata(L, -1)) <span class="comment">// is the wxObject* we delete</span>
  560. <a name="l00531"></a>00531 {
  561. <a name="l00532"></a>00532 <span class="comment">// delete the real object for the case where it&#39;s encapsulated</span>
  562. <a name="l00533"></a>00533 wxObject *wxobj = (wxObject*)lua_touserdata(L, -1);
  563. <a name="l00534"></a>00534 <span class="keyword">delete</span> wxobj;
  564. <a name="l00535"></a>00535
  565. <a name="l00536"></a>00536 lua_pop(L, 1); <span class="comment">// pop lightuserdata value</span>
  566. <a name="l00537"></a>00537
  567. <a name="l00538"></a>00538 lua_pushlightuserdata(L, obj_ptr); <span class="comment">// push key</span>
  568. <a name="l00539"></a>00539 lua_pushnil(L); <span class="comment">// push value</span>
  569. <a name="l00540"></a>00540 lua_rawset(L, -3); <span class="comment">// set t[key] = value, pops key and value</span>
  570. <a name="l00541"></a>00541
  571. <a name="l00542"></a>00542 lua_pop(L, 1); <span class="comment">// pop delobj table</span>
  572. <a name="l00543"></a>00543
  573. <a name="l00544"></a>00544 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  574. <a name="l00545"></a>00545 }
  575. <a name="l00546"></a>00546 <span class="keywordflow">else</span>
  576. <a name="l00547"></a>00547 {
  577. <a name="l00548"></a>00548 <span class="comment">// no error message since we&#39;re called from wxlua_wxLuaBindClass__gc</span>
  578. <a name="l00549"></a>00549 <span class="comment">// automatically for all our objects and this table stores which ones to delete</span>
  579. <a name="l00550"></a>00550 <span class="comment">// so we don&#39;t want to have to check first and then call this.</span>
  580. <a name="l00551"></a>00551 lua_pop(L, 2); <span class="comment">// pop nil and delobj</span>
  581. <a name="l00552"></a>00552 }
  582. <a name="l00553"></a>00553 }
  583. <a name="l00554"></a>00554
  584. <a name="l00555"></a>00555 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  585. <a name="l00556"></a>00556 }
  586. <a name="l00557"></a>00557
  587. <a name="l00558"></a><a class="code" href="wxlstate_8cpp.html#afaaa576936abb264f61d78633b74f528">00558</a> <span class="keywordtype">bool</span> LUACALL <a class="code" href="wxlstate_8h.html#afaaa576936abb264f61d78633b74f528">wxluaO_undeletegcobject</a>(lua_State *L, <span class="keywordtype">void</span> *obj_ptr)
  588. <a name="l00559"></a>00559 {
  589. <a name="l00560"></a>00560 <span class="keywordflow">if</span> (obj_ptr == NULL) <span class="keywordflow">return</span> <span class="keyword">false</span>;
  590. <a name="l00561"></a>00561
  591. <a name="l00562"></a>00562 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a7ec5afec8a64a29e28fefec4a1105790">wxlua_lreg_gcobjects_key</a>); <span class="comment">// push key</span>
  592. <a name="l00563"></a>00563 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  593. <a name="l00564"></a>00564
  594. <a name="l00565"></a>00565 lua_pushlightuserdata(L, obj_ptr); <span class="comment">// push key</span>
  595. <a name="l00566"></a>00566 lua_rawget(L, -2); <span class="comment">// get t[key] = value, pops key</span>
  596. <a name="l00567"></a>00567
  597. <a name="l00568"></a>00568 <span class="keywordflow">if</span> (lua_islightuserdata(L, -1)) <span class="comment">// is the wxObject* we delete</span>
  598. <a name="l00569"></a>00569 {
  599. <a name="l00570"></a>00570 lua_pop(L, 1); <span class="comment">// pop lightuserdata</span>
  600. <a name="l00571"></a>00571
  601. <a name="l00572"></a>00572 lua_pushlightuserdata(L, obj_ptr); <span class="comment">// push key</span>
  602. <a name="l00573"></a>00573 lua_pushnil(L); <span class="comment">// push value</span>
  603. <a name="l00574"></a>00574 lua_rawset(L, -3); <span class="comment">// set t[key] = value, pops key and value</span>
  604. <a name="l00575"></a>00575
  605. <a name="l00576"></a>00576 lua_pop(L, 1); <span class="comment">// pop delobj table</span>
  606. <a name="l00577"></a>00577 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  607. <a name="l00578"></a>00578 }
  608. <a name="l00579"></a>00579 <span class="keywordflow">else</span>
  609. <a name="l00580"></a>00580 lua_pop(L, 2); <span class="comment">// pop nil and gcobject table</span>
  610. <a name="l00581"></a>00581
  611. <a name="l00582"></a>00582 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  612. <a name="l00583"></a>00583 }
  613. <a name="l00584"></a>00584
  614. <a name="l00585"></a><a class="code" href="wxlstate_8cpp.html#a10a0351ed2d2abe300bf0e5db307cdd0">00585</a> <span class="keywordtype">bool</span> LUACALL <a class="code" href="wxlstate_8h.html#a10a0351ed2d2abe300bf0e5db307cdd0">wxluaO_isgcobject</a>(lua_State *L, <span class="keywordtype">void</span> *obj_ptr)
  615. <a name="l00586"></a>00586 {
  616. <a name="l00587"></a>00587 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a7ec5afec8a64a29e28fefec4a1105790">wxlua_lreg_gcobjects_key</a>); <span class="comment">// push key</span>
  617. <a name="l00588"></a>00588 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  618. <a name="l00589"></a>00589
  619. <a name="l00590"></a>00590 lua_pushlightuserdata(L, obj_ptr); <span class="comment">// push key</span>
  620. <a name="l00591"></a>00591 lua_rawget(L, -2); <span class="comment">// get t[key] = value, pops key</span>
  621. <a name="l00592"></a>00592
  622. <a name="l00593"></a>00593 <span class="keywordtype">bool</span> found = lua_islightuserdata(L, -1);
  623. <a name="l00594"></a>00594 lua_pop(L, 2); <span class="comment">// pop udata and table</span>
  624. <a name="l00595"></a>00595
  625. <a name="l00596"></a>00596 <span class="keywordflow">return</span> found;
  626. <a name="l00597"></a>00597 }
  627. <a name="l00598"></a>00598
  628. <a name="l00599"></a><a class="code" href="wxlstate_8cpp.html#a1731f8112f747955ec5f3c15232429ba">00599</a> wxArrayString LUACALL <a class="code" href="wxlstate_8h.html#a1731f8112f747955ec5f3c15232429ba">wxluaO_getgcobjectinfo</a>(lua_State *L)
  629. <a name="l00600"></a>00600 {
  630. <a name="l00601"></a>00601 wxArrayString arrStr;
  631. <a name="l00602"></a>00602
  632. <a name="l00603"></a>00603 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a7ec5afec8a64a29e28fefec4a1105790">wxlua_lreg_gcobjects_key</a>); <span class="comment">// push key</span>
  633. <a name="l00604"></a>00604 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  634. <a name="l00605"></a>00605
  635. <a name="l00606"></a>00606 lua_pushnil(L);
  636. <a name="l00607"></a>00607 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
  637. <a name="l00608"></a>00608 {
  638. <a name="l00609"></a>00609 <span class="comment">// value = -1, key = -2, table = -3</span>
  639. <a name="l00610"></a>00610 wxString name(wxT(<span class="stringliteral">&quot;wxObject?&quot;</span>));
  640. <a name="l00611"></a>00611
  641. <a name="l00612"></a>00612 wxObject* obj = (wxObject*)lua_touserdata(L, -1);
  642. <a name="l00613"></a>00613 <span class="keywordflow">if</span> (obj &amp;&amp; obj-&gt;GetClassInfo() &amp;&amp; obj-&gt;GetClassInfo()-&gt;GetClassName())
  643. <a name="l00614"></a>00614 name = obj-&gt;GetClassInfo()-&gt;GetClassName();
  644. <a name="l00615"></a>00615
  645. <a name="l00616"></a>00616 arrStr.Add(wxString::Format(wxT(<span class="stringliteral">&quot;%s(%p)&quot;</span>), name.c_str(), obj));
  646. <a name="l00617"></a>00617
  647. <a name="l00618"></a>00618 lua_pop(L, 1); <span class="comment">// pop value, lua_next will pop key at end</span>
  648. <a name="l00619"></a>00619 }
  649. <a name="l00620"></a>00620
  650. <a name="l00621"></a>00621 lua_pop(L, 1); <span class="comment">// pop table</span>
  651. <a name="l00622"></a>00622
  652. <a name="l00623"></a>00623 arrStr.Sort();
  653. <a name="l00624"></a>00624 <span class="keywordflow">return</span> arrStr;
  654. <a name="l00625"></a>00625 }
  655. <a name="l00626"></a>00626
  656. <a name="l00627"></a><a class="code" href="wxlstate_8cpp.html#a877ac3a3e719283fbf39f4887daeb928">00627</a> <span class="keywordtype">void</span> LUACALL <a class="code" href="wxlstate_8h.html#a877ac3a3e719283fbf39f4887daeb928">wxluaO_trackweakobject</a>(lua_State *L, <span class="keywordtype">int</span> udata_stack_idx, <span class="keywordtype">void</span> *obj_ptr, <span class="keywordtype">int</span> wxl_type)
  657. <a name="l00628"></a>00628 {
  658. <a name="l00629"></a>00629 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#af255531a04d81a0d82556c0d1fe8e7e7">wxlua_lreg_weakobjects_key</a>); <span class="comment">// push key</span>
  659. <a name="l00630"></a>00630 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (the obj table)</span>
  660. <a name="l00631"></a>00631
  661. <a name="l00632"></a>00632 lua_pushlightuserdata(L, obj_ptr); <span class="comment">// push key</span>
  662. <a name="l00633"></a>00633 lua_rawget(L, -2);
  663. <a name="l00634"></a>00634
  664. <a name="l00635"></a>00635 <span class="keywordflow">if</span> (lua_isnil(L, -1)) <span class="comment">// not tracked yet, create new table to store items</span>
  665. <a name="l00636"></a>00636 {
  666. <a name="l00637"></a>00637 lua_pop(L, 1); <span class="comment">// pop nil</span>
  667. <a name="l00638"></a>00638
  668. <a name="l00639"></a>00639 lua_pushlightuserdata(L, obj_ptr);
  669. <a name="l00640"></a>00640 lua_newtable(L);
  670. <a name="l00641"></a>00641 lua_newtable(L); <span class="comment">// metatable</span>
  671. <a name="l00642"></a>00642 lua_pushlstring(L, <span class="stringliteral">&quot;__mode&quot;</span>, 6);
  672. <a name="l00643"></a>00643 lua_pushlstring(L, <span class="stringliteral">&quot;v&quot;</span>, 1);
  673. <a name="l00644"></a>00644 lua_rawset(L, -3); <span class="comment">// set mode of main table</span>
  674. <a name="l00645"></a>00645 lua_setmetatable(L, -2); <span class="comment">// via the metatable</span>
  675. <a name="l00646"></a>00646 lua_rawset(L, -3);
  676. <a name="l00647"></a>00647
  677. <a name="l00648"></a>00648 lua_pushlightuserdata(L, obj_ptr); <span class="comment">// get the table back</span>
  678. <a name="l00649"></a>00649 lua_rawget(L, -2);
  679. <a name="l00650"></a>00650 }
  680. <a name="l00651"></a>00651 <span class="keywordflow">else</span>
  681. <a name="l00652"></a>00652 {
  682. <a name="l00653"></a>00653 <span class="comment">// check for dupes since that&#39;s what we&#39;re trying to avoid</span>
  683. <a name="l00654"></a>00654 lua_pushnumber(L, wxl_type);
  684. <a name="l00655"></a>00655 lua_rawget(L, -2);
  685. <a name="l00656"></a>00656 <span class="comment">// this must never happen</span>
  686. <a name="l00657"></a>00657 <span class="keywordflow">if</span> (!lua_isnil(L, -1)) wxFAIL_MSG(wxT(<span class="stringliteral">&quot;Trying to push userdata for object with same wxLua type twice&quot;</span>));
  687. <a name="l00658"></a>00658 lua_pop(L, 1); <span class="comment">// pop nil</span>
  688. <a name="l00659"></a>00659 }
  689. <a name="l00660"></a>00660
  690. <a name="l00661"></a>00661 lua_pushnumber(L, wxl_type);
  691. <a name="l00662"></a>00662 lua_pushvalue(L, <a class="code" href="wxlstate_8cpp.html#a08525c218f0a90e660c0f816906da29e">ABS_LUA_STKIDX</a>(udata_stack_idx, 3)); <span class="comment">// push the Lua userdata as the value (note: weak valued table)</span>
  692. <a name="l00663"></a>00663 lua_rawset(L, -3); <span class="comment">// t[key] = value; pops key and value</span>
  693. <a name="l00664"></a>00664 lua_pop(L, 2); <span class="comment">// pop weakobj table and obj_ptr table</span>
  694. <a name="l00665"></a>00665 }
  695. <a name="l00666"></a>00666
  696. <a name="l00667"></a><a class="code" href="wxlstate_8cpp.html#a76fa03ffe7ba99804c524d86e17260db">00667</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlstate_8h.html#a76fa03ffe7ba99804c524d86e17260db">wxluaO_untrackweakobject</a>(lua_State *L, <span class="keywordtype">void</span>* udata, <span class="keywordtype">void</span> *obj_ptr)
  697. <a name="l00668"></a>00668 {
  698. <a name="l00669"></a>00669 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#af255531a04d81a0d82556c0d1fe8e7e7">wxlua_lreg_weakobjects_key</a>); <span class="comment">// push key</span>
  699. <a name="l00670"></a>00670 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (the object table)</span>
  700. <a name="l00671"></a>00671
  701. <a name="l00672"></a>00672 lua_pushlightuserdata(L, (<span class="keywordtype">void</span>*)obj_ptr); <span class="comment">// push key</span>
  702. <a name="l00673"></a>00673 lua_rawget(L, -2); <span class="comment">// get t[key] = value; pop key push value</span>
  703. <a name="l00674"></a>00674
  704. <a name="l00675"></a>00675 <span class="keywordtype">int</span> count = 0;
  705. <a name="l00676"></a>00676
  706. <a name="l00677"></a>00677 <span class="keywordflow">if</span> (lua_istable(L, -1))
  707. <a name="l00678"></a>00678 {
  708. <a name="l00679"></a>00679 <span class="comment">// clear the metatables for the userdata</span>
  709. <a name="l00680"></a>00680 lua_pushnil(L);
  710. <a name="l00681"></a>00681 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
  711. <a name="l00682"></a>00682 {
  712. <a name="l00683"></a>00683 <span class="comment">// value = -1, key = -2, table = -3</span>
  713. <a name="l00684"></a>00684 <span class="keywordtype">void</span> *u = lua_touserdata(L, -1);
  714. <a name="l00685"></a>00685
  715. <a name="l00686"></a>00686 <span class="keywordflow">if</span> ((udata == NULL) || (udata == u))
  716. <a name="l00687"></a>00687 {
  717. <a name="l00688"></a>00688 lua_pushnil(L);
  718. <a name="l00689"></a>00689 lua_setmetatable(L, -2); <span class="comment">// remove value&#39;s metatable</span>
  719. <a name="l00690"></a>00690 }
  720. <a name="l00691"></a>00691
  721. <a name="l00692"></a>00692 <span class="keywordflow">if</span> (udata == u)
  722. <a name="l00693"></a>00693 {
  723. <a name="l00694"></a>00694 lua_pop(L, 1); <span class="comment">// pop value</span>
  724. <a name="l00695"></a>00695
  725. <a name="l00696"></a>00696 lua_pushvalue(L, -1); <span class="comment">// copy key for next iteration</span>
  726. <a name="l00697"></a>00697 lua_pushnil(L);
  727. <a name="l00698"></a>00698 lua_rawset(L, -4); <span class="comment">// set t[key] = nil to remove it</span>
  728. <a name="l00699"></a>00699 }
  729. <a name="l00700"></a>00700 <span class="keywordflow">else</span>
  730. <a name="l00701"></a>00701 {
  731. <a name="l00702"></a>00702 ++count; <span class="comment">// only count ones that still exist</span>
  732. <a name="l00703"></a>00703 lua_pop(L, 1); <span class="comment">// pop value, leave key for next iteration</span>
  733. <a name="l00704"></a>00704 }
  734. <a name="l00705"></a>00705 }
  735. <a name="l00706"></a>00706
  736. <a name="l00707"></a>00707 lua_pop(L, 1); <span class="comment">// pop obj_ptr table</span>
  737. <a name="l00708"></a>00708
  738. <a name="l00709"></a>00709 <span class="comment">// If we&#39;ve cleared everything then remove the table</span>
  739. <a name="l00710"></a>00710 <span class="keywordflow">if</span> ((udata == NULL) || (count == 0))
  740. <a name="l00711"></a>00711 {
  741. <a name="l00712"></a>00712 count = 0; <span class="comment">// removed them all</span>
  742. <a name="l00713"></a>00713 lua_pushlightuserdata(L, (<span class="keywordtype">void</span>*)obj_ptr); <span class="comment">// push key</span>
  743. <a name="l00714"></a>00714 lua_pushnil(L); <span class="comment">// push value</span>
  744. <a name="l00715"></a>00715 lua_rawset(L, -3); <span class="comment">// set t[key] = nil; pops key and value</span>
  745. <a name="l00716"></a>00716 }
  746. <a name="l00717"></a>00717
  747. <a name="l00718"></a>00718 lua_pop(L, 1); <span class="comment">// pop objects table</span>
  748. <a name="l00719"></a>00719 }
  749. <a name="l00720"></a>00720 <span class="keywordflow">else</span>
  750. <a name="l00721"></a>00721 lua_pop(L, 2); <span class="comment">// pop nil and weakobj table</span>
  751. <a name="l00722"></a>00722
  752. <a name="l00723"></a>00723 <span class="keywordflow">return</span> count;
  753. <a name="l00724"></a>00724 }
  754. <a name="l00725"></a>00725
  755. <a name="l00726"></a><a class="code" href="wxlstate_8cpp.html#a1c0abab7b240281334eea23ce5cd5b94">00726</a> <span class="keywordtype">bool</span> LUACALL <a class="code" href="wxlstate_8h.html#a1c0abab7b240281334eea23ce5cd5b94">wxluaO_istrackedweakobject</a>(lua_State *L, <span class="keywordtype">void</span> *obj_ptr, <span class="keywordtype">int</span> wxl_type, <span class="keywordtype">bool</span> push_on_stack)
  756. <a name="l00727"></a>00727 {
  757. <a name="l00728"></a>00728 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#af255531a04d81a0d82556c0d1fe8e7e7">wxlua_lreg_weakobjects_key</a>); <span class="comment">// push key</span>
  758. <a name="l00729"></a>00729 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (the obj table)</span>
  759. <a name="l00730"></a>00730
  760. <a name="l00731"></a>00731 lua_pushlightuserdata(L, obj_ptr); <span class="comment">// push key</span>
  761. <a name="l00732"></a>00732 lua_rawget(L, -2); <span class="comment">// get t[key] value; pop key push value</span>
  762. <a name="l00733"></a>00733
  763. <a name="l00734"></a>00734 <span class="keywordflow">if</span> (lua_istable(L, -1))
  764. <a name="l00735"></a>00735 {
  765. <a name="l00736"></a>00736 lua_pushnumber(L, wxl_type); <span class="comment">// push key</span>
  766. <a name="l00737"></a>00737 lua_rawget(L, -2); <span class="comment">// get t[key] = value; pops key</span>
  767. <a name="l00738"></a>00738
  768. <a name="l00739"></a>00739 <span class="comment">// check if they&#39;ve dynamic casted the object or if it was casted in C++</span>
  769. <a name="l00740"></a>00740 <span class="keywordflow">if</span> (wxl_type == <a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(L, -1))
  770. <a name="l00741"></a>00741 {
  771. <a name="l00742"></a>00742 <span class="keywordflow">if</span> (push_on_stack)
  772. <a name="l00743"></a>00743 {
  773. <a name="l00744"></a>00744 lua_remove(L, -3); <span class="comment">// remove the obj table, leave value on the stack</span>
  774. <a name="l00745"></a>00745 lua_remove(L, -2); <span class="comment">// remove table of userdata, leave value on the stack</span>
  775. <a name="l00746"></a>00746 }
  776. <a name="l00747"></a>00747 <span class="keywordflow">else</span>
  777. <a name="l00748"></a>00748 lua_pop(L, 3);
  778. <a name="l00749"></a>00749
  779. <a name="l00750"></a>00750 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  780. <a name="l00751"></a>00751 }
  781. <a name="l00752"></a>00752 <span class="keywordflow">else</span>
  782. <a name="l00753"></a>00753 lua_pop(L, 1); <span class="comment">// pop the userdata that is not the right type</span>
  783. <a name="l00754"></a>00754 }
  784. <a name="l00755"></a>00755
  785. <a name="l00756"></a>00756 lua_pop(L, 2); <span class="comment">// pop the weakobj table and the nil.</span>
  786. <a name="l00757"></a>00757 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  787. <a name="l00758"></a>00758 }
  788. <a name="l00759"></a>00759
  789. <a name="l00760"></a><a class="code" href="wxlstate_8cpp.html#ad0f4e44fbd25af4537a7fe708f6736b1">00760</a> wxArrayString LUACALL <a class="code" href="wxlstate_8h.html#ad0f4e44fbd25af4537a7fe708f6736b1">wxluaO_gettrackedweakobjectinfo</a>(lua_State *L)
  790. <a name="l00761"></a>00761 {
  791. <a name="l00762"></a>00762 wxArrayString arrStr;
  792. <a name="l00763"></a>00763
  793. <a name="l00764"></a>00764 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#af255531a04d81a0d82556c0d1fe8e7e7">wxlua_lreg_weakobjects_key</a>); <span class="comment">// push key</span>
  794. <a name="l00765"></a>00765 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  795. <a name="l00766"></a>00766
  796. <a name="l00767"></a>00767 lua_pushnil(L);
  797. <a name="l00768"></a>00768 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
  798. <a name="l00769"></a>00769 {
  799. <a name="l00770"></a>00770 <span class="comment">// value = -1, key = -2, table = -3</span>
  800. <a name="l00771"></a>00771 <span class="keywordtype">void</span>* obj_ptr = lua_touserdata(L, -2); <span class="comment">// actually lightuserdata</span>
  801. <a name="l00772"></a>00772
  802. <a name="l00773"></a>00773 wxString name;
  803. <a name="l00774"></a>00774
  804. <a name="l00775"></a>00775 <span class="comment">// iterate the table of userdata</span>
  805. <a name="l00776"></a>00776 lua_pushnil(L);
  806. <a name="l00777"></a>00777 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
  807. <a name="l00778"></a>00778 {
  808. <a name="l00779"></a>00779 <span class="comment">// value = -1, key = -2, table = -3</span>
  809. <a name="l00780"></a>00780 <span class="keywordtype">int</span> wxl_type = (int)lua_tonumber(L, -2);
  810. <a name="l00781"></a>00781 <span class="keywordflow">if</span> (!name.IsEmpty()) name += wxT(<span class="stringliteral">&quot;, &quot;</span>);
  811. <a name="l00782"></a>00782 name += wxString::Format(wxT(<span class="stringliteral">&quot;%s(%p, type=%d)&quot;</span>), <a class="code" href="wxlstate_8h.html#a6621fa5a456448acfd515112aa7b23e1">wxluaT_typename</a>(L, wxl_type).c_str(), lua_touserdata(L, -1), wxl_type);
  812. <a name="l00783"></a>00783 lua_pop(L, 1); <span class="comment">// pop value, lua_next will pop key at end</span>
  813. <a name="l00784"></a>00784 }
  814. <a name="l00785"></a>00785
  815. <a name="l00786"></a>00786 arrStr.Add(wxString::Format(wxT(<span class="stringliteral">&quot;%p = %s&quot;</span>), obj_ptr, name.c_str()));
  816. <a name="l00787"></a>00787
  817. <a name="l00788"></a>00788 lua_pop(L, 1); <span class="comment">// pop value, lua_next will pop key at end</span>
  818. <a name="l00789"></a>00789 }
  819. <a name="l00790"></a>00790
  820. <a name="l00791"></a>00791 lua_pop(L, 1); <span class="comment">// pop table</span>
  821. <a name="l00792"></a>00792
  822. <a name="l00793"></a>00793 arrStr.Sort();
  823. <a name="l00794"></a>00794 <span class="keywordflow">return</span> arrStr;
  824. <a name="l00795"></a>00795 }
  825. <a name="l00796"></a>00796
  826. <a name="l00797"></a>00797 <span class="comment">// ----------------------------------------------------------------------------</span>
  827. <a name="l00798"></a>00798 <span class="comment">// wxluaW_XXX - functions operate on tracked wxWindows</span>
  828. <a name="l00799"></a>00799 <span class="comment">// ----------------------------------------------------------------------------</span>
  829. <a name="l00800"></a>00800
  830. <a name="l00801"></a><a class="code" href="wxlstate_8cpp.html#a6acba6e5567b9a9c3d3e90f6fdb42456">00801</a> <span class="keywordtype">void</span> LUACALL <a class="code" href="wxlstate_8h.html#a6acba6e5567b9a9c3d3e90f6fdb42456">wxluaW_addtrackedwindow</a>(lua_State *L, wxObject* wxobj)
  831. <a name="l00802"></a>00802 {
  832. <a name="l00803"></a>00803 <span class="keywordflow">if</span> (!wxobj) <span class="keywordflow">return</span>; <span class="comment">// allow NULL w/o error</span>
  833. <a name="l00804"></a>00804
  834. <a name="l00805"></a>00805 <span class="comment">// don&#39;t track these &quot;windows&quot; since they&#39;re supposed to be attached</span>
  835. <a name="l00806"></a>00806 <span class="comment">// and their parents are not properly set so we can&#39;t tell if</span>
  836. <a name="l00807"></a>00807 <span class="comment">// their parents are tracked.</span>
  837. <a name="l00808"></a>00808 <span class="keywordflow">if</span> (wxDynamicCast(wxobj, wxMenuBar) != NULL) <span class="keywordflow">return</span>;
  838. <a name="l00809"></a>00809 <span class="keywordflow">if</span> (wxDynamicCast(wxobj, wxToolBar) != NULL) <span class="keywordflow">return</span>;
  839. <a name="l00810"></a>00810
  840. <a name="l00811"></a>00811 wxWindow* win = wxDynamicCast(wxobj, wxWindow);
  841. <a name="l00812"></a>00812
  842. <a name="l00813"></a>00813 <span class="comment">// only need to track parent window, it deletes children for us</span>
  843. <a name="l00814"></a>00814 <span class="keywordflow">if</span> (win &amp;&amp; !<a class="code" href="wxlstate_8h.html#a1ea46fab0293690fb38fb3cee9ffccd0">wxluaW_istrackedwindow</a>(L, win, <span class="keyword">true</span>))
  844. <a name="l00815"></a>00815 {
  845. <a name="l00816"></a>00816 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#aab2351a78a8949184e1910cc1f9e7463">wxlua_lreg_topwindows_key</a>); <span class="comment">// push key</span>
  846. <a name="l00817"></a>00817 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  847. <a name="l00818"></a>00818
  848. <a name="l00819"></a>00819 lua_pushlightuserdata(L, win); <span class="comment">// push key</span>
  849. <a name="l00820"></a>00820 lua_pushnumber(L, 1); <span class="comment">// push value</span>
  850. <a name="l00821"></a>00821 lua_rawset(L, -3); <span class="comment">// set t[key] = value, pops key and value</span>
  851. <a name="l00822"></a>00822
  852. <a name="l00823"></a>00823 lua_pop(L, 1); <span class="comment">// pop topwindows table</span>
  853. <a name="l00824"></a>00824 }
  854. <a name="l00825"></a>00825 }
  855. <a name="l00826"></a>00826
  856. <a name="l00827"></a><a class="code" href="wxlstate_8cpp.html#af1bf3244574d51336b5efb38479c103f">00827</a> <span class="keywordtype">void</span> LUACALL <a class="code" href="wxlstate_8h.html#af1bf3244574d51336b5efb38479c103f">wxluaW_removetrackedwindow</a>(lua_State *L, wxWindow* win)
  857. <a name="l00828"></a>00828 {
  858. <a name="l00829"></a>00829 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#aab2351a78a8949184e1910cc1f9e7463">wxlua_lreg_topwindows_key</a>); <span class="comment">// push key</span>
  859. <a name="l00830"></a>00830 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  860. <a name="l00831"></a>00831
  861. <a name="l00832"></a>00832 lua_pushlightuserdata(L, win); <span class="comment">// push key</span>
  862. <a name="l00833"></a>00833 lua_pushnil(L); <span class="comment">// push value</span>
  863. <a name="l00834"></a>00834 lua_rawset(L, -3); <span class="comment">// set t[key] = value, pops key and value</span>
  864. <a name="l00835"></a>00835
  865. <a name="l00836"></a>00836 lua_pop(L, 1); <span class="comment">// pop topwindows table</span>
  866. <a name="l00837"></a>00837 }
  867. <a name="l00838"></a>00838
  868. <a name="l00839"></a><a class="code" href="wxlstate_8cpp.html#a1ea46fab0293690fb38fb3cee9ffccd0">00839</a> <span class="keywordtype">bool</span> LUACALL <a class="code" href="wxlstate_8h.html#a1ea46fab0293690fb38fb3cee9ffccd0">wxluaW_istrackedwindow</a>(lua_State *L, wxWindow* win, <span class="keywordtype">bool</span> check_parents)
  869. <a name="l00840"></a>00840 {
  870. <a name="l00841"></a>00841 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#aab2351a78a8949184e1910cc1f9e7463">wxlua_lreg_topwindows_key</a>); <span class="comment">// push key</span>
  871. <a name="l00842"></a>00842 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  872. <a name="l00843"></a>00843
  873. <a name="l00844"></a>00844 wxWindow* parent = win;
  874. <a name="l00845"></a>00845
  875. <a name="l00846"></a>00846 <span class="keywordflow">while</span> (parent)
  876. <a name="l00847"></a>00847 {
  877. <a name="l00848"></a>00848 lua_pushlightuserdata(L, parent); <span class="comment">// push key</span>
  878. <a name="l00849"></a>00849 lua_rawget(L, -2); <span class="comment">// pop key, push value</span>
  879. <a name="l00850"></a>00850
  880. <a name="l00851"></a>00851 <span class="keywordflow">if</span> (lua_isnumber(L, -1))
  881. <a name="l00852"></a>00852 {
  882. <a name="l00853"></a>00853 lua_pop(L, 2); <span class="comment">// pop topwindows table and value</span>
  883. <a name="l00854"></a>00854 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  884. <a name="l00855"></a>00855 }
  885. <a name="l00856"></a>00856
  886. <a name="l00857"></a>00857 parent = check_parents ? parent-&gt;GetParent() : NULL;
  887. <a name="l00858"></a>00858 lua_pop(L, 1); <span class="comment">// pop value (nil)</span>
  888. <a name="l00859"></a>00859 }
  889. <a name="l00860"></a>00860
  890. <a name="l00861"></a>00861 lua_pop(L, 1); <span class="comment">// pop topwindows table</span>
  891. <a name="l00862"></a>00862
  892. <a name="l00863"></a>00863 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  893. <a name="l00864"></a>00864 }
  894. <a name="l00865"></a>00865
  895. <a name="l00866"></a><a class="code" href="wxlstate_8cpp.html#affb2d1ff4f80af7ac7bb6a39ea15a70d">00866</a> wxArrayString LUACALL <a class="code" href="wxlstate_8h.html#affb2d1ff4f80af7ac7bb6a39ea15a70d">wxluaW_gettrackedwindowinfo</a>(lua_State *L)
  896. <a name="l00867"></a>00867 {
  897. <a name="l00868"></a>00868 wxArrayString arrStr;
  898. <a name="l00869"></a>00869
  899. <a name="l00870"></a>00870 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#aab2351a78a8949184e1910cc1f9e7463">wxlua_lreg_topwindows_key</a>); <span class="comment">// push key</span>
  900. <a name="l00871"></a>00871 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  901. <a name="l00872"></a>00872
  902. <a name="l00873"></a>00873 lua_pushnil(L);
  903. <a name="l00874"></a>00874 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
  904. <a name="l00875"></a>00875 {
  905. <a name="l00876"></a>00876 <span class="comment">// value = -1, key = -2, table = -3</span>
  906. <a name="l00877"></a>00877 wxWindow* win = (wxWindow*)lua_touserdata(L, -2);
  907. <a name="l00878"></a>00878 wxCHECK_MSG(win, arrStr, wxT(<span class="stringliteral">&quot;Invalid wxWindow&quot;</span>));
  908. <a name="l00879"></a>00879
  909. <a name="l00880"></a>00880 wxString name(win-&gt;GetClassInfo()-&gt;GetClassName());
  910. <a name="l00881"></a>00881 arrStr.Add(wxString::Format(wxT(<span class="stringliteral">&quot;%s(%p id=%d)&quot;</span>), name.c_str(), win, win-&gt;GetId()));
  911. <a name="l00882"></a>00882
  912. <a name="l00883"></a>00883 lua_pop(L, 1); <span class="comment">// pop value, lua_next will pop key at end</span>
  913. <a name="l00884"></a>00884 }
  914. <a name="l00885"></a>00885
  915. <a name="l00886"></a>00886 lua_pop(L, 1); <span class="comment">// pop table</span>
  916. <a name="l00887"></a>00887
  917. <a name="l00888"></a>00888 arrStr.Sort();
  918. <a name="l00889"></a>00889 <span class="keywordflow">return</span> arrStr;
  919. <a name="l00890"></a>00890 }
  920. <a name="l00891"></a>00891
  921. <a name="l00892"></a>00892 <span class="comment">// ----------------------------------------------------------------------------</span>
  922. <a name="l00893"></a>00893 <span class="comment">// wxluaT_XXX - functions operate on the wxLua types</span>
  923. <a name="l00894"></a>00894 <span class="comment">// ----------------------------------------------------------------------------</span>
  924. <a name="l00895"></a>00895
  925. <a name="l00896"></a><a class="code" href="wxlstate_8cpp.html#a04b6cba130dfe97f09f158899595e2e1">00896</a> <span class="keywordtype">int</span> <a class="code" href="wxlstate_8h.html#a6e860df2af8f36918348b8b92abfbfb4">wxluaT_newmetatable</a>(lua_State* L, <span class="keywordtype">int</span> wxl_type)
  926. <a name="l00897"></a>00897 {
  927. <a name="l00898"></a>00898 lua_newtable(L); <span class="comment">// create a table for our new type</span>
  928. <a name="l00899"></a>00899 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a663c0f4ffbb1923edf3055b4c8c81ff9">wxlua_metatable_type_key</a>); <span class="comment">// push key</span>
  929. <a name="l00900"></a>00900 lua_pushnumber(L, wxl_type); <span class="comment">// push value</span>
  930. <a name="l00901"></a>00901 lua_rawset(L, -3); <span class="comment">// set t[key] = value; pop key and value</span>
  931. <a name="l00902"></a>00902
  932. <a name="l00903"></a>00903 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a0ef6804bd2cb63f4fa705727f8871cbd">wxlua_lreg_types_key</a>); <span class="comment">// push key</span>
  933. <a name="l00904"></a>00904 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  934. <a name="l00905"></a>00905
  935. <a name="l00906"></a>00906 <span class="comment">// make sure that the Lua table array is contiguous</span>
  936. <a name="l00907"></a>00907 <span class="keywordtype">int</span> len = (int)lua_objlen(L, -1); <span class="comment">// get the length of the table</span>
  937. <a name="l00908"></a>00908 <span class="keywordflow">while</span> (++len &lt; wxl_type)
  938. <a name="l00909"></a>00909 {
  939. <a name="l00910"></a>00910 lua_pushnumber(L, 0);
  940. <a name="l00911"></a>00911 lua_rawseti(L, -2, len);
  941. <a name="l00912"></a>00912 }
  942. <a name="l00913"></a>00913
  943. <a name="l00914"></a>00914 <span class="comment">// It is not allowed to reregister this type</span>
  944. <a name="l00915"></a>00915 lua_rawgeti(L, -1, wxl_type);
  945. <a name="l00916"></a>00916 <span class="keywordtype">int</span> t = lua_type(L, -1);
  946. <a name="l00917"></a>00917 wxCHECK_MSG((t == LUA_TNUMBER) || (t == LUA_TNIL), <a class="code" href="wxlbind_8h.html#aeb150b964405f526ef77087288f403b2">WXLUA_TUNKNOWN</a>, wxT(<span class="stringliteral">&quot;Attempting to reregister wxLua type&quot;</span>));
  947. <a name="l00918"></a>00918 lua_pop(L, 1);
  948. <a name="l00919"></a>00919
  949. <a name="l00920"></a>00920 <span class="comment">// Add the metatable to the wxlua_lreg_types_key table</span>
  950. <a name="l00921"></a>00921 lua_pushvalue(L, -2); <span class="comment">// copy the metatable</span>
  951. <a name="l00922"></a>00922 lua_rawseti(L, -2, wxl_type); <span class="comment">// add it, pops table</span>
  952. <a name="l00923"></a>00923 lua_pop(L, 1); <span class="comment">// pop wxlua_lreg_types_key table</span>
  953. <a name="l00924"></a>00924
  954. <a name="l00925"></a>00925 <span class="keywordflow">return</span> wxl_type; <span class="comment">// leave the table on the stack</span>
  955. <a name="l00926"></a>00926 }
  956. <a name="l00927"></a>00927
  957. <a name="l00928"></a><a class="code" href="wxlstate_8cpp.html#ae9010018526dd75ae4cb8571b8956fa5">00928</a> <span class="keywordtype">bool</span> LUACALL <a class="code" href="wxlstate_8h.html#ae9010018526dd75ae4cb8571b8956fa5">wxluaT_getmetatable</a>(lua_State* L, <span class="keywordtype">int</span> wxl_type)
  958. <a name="l00929"></a>00929 {
  959. <a name="l00930"></a>00930 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#ae7108b396d79179f517a7dc478c2cb43">wxluaR_getref</a>(L, wxl_type, &amp;<a class="code" href="wxlstate_8h.html#a0ef6804bd2cb63f4fa705727f8871cbd">wxlua_lreg_types_key</a>)) <span class="comment">// get the metatable</span>
  960. <a name="l00931"></a>00931 {
  961. <a name="l00932"></a>00932 <span class="keywordflow">if</span> (lua_type(L, -1) == LUA_TTABLE)
  962. <a name="l00933"></a>00933 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  963. <a name="l00934"></a>00934
  964. <a name="l00935"></a>00935 lua_pop(L, 1); <span class="comment">// pop nil or 0 placeholder</span>
  965. <a name="l00936"></a>00936 }
  966. <a name="l00937"></a>00937
  967. <a name="l00938"></a>00938 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  968. <a name="l00939"></a>00939 }
  969. <a name="l00940"></a>00940
  970. <a name="l00941"></a><a class="code" href="wxlstate_8cpp.html#a5fb71259953328a8fd54939518cbe455">00941</a> <span class="keywordtype">bool</span> LUACALL <a class="code" href="wxlstate_8h.html#a5fb71259953328a8fd54939518cbe455">wxluaT_setmetatable</a>(lua_State *L, <span class="keywordtype">int</span> wxl_type)
  971. <a name="l00942"></a>00942 {
  972. <a name="l00943"></a>00943 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#ae9010018526dd75ae4cb8571b8956fa5">wxluaT_getmetatable</a>(L, wxl_type)) <span class="comment">// get the metatable</span>
  973. <a name="l00944"></a>00944 {
  974. <a name="l00945"></a>00945 <span class="comment">// set it as the metatable of the object at the top of the stack</span>
  975. <a name="l00946"></a>00946 <span class="keywordflow">if</span> (lua_setmetatable(L, -2)) <span class="comment">// pops table</span>
  976. <a name="l00947"></a>00947 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  977. <a name="l00948"></a>00948 <span class="keywordflow">else</span>
  978. <a name="l00949"></a>00949 {
  979. <a name="l00950"></a>00950 lua_pop(L, 1); <span class="comment">// pop table</span>
  980. <a name="l00951"></a>00951 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, <span class="stringliteral">&quot;wxLua: Unable to set metatable in wxluaT_setmetatable.&quot;</span>);
  981. <a name="l00952"></a>00952 }
  982. <a name="l00953"></a>00953 }
  983. <a name="l00954"></a>00954 <span class="keywordflow">else</span>
  984. <a name="l00955"></a>00955 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, <span class="stringliteral">&quot;wxLua: Unable to get metatable in wxluaT_setmetatable.&quot;</span>);
  985. <a name="l00956"></a>00956
  986. <a name="l00957"></a>00957 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  987. <a name="l00958"></a>00958 }
  988. <a name="l00959"></a>00959
  989. <a name="l00960"></a><a class="code" href="wxlstate_8cpp.html#a212261fffa8066de870a4cdb969d5180">00960</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(lua_State *L, <span class="keywordtype">int</span> stack_idx)
  990. <a name="l00961"></a>00961 {
  991. <a name="l00962"></a>00962 <span class="keywordtype">int</span> wxl_type = <a class="code" href="wxlbind_8h.html#aeb150b964405f526ef77087288f403b2">WXLUA_TUNKNOWN</a>;
  992. <a name="l00963"></a>00963 <span class="keywordtype">int</span> ltype = lua_type(L, stack_idx);
  993. <a name="l00964"></a>00964
  994. <a name="l00965"></a>00965 <span class="keywordflow">if</span> ((ltype == LUA_TUSERDATA) &amp;&amp; lua_getmetatable(L, stack_idx)) <span class="comment">// see wxluaT_newmetatable()</span>
  995. <a name="l00966"></a>00966 {
  996. <a name="l00967"></a>00967 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a663c0f4ffbb1923edf3055b4c8c81ff9">wxlua_metatable_type_key</a>); <span class="comment">// push key</span>
  997. <a name="l00968"></a>00968 lua_rawget(L, -2); <span class="comment">// get t[key] = value; pop key push value</span>
  998. <a name="l00969"></a>00969 wxl_type = (int)lua_tonumber(L, -1); <span class="comment">// if !isnumber it returns 0 (check below is faster)</span>
  999. <a name="l00970"></a>00970
  1000. <a name="l00971"></a>00971 <span class="comment">// if it&#39;s not a number (it&#39;s probably nil) then it&#39;s someone else&#39;s userdata</span>
  1001. <a name="l00972"></a>00972 <span class="keywordflow">if</span> ((wxl_type == 0) &amp;&amp; !lua_isnumber(L, -1))
  1002. <a name="l00973"></a>00973 wxl_type = <a class="code" href="wxlbind_8h.html#af70988ad845289f3b60451dce70d9622">WXLUA_TUSERDATA</a>;
  1003. <a name="l00974"></a>00974
  1004. <a name="l00975"></a>00975 lua_pop(L, 2); <span class="comment">// pop metatable and wxl_type number</span>
  1005. <a name="l00976"></a>00976 }
  1006. <a name="l00977"></a>00977 <span class="keywordflow">else</span>
  1007. <a name="l00978"></a>00978 wxl_type = <a class="code" href="wxlstate_8h.html#a00fa8bc9f668364c6a56b79a3d69738c">wxlua_luatowxluatype</a>(ltype);
  1008. <a name="l00979"></a>00979
  1009. <a name="l00980"></a>00980 <span class="keywordflow">return</span> wxl_type;
  1010. <a name="l00981"></a>00981 }
  1011. <a name="l00982"></a>00982
  1012. <a name="l00983"></a><a class="code" href="wxlstate_8cpp.html#a6621fa5a456448acfd515112aa7b23e1">00983</a> wxString LUACALL <a class="code" href="wxlstate_8h.html#a6621fa5a456448acfd515112aa7b23e1">wxluaT_typename</a>(lua_State* L, <span class="keywordtype">int</span> wxl_type)
  1013. <a name="l00984"></a>00984 {
  1014. <a name="l00985"></a>00985 <span class="comment">// try to use wxString&#39;s ref counting and return this existing copy</span>
  1015. <a name="l00986"></a>00986 <span class="keyword">static</span> wxString s[13] = {
  1016. <a name="l00987"></a>00987 wxT(<span class="stringliteral">&quot;unknown&quot;</span>),
  1017. <a name="l00988"></a>00988 wxT(<span class="stringliteral">&quot;none&quot;</span>),
  1018. <a name="l00989"></a>00989 wxT(<span class="stringliteral">&quot;nil&quot;</span>),
  1019. <a name="l00990"></a>00990 wxT(<span class="stringliteral">&quot;boolean&quot;</span>),
  1020. <a name="l00991"></a>00991 wxT(<span class="stringliteral">&quot;lightuserdata&quot;</span>),
  1021. <a name="l00992"></a>00992 wxT(<span class="stringliteral">&quot;number&quot;</span>),
  1022. <a name="l00993"></a>00993 wxT(<span class="stringliteral">&quot;string&quot;</span>),
  1023. <a name="l00994"></a>00994 wxT(<span class="stringliteral">&quot;table&quot;</span>),
  1024. <a name="l00995"></a>00995 wxT(<span class="stringliteral">&quot;function&quot;</span>),
  1025. <a name="l00996"></a>00996 wxT(<span class="stringliteral">&quot;userdata&quot;</span>),
  1026. <a name="l00997"></a>00997 wxT(<span class="stringliteral">&quot;thread&quot;</span>),
  1027. <a name="l00998"></a>00998 wxT(<span class="stringliteral">&quot;integer&quot;</span>),
  1028. <a name="l00999"></a>00999 wxT(<span class="stringliteral">&quot;cfunction&quot;</span>),
  1029. <a name="l01000"></a>01000 };
  1030. <a name="l01001"></a>01001
  1031. <a name="l01002"></a>01002 <span class="comment">// Check for real type or this is a predefined WXLUA_TXXX type</span>
  1032. <a name="l01003"></a>01003 <span class="keywordflow">if</span> ((L == NULL) || (<a class="code" href="wxlbind_8h.html#a430d2b2f92cfef1455bd99483e58d877">WXLUAT_IS_LUAT</a>(wxl_type)))
  1033. <a name="l01004"></a>01004 {
  1034. <a name="l01005"></a>01005 <span class="keywordflow">switch</span> (wxl_type)
  1035. <a name="l01006"></a>01006 {
  1036. <a name="l01007"></a>01007 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#aeb150b964405f526ef77087288f403b2">WXLUA_TUNKNOWN</a> : <span class="keywordflow">return</span> s[0];
  1037. <a name="l01008"></a>01008 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#ab1ffe83879cd856390708161cbc49e8d">WXLUA_TNONE</a> : <span class="keywordflow">return</span> s[1];
  1038. <a name="l01009"></a>01009 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a1ab3b990ed46ff3d8986e5b0fb7ab2fb">WXLUA_TNIL</a> : <span class="keywordflow">return</span> s[2];
  1039. <a name="l01010"></a>01010 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a458b772ab1522825ff3199d8fba34df7">WXLUA_TBOOLEAN</a> : <span class="keywordflow">return</span> s[3];
  1040. <a name="l01011"></a>01011 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#af997ec3f0137737b21fa6eb91aca9529">WXLUA_TLIGHTUSERDATA</a> : <span class="keywordflow">return</span> s[4];
  1041. <a name="l01012"></a>01012 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#ab722ed662e4f3b7f2624d9a71f5c5817">WXLUA_TNUMBER</a> : <span class="keywordflow">return</span> s[5];
  1042. <a name="l01013"></a>01013 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a2e521227720c7b42b9fe076b1e944405">WXLUA_TSTRING</a> : <span class="keywordflow">return</span> s[6];
  1043. <a name="l01014"></a>01014 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#ab80aed8ef4eafc8ab9479e39597330ff">WXLUA_TTABLE</a> : <span class="keywordflow">return</span> s[7];
  1044. <a name="l01015"></a>01015 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#ad1ad6ff2d60457dfb1251faede683dd7">WXLUA_TFUNCTION</a> : <span class="keywordflow">return</span> s[8];
  1045. <a name="l01016"></a>01016 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#af70988ad845289f3b60451dce70d9622">WXLUA_TUSERDATA</a> : <span class="keywordflow">return</span> s[9];
  1046. <a name="l01017"></a>01017 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#af26c97cbb42bdb22bc85a245bd93c6a4">WXLUA_TTHREAD</a> : <span class="keywordflow">return</span> s[10];
  1047. <a name="l01018"></a>01018
  1048. <a name="l01019"></a>01019 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a58050f86cf4136d7b81371ac367313c0">WXLUA_TINTEGER</a> : <span class="keywordflow">return</span> s[11];
  1049. <a name="l01020"></a>01020 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a53115f4dba53cf577b8fd547b9ac874c">WXLUA_TCFUNCTION</a> : <span class="keywordflow">return</span> s[12];
  1050. <a name="l01021"></a>01021 }
  1051. <a name="l01022"></a>01022 }
  1052. <a name="l01023"></a>01023 <span class="keywordflow">else</span>
  1053. <a name="l01024"></a>01024 {
  1054. <a name="l01025"></a>01025 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = <a class="code" href="wxlstate_8h.html#a4a7a8f2cc1d3b1ba337295b6d02ab97f">wxluaT_getclass</a>(L, wxl_type);
  1055. <a name="l01026"></a>01026 <span class="keywordflow">if</span> (wxlClass)
  1056. <a name="l01027"></a>01027 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#af89cbb87774c38c593f7ed87a68fffcb">name</a>);
  1057. <a name="l01028"></a>01028 }
  1058. <a name="l01029"></a>01029
  1059. <a name="l01030"></a>01030 <span class="keywordflow">return</span> wxT(<span class="stringliteral">&quot;Unknown wxLua Type?&quot;</span>);
  1060. <a name="l01031"></a>01031 }
  1061. <a name="l01032"></a>01032
  1062. <a name="l01033"></a><a class="code" href="wxlstate_8cpp.html#a3d22f924c535006b6202120af11939ae">01033</a> wxString LUACALL <a class="code" href="wxlstate_8h.html#a3d22f924c535006b6202120af11939ae">wxluaT_gettypename</a>(lua_State* L, <span class="keywordtype">int</span> stack_idx)
  1063. <a name="l01034"></a>01034 {
  1064. <a name="l01035"></a>01035 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a6621fa5a456448acfd515112aa7b23e1">wxluaT_typename</a>(L, <a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(L, stack_idx));
  1065. <a name="l01036"></a>01036 }
  1066. <a name="l01037"></a>01037
  1067. <a name="l01038"></a><a class="code" href="wxlstate_8cpp.html#acf6d708626f3c7194d1f2aebb7a73b6e">01038</a> wxString LUACALL <a class="code" href="wxlstate_8h.html#acf6d708626f3c7194d1f2aebb7a73b6e">wxlua_luaL_typename</a>(lua_State* L, <span class="keywordtype">int</span> stack_idx)
  1068. <a name="l01039"></a>01039 {
  1069. <a name="l01040"></a>01040 <span class="comment">// lua_typename(L, lua_type(L, stack_idx))</span>
  1070. <a name="l01041"></a>01041 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(luaL_typename(L, stack_idx));
  1071. <a name="l01042"></a>01042 }
  1072. <a name="l01043"></a>01043
  1073. <a name="l01044"></a><a class="code" href="wxlstate_8cpp.html#a20b4f50d6102023ba6661683929f0157">01044</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlstate_8h.html#a44d205938ab4c0eaacaea1d58face217">wxluaT_gettype</a>(lua_State* L, <span class="keyword">const</span> <span class="keywordtype">char</span>* class_name)
  1074. <a name="l01045"></a>01045 {
  1075. <a name="l01046"></a>01046 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = <a class="code" href="wxlstate_8h.html#a4a7a8f2cc1d3b1ba337295b6d02ab97f">wxluaT_getclass</a>(L, class_name);
  1076. <a name="l01047"></a>01047 <span class="keywordflow">if</span> (wxlClass)
  1077. <a name="l01048"></a>01048 <span class="keywordflow">return</span> *wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a487a56c7a763a21041272c4b053e6c99">wxluatype</a>;
  1078. <a name="l01049"></a>01049
  1079. <a name="l01050"></a>01050 <span class="keywordflow">return</span> <a class="code" href="wxlbind_8h.html#aeb150b964405f526ef77087288f403b2">WXLUA_TUNKNOWN</a>;
  1080. <a name="l01051"></a>01051 }
  1081. <a name="l01052"></a>01052
  1082. <a name="l01053"></a><a class="code" href="wxlstate_8cpp.html#a4a7a8f2cc1d3b1ba337295b6d02ab97f">01053</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* LUACALL <a class="code" href="wxlstate_8h.html#a4a7a8f2cc1d3b1ba337295b6d02ab97f">wxluaT_getclass</a>(lua_State* L, <span class="keywordtype">int</span> wxl_type)
  1083. <a name="l01054"></a>01054 {
  1084. <a name="l01055"></a>01055 <span class="comment">// note: wxluaR_getref() doesn&#39;t leave anything on the stack on failure</span>
  1085. <a name="l01056"></a>01056 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#ae9010018526dd75ae4cb8571b8956fa5">wxluaT_getmetatable</a>(L, wxl_type))
  1086. <a name="l01057"></a>01057 {
  1087. <a name="l01058"></a>01058 <span class="comment">// t[wxluatype] = { [bindclass_key] = lightuserdata wxLuaBindClass... (or nil if not a wxLua class type)</span>
  1088. <a name="l01059"></a>01059 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a8719cfeea23ebd1cb309de8296777da6">wxlua_metatable_wxluabindclass_key</a>);
  1089. <a name="l01060"></a>01060 lua_rawget(L, -2);
  1090. <a name="l01061"></a>01061 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = (<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *)lua_touserdata(L, -1); <span class="comment">// actually lightuserdata</span>
  1091. <a name="l01062"></a>01062
  1092. <a name="l01063"></a>01063 lua_pop(L, 2); <span class="comment">// pop type table and lightuserdata (or nil if none)</span>
  1093. <a name="l01064"></a>01064
  1094. <a name="l01065"></a>01065 <span class="keywordflow">return</span> wxlClass;
  1095. <a name="l01066"></a>01066 }
  1096. <a name="l01067"></a>01067
  1097. <a name="l01068"></a>01068 <span class="keywordflow">return</span> NULL;
  1098. <a name="l01069"></a>01069 }
  1099. <a name="l01070"></a>01070
  1100. <a name="l01071"></a><a class="code" href="wxlstate_8cpp.html#a75b24f6e3e8ab375104bb23ea702f0bf">01071</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* LUACALL <a class="code" href="wxlstate_8h.html#a4a7a8f2cc1d3b1ba337295b6d02ab97f">wxluaT_getclass</a>(lua_State* L, <span class="keyword">const</span> <span class="keywordtype">char</span>* class_name)
  1101. <a name="l01072"></a>01072 {
  1102. <a name="l01073"></a>01073 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a0bcf696ed6d6e2b4218e9a8852a164ef">wxlua_lreg_classes_key</a>); <span class="comment">// push key</span>
  1103. <a name="l01074"></a>01074 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  1104. <a name="l01075"></a>01075
  1105. <a name="l01076"></a>01076 lua_pushstring(L, class_name); <span class="comment">// push key</span>
  1106. <a name="l01077"></a>01077 lua_rawget(L, -2); <span class="comment">// get t[&quot;class_name&quot;] = &amp;wxLuaBindClass; pop key push value</span>
  1107. <a name="l01078"></a>01078 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = (<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *)lua_touserdata(L, -1); <span class="comment">// actually lightuserdata</span>
  1108. <a name="l01079"></a>01079
  1109. <a name="l01080"></a>01080 lua_pop(L, 2); <span class="comment">// pop table and lightuserdata (or nil if none)</span>
  1110. <a name="l01081"></a>01081
  1111. <a name="l01082"></a>01082 <span class="keywordflow">return</span> wxlClass; <span class="comment">// may be NULL</span>
  1112. <a name="l01083"></a>01083 }
  1113. <a name="l01084"></a>01084
  1114. <a name="l01085"></a><a class="code" href="wxlstate_8cpp.html#a1602757335e28069aa1d9416a5c53ac2">01085</a> <span class="keywordtype">bool</span> <a class="code" href="wxlstate_8h.html#a1602757335e28069aa1d9416a5c53ac2">wxluaT_isuserdatatype</a>(lua_State* L, <span class="keywordtype">int</span> stack_idx, <span class="keywordtype">int</span> wxl_type)
  1115. <a name="l01086"></a>01086 {
  1116. <a name="l01087"></a>01087 <span class="keywordtype">int</span> stack_type = <a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(L, stack_idx);
  1117. <a name="l01088"></a>01088
  1118. <a name="l01089"></a>01089 <span class="keywordflow">if</span> (<a class="code" href="wxlbind_8h.html#ab26c2ec570e70f2f2b3ed9fa82afe24a">wxlua_iswxuserdatatype</a>(stack_type) &amp;&amp;
  1119. <a name="l01090"></a>01090 ((<a class="code" href="wxlbind_8cpp.html#ada2f84390e66116604bfa8d5102c7305">wxluatype_NULL</a> == stack_type) || <span class="comment">// FIXME, how to check when NULL is valid or not?</span>
  1120. <a name="l01091"></a>01091 ((wxl_type == <a class="code" href="wxlbind_8h.html#a2e521227720c7b42b9fe076b1e944405">WXLUA_TSTRING</a>) &amp;&amp; (<a class="code" href="wxlstate_8h.html#a1a5e4f51c5902cbd8e3047f7a99b871d">wxluaT_isderivedtype</a>(L, stack_type, *<a class="code" href="wxlbind_8cpp.html#a4d788db68e87954d09dd58ea30df0cd3">p_wxluatype_wxString</a>) &gt;= 0)) ||
  1121. <a name="l01092"></a>01092 (<a class="code" href="wxlstate_8h.html#a1a5e4f51c5902cbd8e3047f7a99b871d">wxluaT_isderivedtype</a>(L, stack_type, wxl_type) &gt;= 0)))
  1122. <a name="l01093"></a>01093 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  1123. <a name="l01094"></a>01094
  1124. <a name="l01095"></a>01095 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  1125. <a name="l01096"></a>01096 }
  1126. <a name="l01097"></a>01097
  1127. <a name="l01098"></a><a class="code" href="wxlstate_8cpp.html#a4b840fe9dc39ed3114a3c4b271507335">01098</a> <span class="keywordtype">void</span>* LUACALL <a class="code" href="wxlstate_8h.html#a4b840fe9dc39ed3114a3c4b271507335">wxluaT_getuserdatatype</a>(lua_State* L, <span class="keywordtype">int</span> stack_idx, <span class="keywordtype">int</span> wxl_type)
  1128. <a name="l01099"></a>01099 {
  1129. <a name="l01100"></a>01100 <span class="keywordtype">int</span> stack_type = <a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(L, stack_idx);
  1130. <a name="l01101"></a>01101
  1131. <a name="l01102"></a>01102 <span class="keywordflow">if</span> (<a class="code" href="wxlbind_8cpp.html#ada2f84390e66116604bfa8d5102c7305">wxluatype_NULL</a> == stack_type)
  1132. <a name="l01103"></a>01103 <span class="keywordflow">return</span> NULL;
  1133. <a name="l01104"></a>01104 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a1a5e4f51c5902cbd8e3047f7a99b871d">wxluaT_isderivedtype</a>(L, stack_type, wxl_type) &gt;= 0)
  1134. <a name="l01105"></a>01105 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#ac5a0a65665274df59adbed667480e93e">wxlua_touserdata</a>(L, stack_idx, <span class="keyword">false</span>);
  1135. <a name="l01106"></a>01106
  1136. <a name="l01107"></a>01107 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;a &#39;&quot;</span>) + <a class="code" href="wxlstate_8h.html#a6621fa5a456448acfd515112aa7b23e1">wxluaT_typename</a>(L, wxl_type) + wxT(<span class="stringliteral">&quot;&#39;&quot;</span>));
  1137. <a name="l01108"></a>01108
  1138. <a name="l01109"></a>01109 <span class="keywordflow">return</span> NULL;
  1139. <a name="l01110"></a>01110 }
  1140. <a name="l01111"></a>01111
  1141. <a name="l01112"></a><a class="code" href="wxlstate_8cpp.html#ad1e9e9ace0385ddbce65697d702c4cf4">01112</a> <span class="keywordtype">bool</span> LUACALL <a class="code" href="wxlstate_8h.html#a4cd81a70613d64cac4f0f363807df6a6">wxluaT_pushuserdatatype</a>(lua_State* L, <span class="keyword">const</span> <span class="keywordtype">void</span> *obj_ptr, <span class="keywordtype">int</span> wxl_type, <span class="keywordtype">bool</span> track, <span class="keywordtype">bool</span> allow_NULL)
  1142. <a name="l01113"></a>01113 {
  1143. <a name="l01114"></a>01114 <span class="comment">// FIXME allow_NULL is a hack for the NULL userdata type.</span>
  1144. <a name="l01115"></a>01115
  1145. <a name="l01116"></a>01116 <span class="keywordflow">if</span> (allow_NULL || (obj_ptr != NULL))
  1146. <a name="l01117"></a>01117 {
  1147. <a name="l01118"></a>01118 <span class="comment">// First check to see if we&#39;ve already pushed this object into Lua.</span>
  1148. <a name="l01119"></a>01119 <span class="comment">// This avoids the problem of the gc deleting a returned pointer to a permanent object.</span>
  1149. <a name="l01120"></a>01120 <span class="comment">// Test code is this:</span>
  1150. <a name="l01121"></a>01121 <span class="comment">// il = wx.wxImageList(16,16); ... noteBook:SetImageList(il); ... local il2 = noteBook:GetImageList()</span>
  1151. <a name="l01122"></a>01122 <span class="comment">// When il2 gets gc it will delete il even though il may still be valid and used by the notebook.</span>
  1152. <a name="l01123"></a>01123
  1153. <a name="l01124"></a>01124 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a1c0abab7b240281334eea23ce5cd5b94">wxluaO_istrackedweakobject</a>(L, (<span class="keywordtype">void</span>*)obj_ptr, wxl_type, <span class="keyword">true</span>))
  1154. <a name="l01125"></a>01125 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  1155. <a name="l01126"></a>01126
  1156. <a name="l01127"></a>01127 <span class="comment">// if the object we are referencing is derived from wxWindow</span>
  1157. <a name="l01128"></a>01128 <span class="keywordflow">if</span> (obj_ptr &amp;&amp; (<a class="code" href="wxlstate_8h.html#a1a5e4f51c5902cbd8e3047f7a99b871d">wxluaT_isderivedtype</a>(L, wxl_type, *<a class="code" href="wxlbind_8cpp.html#a39c4487f5ea5ac7d668d2f6db931970e">p_wxluatype_wxWindow</a>) &gt;= 0))
  1158. <a name="l01129"></a>01129 {
  1159. <a name="l01130"></a>01130 wxWindow* win = wxDynamicCast(obj_ptr, wxWindow); <span class="comment">// double check that it&#39;s a wxWindow</span>
  1160. <a name="l01131"></a>01131 <span class="keywordflow">if</span> (win != NULL)
  1161. <a name="l01132"></a>01132 {
  1162. <a name="l01133"></a>01133 <span class="comment">// check to make sure that we&#39;re not trying to attach another destroy callback</span>
  1163. <a name="l01134"></a>01134 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#ae13b14073477671929c41823f198c33d">wxlua_lreg_windestroycallbacks_key</a>); <span class="comment">// push key</span>
  1164. <a name="l01135"></a>01135 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  1165. <a name="l01136"></a>01136
  1166. <a name="l01137"></a>01137 lua_pushlightuserdata(L, win); <span class="comment">// push key</span>
  1167. <a name="l01138"></a>01138 lua_rawget(L, -2); <span class="comment">// get t[key] = value; pops key</span>
  1168. <a name="l01139"></a>01139
  1169. <a name="l01140"></a>01140 <span class="keywordflow">if</span> (!lua_islightuserdata(L, -1))
  1170. <a name="l01141"></a>01141 {
  1171. <a name="l01142"></a>01142 <span class="comment">// Connect the wxWindow to wxEVT_DESTROY callback so if Lua has</span>
  1172. <a name="l01143"></a>01143 <span class="comment">// a copy(s) of it we can clear the metatable when we get the</span>
  1173. <a name="l01144"></a>01144 <span class="comment">// event so we don&#39;t segfault if we try to access it by accident.</span>
  1174. <a name="l01145"></a>01145 <a class="code" href="classwxLuaState.html">wxLuaState</a> wxlState(L);
  1175. <a name="l01146"></a>01146 wxCHECK_MSG(wxlState.<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  1176. <a name="l01147"></a>01147 <a class="code" href="classwxLuaWinDestroyCallback.html">wxLuaWinDestroyCallback</a> *pCallback =
  1177. <a name="l01148"></a>01148 <span class="keyword">new</span> <a class="code" href="classwxLuaWinDestroyCallback.html">wxLuaWinDestroyCallback</a>(wxlState, win);
  1178. <a name="l01149"></a>01149
  1179. <a name="l01150"></a>01150 <span class="keywordflow">if</span> (pCallback == NULL)
  1180. <a name="l01151"></a>01151 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, <span class="stringliteral">&quot;wxLua: Out of memory creating wxLuaWinDestroyCallback.&quot;</span>);
  1181. <a name="l01152"></a>01152 <span class="comment">// assert should have been given in constructor so delete it</span>
  1182. <a name="l01153"></a>01153 <span class="comment">// since it&#39;s not attached as a callback user data</span>
  1183. <a name="l01154"></a>01154 <span class="keywordflow">if</span> (!pCallback-&gt;Ok())
  1184. <a name="l01155"></a>01155 <span class="keyword">delete</span> pCallback;
  1185. <a name="l01156"></a>01156 }
  1186. <a name="l01157"></a>01157
  1187. <a name="l01158"></a>01158 lua_pop(L, 2); <span class="comment">// pop windestroy table and value</span>
  1188. <a name="l01159"></a>01159 }
  1189. <a name="l01160"></a>01160 }
  1190. <a name="l01161"></a>01161
  1191. <a name="l01162"></a>01162 <span class="comment">// Wrap the void* pointer in a newuserdata</span>
  1192. <a name="l01163"></a>01163 <span class="keyword">const</span> <span class="keywordtype">void</span> **ptr = (<span class="keyword">const</span> <span class="keywordtype">void</span> **)lua_newuserdata(L, <span class="keyword">sizeof</span>(<span class="keywordtype">void</span> *));
  1193. <a name="l01164"></a>01164 <span class="keywordflow">if</span> (ptr != NULL)
  1194. <a name="l01165"></a>01165 {
  1195. <a name="l01166"></a>01166 *ptr = obj_ptr;
  1196. <a name="l01167"></a>01167 <span class="comment">// try to get the object&#39;s references table and set the metatable to the object</span>
  1197. <a name="l01168"></a>01168 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#ae9010018526dd75ae4cb8571b8956fa5">wxluaT_getmetatable</a>(L, wxl_type))
  1198. <a name="l01169"></a>01169 {
  1199. <a name="l01170"></a>01170 <span class="comment">// pop the table and set it as the metatable for the newuserdata</span>
  1200. <a name="l01171"></a>01171 lua_setmetatable(L, -2);
  1201. <a name="l01172"></a>01172
  1202. <a name="l01173"></a>01173 <span class="keywordflow">if</span> (track)
  1203. <a name="l01174"></a>01174 <a class="code" href="wxlstate_8h.html#a877ac3a3e719283fbf39f4887daeb928">wxluaO_trackweakobject</a>(L, -1, (<span class="keywordtype">void</span>*)obj_ptr, wxl_type);
  1204. <a name="l01175"></a>01175
  1205. <a name="l01176"></a>01176 <span class="keywordflow">return</span> <span class="keyword">true</span>; <span class="comment">// leave value on the stack</span>
  1206. <a name="l01177"></a>01177 }
  1207. <a name="l01178"></a>01178 <span class="keywordflow">else</span>
  1208. <a name="l01179"></a>01179 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, <span class="stringliteral">&quot;wxLua: Unable to get metatable in wxluaT_pushuserdatatype.&quot;</span>);
  1209. <a name="l01180"></a>01180 }
  1210. <a name="l01181"></a>01181 <span class="keywordflow">else</span>
  1211. <a name="l01182"></a>01182 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, <span class="stringliteral">&quot;wxLua: Out of memory&quot;</span>);
  1212. <a name="l01183"></a>01183 }
  1213. <a name="l01184"></a>01184 <span class="keywordflow">else</span>
  1214. <a name="l01185"></a>01185 {
  1215. <a name="l01186"></a>01186 lua_pushnil(L);
  1216. <a name="l01187"></a>01187 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  1217. <a name="l01188"></a>01188 }
  1218. <a name="l01189"></a>01189
  1219. <a name="l01190"></a>01190 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  1220. <a name="l01191"></a>01191 }
  1221. <a name="l01192"></a>01192
  1222. <a name="l01193"></a>01193 <span class="comment">// ----------------------------------------------------------------------------</span>
  1223. <a name="l01194"></a>01194 <span class="comment">// Functions to get info about the wxLua types</span>
  1224. <a name="l01195"></a>01195 <span class="comment">// ----------------------------------------------------------------------------</span>
  1225. <a name="l01196"></a>01196
  1226. <a name="l01197"></a><a class="code" href="wxlstate_8cpp.html#a4a9c7d2181167e553f8cb78984b13aeb">01197</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="wxlstate_8cpp.html#a4a9c7d2181167e553f8cb78984b13aeb">wxluaT_isderivedtype_recurser</a>(<span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *wxlClass, <span class="keywordtype">int</span> base_wxl_type, <span class="keywordtype">int</span> levels)
  1227. <a name="l01198"></a>01198 {
  1228. <a name="l01199"></a>01199 <span class="keywordflow">if</span> (wxlClass != NULL)
  1229. <a name="l01200"></a>01200 {
  1230. <a name="l01201"></a>01201 <span class="keywordflow">if</span> (*wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a487a56c7a763a21041272c4b053e6c99">wxluatype</a> == base_wxl_type)
  1231. <a name="l01202"></a>01202 <span class="keywordflow">return</span> levels;
  1232. <a name="l01203"></a>01203 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a22728b03f43176679679849fdb48f55e">baseclassNames</a> != NULL) <span class="comment">// check baseclass by baseclass</span>
  1233. <a name="l01204"></a>01204 {
  1234. <a name="l01205"></a>01205 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a22728b03f43176679679849fdb48f55e">baseclassNames</a>[i]; ++i)
  1235. <a name="l01206"></a>01206 {
  1236. <a name="l01207"></a>01207 <span class="comment">// Note: base class may be NULL if lib/module containing it is not loaded</span>
  1237. <a name="l01208"></a>01208 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* baseClass = wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#ad6e5609d26483c65f37a6968275d7a0d">baseBindClasses</a>[i];
  1238. <a name="l01209"></a>01209
  1239. <a name="l01210"></a>01210 <span class="keywordflow">if</span> (baseClass != NULL)
  1240. <a name="l01211"></a>01211 {
  1241. <a name="l01212"></a>01212 <span class="keywordflow">if</span> (*baseClass-&gt;<a class="code" href="structwxLuaBindClass.html#a487a56c7a763a21041272c4b053e6c99">wxluatype</a> == base_wxl_type)
  1242. <a name="l01213"></a>01213 <span class="keywordflow">return</span> levels;
  1243. <a name="l01214"></a>01214 <span class="keywordflow">else</span>
  1244. <a name="l01215"></a>01215 {
  1245. <a name="l01216"></a>01216 <span class="keywordtype">int</span> ret = <a class="code" href="wxlstate_8cpp.html#a4a9c7d2181167e553f8cb78984b13aeb">wxluaT_isderivedtype_recurser</a>(baseClass, base_wxl_type, levels+1);
  1246. <a name="l01217"></a>01217 <span class="keywordflow">if</span> (ret &gt; -1)
  1247. <a name="l01218"></a>01218 <span class="keywordflow">return</span> ret;
  1248. <a name="l01219"></a>01219 }
  1249. <a name="l01220"></a>01220 }
  1250. <a name="l01221"></a>01221 }
  1251. <a name="l01222"></a>01222 }
  1252. <a name="l01223"></a>01223 }
  1253. <a name="l01224"></a>01224
  1254. <a name="l01225"></a>01225 <span class="keywordflow">return</span> -1; <span class="comment">// wxluatype is not derived from base_wxluatype</span>
  1255. <a name="l01226"></a>01226 }
  1256. <a name="l01227"></a>01227
  1257. <a name="l01228"></a><a class="code" href="wxlstate_8cpp.html#a1a5e4f51c5902cbd8e3047f7a99b871d">01228</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlstate_8h.html#a1a5e4f51c5902cbd8e3047f7a99b871d">wxluaT_isderivedtype</a>(lua_State* L, <span class="keywordtype">int</span> wxl_type, <span class="keywordtype">int</span> base_wxl_type)
  1258. <a name="l01229"></a>01229 {
  1259. <a name="l01230"></a>01230 <span class="comment">// couldn&#39;t possibly be derived from each other</span>
  1260. <a name="l01231"></a>01231 <span class="keywordflow">if</span> (!<a class="code" href="wxlbind_8h.html#ab26c2ec570e70f2f2b3ed9fa82afe24a">wxlua_iswxuserdatatype</a>(wxl_type) || !<a class="code" href="wxlbind_8h.html#ab26c2ec570e70f2f2b3ed9fa82afe24a">wxlua_iswxuserdatatype</a>(base_wxl_type))
  1261. <a name="l01232"></a>01232 <span class="keywordflow">return</span> -1;
  1262. <a name="l01233"></a>01233
  1263. <a name="l01234"></a>01234 <span class="comment">// These two types are the same</span>
  1264. <a name="l01235"></a>01235 <span class="keywordflow">if</span> (wxl_type == base_wxl_type)
  1265. <a name="l01236"></a>01236 <span class="keywordflow">return</span> 0;
  1266. <a name="l01237"></a>01237
  1267. <a name="l01238"></a>01238 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *wxlClass = <a class="code" href="wxlstate_8h.html#a4a7a8f2cc1d3b1ba337295b6d02ab97f">wxluaT_getclass</a>(L, wxl_type);
  1268. <a name="l01239"></a>01239
  1269. <a name="l01240"></a>01240 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#a4a9c7d2181167e553f8cb78984b13aeb">wxluaT_isderivedtype_recurser</a>(wxlClass, base_wxl_type, 1);
  1270. <a name="l01241"></a>01241 }
  1271. <a name="l01242"></a>01242
  1272. <a name="l01243"></a><a class="code" href="wxlstate_8cpp.html#a769186e214bfa3f0029e6c6addd9d42d">01243</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlstate_8h.html#a769186e214bfa3f0029e6c6addd9d42d">wxluaT_isderivedclass</a>(<span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass, <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* base_wxlClass)
  1273. <a name="l01244"></a>01244 {
  1274. <a name="l01245"></a>01245 <span class="comment">// Ok if either is NULL to allow blindly calling this</span>
  1275. <a name="l01246"></a>01246 <span class="keywordflow">if</span> ((wxlClass == NULL) || (base_wxlClass == NULL))
  1276. <a name="l01247"></a>01247 <span class="keywordflow">return</span> -1;
  1277. <a name="l01248"></a>01248
  1278. <a name="l01249"></a>01249 <span class="comment">// These two types are the same</span>
  1279. <a name="l01250"></a>01250 <span class="keywordflow">if</span> (wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a487a56c7a763a21041272c4b053e6c99">wxluatype</a> == base_wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a487a56c7a763a21041272c4b053e6c99">wxluatype</a>) <span class="comment">// comparing pointers</span>
  1280. <a name="l01251"></a>01251 <span class="keywordflow">return</span> 0;
  1281. <a name="l01252"></a>01252
  1282. <a name="l01253"></a>01253 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#a4a9c7d2181167e553f8cb78984b13aeb">wxluaT_isderivedtype_recurser</a>(wxlClass, *base_wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a487a56c7a763a21041272c4b053e6c99">wxluatype</a>, 1);
  1283. <a name="l01254"></a>01254 }
  1284. <a name="l01255"></a>01255
  1285. <a name="l01256"></a><a class="code" href="wxlstate_8cpp.html#a66b8e88ce731fc39d11b9e3a3615ffc1">01256</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlstate_8h.html#a47f2034cabf94ca87dde758af863f4e2">wxlua_iswxluatype</a>(<span class="keywordtype">int</span> luatype, <span class="keywordtype">int</span> wxl_type, lua_State* L <span class="comment">/* = NULL */</span>)
  1286. <a name="l01257"></a>01257 {
  1287. <a name="l01258"></a>01258 <span class="keywordtype">int</span> ret = -1; <span class="comment">// unknown wxlua arg type</span>
  1288. <a name="l01259"></a>01259
  1289. <a name="l01260"></a>01260 <span class="keywordflow">switch</span> (wxl_type)
  1290. <a name="l01261"></a>01261 {
  1291. <a name="l01262"></a>01262 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#ab1ffe83879cd856390708161cbc49e8d">WXLUA_TNONE</a> :
  1292. <a name="l01263"></a>01263 ret = (luatype == LUA_TNONE) ? 1 : 0;
  1293. <a name="l01264"></a>01264 <span class="keywordflow">break</span>;
  1294. <a name="l01265"></a>01265 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a1ab3b990ed46ff3d8986e5b0fb7ab2fb">WXLUA_TNIL</a> :
  1295. <a name="l01266"></a>01266 ret = (luatype == LUA_TNIL) ? 1 : 0;
  1296. <a name="l01267"></a>01267 <span class="keywordflow">break</span>;
  1297. <a name="l01268"></a>01268 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a458b772ab1522825ff3199d8fba34df7">WXLUA_TBOOLEAN</a> :
  1298. <a name="l01269"></a>01269 <span class="comment">// LUA_TNIL: nil == false</span>
  1299. <a name="l01270"></a>01270 <span class="comment">// LUA_TNUMBER: 0 == false as in C</span>
  1300. <a name="l01271"></a>01271 ret = ((luatype == LUA_TBOOLEAN) || (luatype == LUA_TNUMBER) || (luatype == LUA_TNIL)) ? 1 : 0;
  1301. <a name="l01272"></a>01272 <span class="keywordflow">break</span>;
  1302. <a name="l01273"></a>01273 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#af997ec3f0137737b21fa6eb91aca9529">WXLUA_TLIGHTUSERDATA</a>:
  1303. <a name="l01274"></a>01274 ret = (luatype == LUA_TLIGHTUSERDATA) ? 1 : 0;
  1304. <a name="l01275"></a>01275 <span class="keywordflow">break</span>;
  1305. <a name="l01276"></a>01276 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#ab722ed662e4f3b7f2624d9a71f5c5817">WXLUA_TNUMBER</a> :
  1306. <a name="l01277"></a>01277 <span class="comment">// LUA_TNIL: evaluates to 0, too easy to have a typo</span>
  1307. <a name="l01278"></a>01278 <span class="comment">// LUA_TSTRING: will be 0 unless really a number &quot;2&quot;</span>
  1308. <a name="l01279"></a>01279 <span class="comment">// LUA_TBOOLEAN: can&#39;t do (bool_val or 1)</span>
  1309. <a name="l01280"></a>01280 ret = ((luatype == LUA_TNUMBER) || (luatype == LUA_TBOOLEAN)) ? 1 : 0;
  1310. <a name="l01281"></a>01281 <span class="keywordflow">break</span>;
  1311. <a name="l01282"></a>01282 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a2e521227720c7b42b9fe076b1e944405">WXLUA_TSTRING</a> :
  1312. <a name="l01283"></a>01283 <span class="comment">// LUA_TNIL: too easy to have a variable typo, use (str or &quot;&quot;)</span>
  1313. <a name="l01284"></a>01284 <span class="comment">// LUA_TNUMBER: can convert easily, always works, but breaks overload bindings</span>
  1314. <a name="l01285"></a>01285 ret = (luatype == LUA_TSTRING) ? 1 : 0;
  1315. <a name="l01286"></a>01286 <span class="keywordflow">break</span>;
  1316. <a name="l01287"></a>01287 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#ab80aed8ef4eafc8ab9479e39597330ff">WXLUA_TTABLE</a> :
  1317. <a name="l01288"></a>01288 ret = (luatype == LUA_TTABLE) ? 1 : 0;
  1318. <a name="l01289"></a>01289 <span class="keywordflow">break</span>;
  1319. <a name="l01290"></a>01290 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#ad1ad6ff2d60457dfb1251faede683dd7">WXLUA_TFUNCTION</a> :
  1320. <a name="l01291"></a>01291 ret = (luatype == LUA_TFUNCTION) ? 1 : 0;
  1321. <a name="l01292"></a>01292 <span class="keywordflow">break</span>;
  1322. <a name="l01293"></a>01293 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#af70988ad845289f3b60451dce70d9622">WXLUA_TUSERDATA</a> :
  1323. <a name="l01294"></a>01294 ret = (luatype == LUA_TUSERDATA) ? 1 : 0;
  1324. <a name="l01295"></a>01295 <span class="keywordflow">break</span>;
  1325. <a name="l01296"></a>01296 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#af26c97cbb42bdb22bc85a245bd93c6a4">WXLUA_TTHREAD</a> :
  1326. <a name="l01297"></a>01297 ret = (luatype == LUA_TTHREAD) ? 1 : 0;
  1327. <a name="l01298"></a>01298 <span class="keywordflow">break</span>;
  1328. <a name="l01299"></a>01299 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a58050f86cf4136d7b81371ac367313c0">WXLUA_TINTEGER</a> :
  1329. <a name="l01300"></a>01300 <span class="comment">// LUA_TNIL: evaluates to 0 so wx.ENUM_typo = 0</span>
  1330. <a name="l01301"></a>01301 ret = (luatype == LUA_TNUMBER) ? 1 : 0;
  1331. <a name="l01302"></a>01302 <span class="keywordflow">break</span>;
  1332. <a name="l01303"></a>01303 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a53115f4dba53cf577b8fd547b9ac874c">WXLUA_TCFUNCTION</a> :
  1333. <a name="l01304"></a>01304 ret = (luatype == LUA_TFUNCTION) ? 1 : 0;
  1334. <a name="l01305"></a>01305 <span class="keywordflow">break</span>;
  1335. <a name="l01306"></a>01306 }
  1336. <a name="l01307"></a>01307
  1337. <a name="l01308"></a>01308 <span class="comment">// if we don&#39;t know the type (it&#39;s not predefined)</span>
  1338. <a name="l01309"></a>01309 <span class="keywordflow">if</span> ((ret &lt; 0) &amp;&amp; L &amp;&amp;(luatype == LUA_TTABLE))
  1339. <a name="l01310"></a>01310 {
  1340. <a name="l01311"></a>01311 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = <a class="code" href="wxlstate_8h.html#a4a7a8f2cc1d3b1ba337295b6d02ab97f">wxluaT_getclass</a>(L, wxl_type);
  1341. <a name="l01312"></a>01312
  1342. <a name="l01313"></a>01313 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a769186e214bfa3f0029e6c6addd9d42d">wxluaT_isderivedclass</a>(wxlClass, <a class="code" href="wxlstate_8h.html#a4a7a8f2cc1d3b1ba337295b6d02ab97f">wxluaT_getclass</a>(L, <span class="stringliteral">&quot;wxArrayString&quot;</span>)) &gt;= 0)
  1343. <a name="l01314"></a>01314 ret = 1;
  1344. <a name="l01315"></a>01315 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a769186e214bfa3f0029e6c6addd9d42d">wxluaT_isderivedclass</a>(wxlClass, <a class="code" href="wxlstate_8h.html#a4a7a8f2cc1d3b1ba337295b6d02ab97f">wxluaT_getclass</a>(L, <span class="stringliteral">&quot;wxSortedArrayString&quot;</span>)) &gt;= 0)
  1345. <a name="l01316"></a>01316 ret = 1;
  1346. <a name="l01317"></a>01317 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a769186e214bfa3f0029e6c6addd9d42d">wxluaT_isderivedclass</a>(wxlClass, <a class="code" href="wxlstate_8h.html#a4a7a8f2cc1d3b1ba337295b6d02ab97f">wxluaT_getclass</a>(L, <span class="stringliteral">&quot;wxArrayInt&quot;</span>)) &gt;= 0)
  1347. <a name="l01318"></a>01318 ret = 1;
  1348. <a name="l01319"></a>01319 }
  1349. <a name="l01320"></a>01320
  1350. <a name="l01321"></a>01321 <span class="keywordflow">return</span> ret;
  1351. <a name="l01322"></a>01322 }
  1352. <a name="l01323"></a>01323
  1353. <a name="l01324"></a><a class="code" href="wxlstate_8cpp.html#a00fa8bc9f668364c6a56b79a3d69738c">01324</a> <span class="keywordtype">int</span> <a class="code" href="wxlstate_8h.html#a00fa8bc9f668364c6a56b79a3d69738c">wxlua_luatowxluatype</a>(<span class="keywordtype">int</span> luatype)
  1354. <a name="l01325"></a>01325 {
  1355. <a name="l01326"></a>01326 <span class="comment">//int wxltype = LUAT_TO_WXLUAT(luatype);</span>
  1356. <a name="l01327"></a>01327 <span class="comment">//if (!WXLUAT_IS_LUAT(wxltype))</span>
  1357. <a name="l01328"></a>01328 <span class="comment">// return WXLUA_TUNKNOWN;</span>
  1358. <a name="l01329"></a>01329 <span class="comment">//return wxltype;</span>
  1359. <a name="l01330"></a>01330
  1360. <a name="l01331"></a>01331 <span class="keywordflow">switch</span> (luatype)
  1361. <a name="l01332"></a>01332 {
  1362. <a name="l01333"></a>01333 <span class="keywordflow">case</span> LUA_TNONE : <span class="keywordflow">return</span> <a class="code" href="wxlbind_8h.html#ab1ffe83879cd856390708161cbc49e8d">WXLUA_TNONE</a>;
  1363. <a name="l01334"></a>01334 <span class="keywordflow">case</span> LUA_TNIL : <span class="keywordflow">return</span> <a class="code" href="wxlbind_8h.html#a1ab3b990ed46ff3d8986e5b0fb7ab2fb">WXLUA_TNIL</a>;
  1364. <a name="l01335"></a>01335 <span class="keywordflow">case</span> LUA_TBOOLEAN : <span class="keywordflow">return</span> <a class="code" href="wxlbind_8h.html#a458b772ab1522825ff3199d8fba34df7">WXLUA_TBOOLEAN</a>;
  1365. <a name="l01336"></a>01336 <span class="keywordflow">case</span> LUA_TLIGHTUSERDATA : <span class="keywordflow">return</span> <a class="code" href="wxlbind_8h.html#af997ec3f0137737b21fa6eb91aca9529">WXLUA_TLIGHTUSERDATA</a>;
  1366. <a name="l01337"></a>01337 <span class="keywordflow">case</span> LUA_TNUMBER : <span class="keywordflow">return</span> <a class="code" href="wxlbind_8h.html#ab722ed662e4f3b7f2624d9a71f5c5817">WXLUA_TNUMBER</a>;
  1367. <a name="l01338"></a>01338 <span class="keywordflow">case</span> LUA_TSTRING : <span class="keywordflow">return</span> <a class="code" href="wxlbind_8h.html#a2e521227720c7b42b9fe076b1e944405">WXLUA_TSTRING</a>;
  1368. <a name="l01339"></a>01339 <span class="keywordflow">case</span> LUA_TTABLE : <span class="keywordflow">return</span> <a class="code" href="wxlbind_8h.html#ab80aed8ef4eafc8ab9479e39597330ff">WXLUA_TTABLE</a>;
  1369. <a name="l01340"></a>01340 <span class="keywordflow">case</span> LUA_TFUNCTION : <span class="keywordflow">return</span> <a class="code" href="wxlbind_8h.html#ad1ad6ff2d60457dfb1251faede683dd7">WXLUA_TFUNCTION</a>;
  1370. <a name="l01341"></a>01341 <span class="keywordflow">case</span> LUA_TUSERDATA : <span class="keywordflow">return</span> <a class="code" href="wxlbind_8h.html#af70988ad845289f3b60451dce70d9622">WXLUA_TUSERDATA</a>;
  1371. <a name="l01342"></a>01342 <span class="keywordflow">case</span> LUA_TTHREAD : <span class="keywordflow">return</span> <a class="code" href="wxlbind_8h.html#af26c97cbb42bdb22bc85a245bd93c6a4">WXLUA_TTHREAD</a>;
  1372. <a name="l01343"></a>01343 <span class="comment">//case LUA_T??? : return WXLUA_TINTEGER;</span>
  1373. <a name="l01344"></a>01344 <span class="comment">//case LUA_T??? : return WXLUA_TCFUNCTION;</span>
  1374. <a name="l01345"></a>01345 }
  1375. <a name="l01346"></a>01346
  1376. <a name="l01347"></a>01347 <span class="keywordflow">return</span> <a class="code" href="wxlbind_8h.html#aeb150b964405f526ef77087288f403b2">WXLUA_TUNKNOWN</a>;
  1377. <a name="l01348"></a>01348 }
  1378. <a name="l01349"></a>01349
  1379. <a name="l01350"></a><a class="code" href="wxlstate_8cpp.html#a34bd3e8bebe8556a9ee5d49582dea852">01350</a> <span class="keywordtype">int</span> <a class="code" href="wxlstate_8h.html#a63327ee17f8a4f24c7c96ac8db97e146">wxlua_wxluatoluatype</a>(<span class="keywordtype">int</span> wxlarg)
  1380. <a name="l01351"></a>01351 {
  1381. <a name="l01352"></a>01352 <span class="keywordflow">switch</span> (wxlarg)
  1382. <a name="l01353"></a>01353 {
  1383. <a name="l01354"></a>01354 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#ab1ffe83879cd856390708161cbc49e8d">WXLUA_TNONE</a> : <span class="keywordflow">return</span> LUA_TNONE;
  1384. <a name="l01355"></a>01355 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a1ab3b990ed46ff3d8986e5b0fb7ab2fb">WXLUA_TNIL</a> : <span class="keywordflow">return</span> LUA_TNIL;
  1385. <a name="l01356"></a>01356 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a458b772ab1522825ff3199d8fba34df7">WXLUA_TBOOLEAN</a> : <span class="keywordflow">return</span> LUA_TBOOLEAN;
  1386. <a name="l01357"></a>01357 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#af997ec3f0137737b21fa6eb91aca9529">WXLUA_TLIGHTUSERDATA</a> : <span class="keywordflow">return</span> LUA_TLIGHTUSERDATA;
  1387. <a name="l01358"></a>01358 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#ab722ed662e4f3b7f2624d9a71f5c5817">WXLUA_TNUMBER</a> : <span class="keywordflow">return</span> LUA_TNUMBER;
  1388. <a name="l01359"></a>01359 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a2e521227720c7b42b9fe076b1e944405">WXLUA_TSTRING</a> : <span class="keywordflow">return</span> LUA_TSTRING;
  1389. <a name="l01360"></a>01360 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#ab80aed8ef4eafc8ab9479e39597330ff">WXLUA_TTABLE</a> : <span class="keywordflow">return</span> LUA_TTABLE;
  1390. <a name="l01361"></a>01361 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#ad1ad6ff2d60457dfb1251faede683dd7">WXLUA_TFUNCTION</a> : <span class="keywordflow">return</span> LUA_TFUNCTION;
  1391. <a name="l01362"></a>01362 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#af70988ad845289f3b60451dce70d9622">WXLUA_TUSERDATA</a> : <span class="keywordflow">return</span> LUA_TUSERDATA;
  1392. <a name="l01363"></a>01363 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#af26c97cbb42bdb22bc85a245bd93c6a4">WXLUA_TTHREAD</a> : <span class="keywordflow">return</span> LUA_TTHREAD;
  1393. <a name="l01364"></a>01364 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a58050f86cf4136d7b81371ac367313c0">WXLUA_TINTEGER</a> : <span class="keywordflow">return</span> LUA_TNUMBER;
  1394. <a name="l01365"></a>01365 <span class="keywordflow">case</span> <a class="code" href="wxlbind_8h.html#a53115f4dba53cf577b8fd547b9ac874c">WXLUA_TCFUNCTION</a> : <span class="keywordflow">return</span> LUA_TFUNCTION;
  1395. <a name="l01366"></a>01366 }
  1396. <a name="l01367"></a>01367
  1397. <a name="l01368"></a>01368 <span class="keywordflow">return</span> -1;
  1398. <a name="l01369"></a>01369 }
  1399. <a name="l01370"></a>01370
  1400. <a name="l01371"></a><a class="code" href="wxlstate_8cpp.html#a4c0ece81cd5c2a156feeda8d71e3e0f8">01371</a> <span class="keywordtype">bool</span> <a class="code" href="wxlstate_8h.html#a4c0ece81cd5c2a156feeda8d71e3e0f8">wxlua_iswxstringtype</a>(lua_State* L, <span class="keywordtype">int</span> stack_idx)
  1401. <a name="l01372"></a>01372 {
  1402. <a name="l01373"></a>01373 <span class="comment">// NOTE: If we ever allow numbers to be coerced to strings we must</span>
  1403. <a name="l01374"></a>01374 <span class="comment">// change how we handle lua_tostring() calls since it will change a number</span>
  1404. <a name="l01375"></a>01375 <span class="comment">// to a string on the stack. This could break people&#39;s code.</span>
  1405. <a name="l01376"></a>01376 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a47f2034cabf94ca87dde758af863f4e2">wxlua_iswxluatype</a>(lua_type(L, stack_idx), <a class="code" href="wxlbind_8h.html#a2e521227720c7b42b9fe076b1e944405">WXLUA_TSTRING</a>) == 1)
  1406. <a name="l01377"></a>01377 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  1407. <a name="l01378"></a>01378 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a00a4b27cd869a94a2edb49866accd10a">wxlua_iswxuserdata</a>(L, stack_idx))
  1408. <a name="l01379"></a>01379 {
  1409. <a name="l01380"></a>01380 <span class="keywordtype">int</span> wxl_type = <a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(L, stack_idx);
  1410. <a name="l01381"></a>01381 <span class="keywordflow">return</span> (<a class="code" href="wxlstate_8h.html#a1a5e4f51c5902cbd8e3047f7a99b871d">wxluaT_isderivedtype</a>(L, wxl_type, *<a class="code" href="wxlbind_8cpp.html#a4d788db68e87954d09dd58ea30df0cd3">p_wxluatype_wxString</a>) &gt;= 0);
  1411. <a name="l01382"></a>01382 }
  1412. <a name="l01383"></a>01383
  1413. <a name="l01384"></a>01384 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  1414. <a name="l01385"></a>01385 }
  1415. <a name="l01386"></a>01386
  1416. <a name="l01387"></a><a class="code" href="wxlstate_8cpp.html#aa15baee6edd4446f22cf1c393a1843a3">01387</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* LUACALL <a class="code" href="wxlstate_8h.html#aa15baee6edd4446f22cf1c393a1843a3">wxlua_getstringtype</a>(lua_State *L, <span class="keywordtype">int</span> stack_idx)
  1417. <a name="l01388"></a>01388 {
  1418. <a name="l01389"></a>01389 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a608577522e6393650240dddfba01d8b4">wxlua_isstringtype</a>(L, stack_idx))
  1419. <a name="l01390"></a>01390 <span class="keywordflow">return</span> lua_tostring(L, stack_idx);
  1420. <a name="l01391"></a>01391 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a00a4b27cd869a94a2edb49866accd10a">wxlua_iswxuserdata</a>(L, stack_idx))
  1421. <a name="l01392"></a>01392 {
  1422. <a name="l01393"></a>01393 <span class="keywordtype">int</span> stack_type = <a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(L, stack_idx);
  1423. <a name="l01394"></a>01394
  1424. <a name="l01395"></a>01395 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a1a5e4f51c5902cbd8e3047f7a99b871d">wxluaT_isderivedtype</a>(L, stack_type, *<a class="code" href="wxlbind_8cpp.html#a4d788db68e87954d09dd58ea30df0cd3">p_wxluatype_wxString</a>) &gt;= 0)
  1425. <a name="l01396"></a>01396 {
  1426. <a name="l01397"></a>01397 wxString* wxstr = (wxString*)<a class="code" href="wxlstate_8h.html#ac5a0a65665274df59adbed667480e93e">wxlua_touserdata</a>(L, stack_idx, <span class="keyword">false</span>);
  1427. <a name="l01398"></a>01398 wxCHECK_MSG(wxstr, NULL, wxT(<span class="stringliteral">&quot;Invalid userdata wxString&quot;</span>));
  1428. <a name="l01399"></a>01399 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a41976a7549ef4bfa7e9a1147dc7b4d55">wx2lua</a>(*wxstr);
  1429. <a name="l01400"></a>01400 }
  1430. <a name="l01401"></a>01401 }
  1431. <a name="l01402"></a>01402
  1432. <a name="l01403"></a>01403 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;a &#39;string&#39; or &#39;wxString&#39;&quot;</span>));
  1433. <a name="l01404"></a>01404
  1434. <a name="l01405"></a>01405 <span class="keywordflow">return</span> NULL;
  1435. <a name="l01406"></a>01406 }
  1436. <a name="l01407"></a>01407
  1437. <a name="l01408"></a><a class="code" href="wxlstate_8cpp.html#abaad17f1e38dd7397d597ed0cbc1c4ef">01408</a> wxString LUACALL <a class="code" href="wxlstate_8h.html#abaad17f1e38dd7397d597ed0cbc1c4ef">wxlua_getwxStringtype</a>(lua_State *L, <span class="keywordtype">int</span> stack_idx)
  1438. <a name="l01409"></a>01409 {
  1439. <a name="l01410"></a>01410 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a608577522e6393650240dddfba01d8b4">wxlua_isstringtype</a>(L, stack_idx))
  1440. <a name="l01411"></a>01411 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(lua_tostring(L, stack_idx));
  1441. <a name="l01412"></a>01412 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a00a4b27cd869a94a2edb49866accd10a">wxlua_iswxuserdata</a>(L, stack_idx))
  1442. <a name="l01413"></a>01413 {
  1443. <a name="l01414"></a>01414 <span class="keywordtype">int</span> stack_type = <a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(L, stack_idx);
  1444. <a name="l01415"></a>01415
  1445. <a name="l01416"></a>01416 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a1a5e4f51c5902cbd8e3047f7a99b871d">wxluaT_isderivedtype</a>(L, stack_type, *<a class="code" href="wxlbind_8cpp.html#a4d788db68e87954d09dd58ea30df0cd3">p_wxluatype_wxString</a>) &gt;= 0)
  1446. <a name="l01417"></a>01417 {
  1447. <a name="l01418"></a>01418 wxString* wxstr = (wxString*)<a class="code" href="wxlstate_8h.html#ac5a0a65665274df59adbed667480e93e">wxlua_touserdata</a>(L, stack_idx, <span class="keyword">false</span>);
  1448. <a name="l01419"></a>01419 wxCHECK_MSG(wxstr, wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid userdata wxString&quot;</span>));
  1449. <a name="l01420"></a>01420 <span class="keywordflow">return</span> *wxstr;
  1450. <a name="l01421"></a>01421 }
  1451. <a name="l01422"></a>01422 }
  1452. <a name="l01423"></a>01423
  1453. <a name="l01424"></a>01424 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;a &#39;string&#39; or &#39;wxString&#39;&quot;</span>));
  1454. <a name="l01425"></a>01425
  1455. <a name="l01426"></a>01426 <span class="keywordflow">return</span> wxEmptyString;
  1456. <a name="l01427"></a>01427 }
  1457. <a name="l01428"></a>01428
  1458. <a name="l01429"></a><a class="code" href="wxlstate_8cpp.html#a77238c0018900d9c06b0163fa202c21d">01429</a> <span class="keywordtype">bool</span> LUACALL <a class="code" href="wxlstate_8h.html#a77238c0018900d9c06b0163fa202c21d">wxlua_getbooleantype</a>(lua_State *L, <span class="keywordtype">int</span> stack_idx)
  1459. <a name="l01430"></a>01430 {
  1460. <a name="l01431"></a>01431 <span class="keywordtype">int</span> l_type = lua_type(L, stack_idx);
  1461. <a name="l01432"></a>01432
  1462. <a name="l01433"></a>01433 <span class="keywordflow">if</span> (!<a class="code" href="wxlstate_8h.html#a47f2034cabf94ca87dde758af863f4e2">wxlua_iswxluatype</a>(l_type, <a class="code" href="wxlbind_8h.html#a458b772ab1522825ff3199d8fba34df7">WXLUA_TBOOLEAN</a>))
  1463. <a name="l01434"></a>01434 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;a &#39;boolean&#39;&quot;</span>));
  1464. <a name="l01435"></a>01435
  1465. <a name="l01436"></a>01436 <span class="keywordtype">int</span> num = 0;
  1466. <a name="l01437"></a>01437 <span class="comment">// we also allow 0 = false and !0 = true (Lua thinks 0 == true, i.e. !nil)</span>
  1467. <a name="l01438"></a>01438 <span class="keywordflow">if</span> (l_type == LUA_TNUMBER)
  1468. <a name="l01439"></a>01439 num = (int)lua_tonumber(L, stack_idx);
  1469. <a name="l01440"></a>01440 <span class="keywordflow">else</span>
  1470. <a name="l01441"></a>01441 num = (int)lua_toboolean(L, stack_idx);
  1471. <a name="l01442"></a>01442
  1472. <a name="l01443"></a>01443 <span class="keywordflow">return</span> (num != 0);
  1473. <a name="l01444"></a>01444 }
  1474. <a name="l01445"></a><a class="code" href="wxlstate_8cpp.html#ab1921d0ee1911ca14ecf141891f90ae5">01445</a> <span class="keywordtype">long</span> LUACALL <a class="code" href="wxlstate_8h.html#ab1921d0ee1911ca14ecf141891f90ae5">wxlua_getenumtype</a>(lua_State *L, <span class="keywordtype">int</span> stack_idx)
  1475. <a name="l01446"></a>01446 {
  1476. <a name="l01447"></a>01447 <span class="keywordtype">int</span> l_type = lua_type(L, stack_idx);
  1477. <a name="l01448"></a>01448
  1478. <a name="l01449"></a>01449 <span class="keywordflow">if</span> (!<a class="code" href="wxlstate_8h.html#a47f2034cabf94ca87dde758af863f4e2">wxlua_iswxluatype</a>(l_type, <a class="code" href="wxlbind_8h.html#a58050f86cf4136d7b81371ac367313c0">WXLUA_TINTEGER</a>))
  1479. <a name="l01450"></a>01450 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;an &#39;integer enum&#39;&quot;</span>));
  1480. <a name="l01451"></a>01451
  1481. <a name="l01452"></a>01452 <span class="comment">// we don&#39;t allow bool or round, enums must strictly be integers</span>
  1482. <a name="l01453"></a>01453 <span class="keywordtype">double</span> value = lua_tonumber(L, stack_idx);
  1483. <a name="l01454"></a>01454 <span class="keywordtype">long</span> long_value = (long)value;
  1484. <a name="l01455"></a>01455
  1485. <a name="l01456"></a>01456 <span class="keywordflow">if</span> (value != long_value)
  1486. <a name="l01457"></a>01457 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;an &#39;integer enum&#39;&quot;</span>));
  1487. <a name="l01458"></a>01458
  1488. <a name="l01459"></a>01459 <span class="keywordflow">return</span> long_value;
  1489. <a name="l01460"></a>01460 }
  1490. <a name="l01461"></a><a class="code" href="wxlstate_8cpp.html#a5b0ffce73ad80800d0b756e49d31bf0e">01461</a> <span class="keywordtype">long</span> LUACALL <a class="code" href="wxlstate_8h.html#a5b0ffce73ad80800d0b756e49d31bf0e">wxlua_getintegertype</a>(lua_State *L, <span class="keywordtype">int</span> stack_idx)
  1491. <a name="l01462"></a>01462 {
  1492. <a name="l01463"></a>01463 <span class="keywordtype">int</span> l_type = lua_type(L, stack_idx);
  1493. <a name="l01464"></a>01464
  1494. <a name="l01465"></a>01465 <span class="keywordflow">if</span> (!<a class="code" href="wxlstate_8h.html#a47f2034cabf94ca87dde758af863f4e2">wxlua_iswxluatype</a>(l_type, <a class="code" href="wxlbind_8h.html#a58050f86cf4136d7b81371ac367313c0">WXLUA_TINTEGER</a>))
  1495. <a name="l01466"></a>01466 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;an &#39;integer&#39;&quot;</span>));
  1496. <a name="l01467"></a>01467
  1497. <a name="l01468"></a>01468 <span class="keywordtype">double</span> value = 0;
  1498. <a name="l01469"></a>01469 <span class="comment">// we also allow bool = 1/0 which Lua evaluates to nil in lua_tonumber</span>
  1499. <a name="l01470"></a>01470 <span class="keywordflow">if</span> (l_type == LUA_TBOOLEAN)
  1500. <a name="l01471"></a>01471 value = lua_toboolean(L, stack_idx) ? 1 : 0;
  1501. <a name="l01472"></a>01472 <span class="keywordflow">else</span>
  1502. <a name="l01473"></a>01473 value = lua_tonumber(L, stack_idx);
  1503. <a name="l01474"></a>01474
  1504. <a name="l01475"></a>01475 <span class="keywordtype">long</span> long_value = (long)value;
  1505. <a name="l01476"></a>01476
  1506. <a name="l01477"></a>01477 <span class="keywordflow">if</span> (value != long_value)
  1507. <a name="l01478"></a>01478 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;an &#39;integer&#39;&quot;</span>));
  1508. <a name="l01479"></a>01479
  1509. <a name="l01480"></a>01480 <span class="keywordflow">return</span> long_value;
  1510. <a name="l01481"></a>01481 }
  1511. <a name="l01482"></a><a class="code" href="wxlstate_8cpp.html#ae108d14d839d23da917b0ce2d24c5363">01482</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> LUACALL <a class="code" href="wxlstate_8h.html#ae108d14d839d23da917b0ce2d24c5363">wxlua_getuintegertype</a>(lua_State *L, <span class="keywordtype">int</span> stack_idx)
  1512. <a name="l01483"></a>01483 {
  1513. <a name="l01484"></a>01484 <span class="keywordtype">int</span> l_type = lua_type(L, stack_idx);
  1514. <a name="l01485"></a>01485
  1515. <a name="l01486"></a>01486 <span class="keywordflow">if</span> (!<a class="code" href="wxlstate_8h.html#a47f2034cabf94ca87dde758af863f4e2">wxlua_iswxluatype</a>(l_type, <a class="code" href="wxlbind_8h.html#a58050f86cf4136d7b81371ac367313c0">WXLUA_TINTEGER</a>))
  1516. <a name="l01487"></a>01487 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;an &#39;unsigned integer&#39;&quot;</span>));
  1517. <a name="l01488"></a>01488
  1518. <a name="l01489"></a>01489 <span class="keywordtype">double</span> value = 0;
  1519. <a name="l01490"></a>01490 <span class="comment">// we also allow bool = 1/0 which Lua evaluates to nil in lua_tonumber</span>
  1520. <a name="l01491"></a>01491 <span class="keywordflow">if</span> (l_type == LUA_TBOOLEAN)
  1521. <a name="l01492"></a>01492 value = lua_toboolean(L, stack_idx) ? 1 : 0;
  1522. <a name="l01493"></a>01493 <span class="keywordflow">else</span>
  1523. <a name="l01494"></a>01494 value = lua_tonumber(L, stack_idx);
  1524. <a name="l01495"></a>01495
  1525. <a name="l01496"></a>01496 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> ulong_value = (<span class="keywordtype">unsigned</span> long)value;
  1526. <a name="l01497"></a>01497
  1527. <a name="l01498"></a>01498 <span class="keywordflow">if</span> ((value != ulong_value) || (value &lt; 0))
  1528. <a name="l01499"></a>01499 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;an &#39;unsigned integer&#39;&quot;</span>));
  1529. <a name="l01500"></a>01500
  1530. <a name="l01501"></a>01501 <span class="keywordflow">return</span> ulong_value;
  1531. <a name="l01502"></a>01502 }
  1532. <a name="l01503"></a><a class="code" href="wxlstate_8cpp.html#a7e0788737b729042ceddba8b630b4e53">01503</a> <span class="keywordtype">double</span> LUACALL <a class="code" href="wxlstate_8h.html#a7e0788737b729042ceddba8b630b4e53">wxlua_getnumbertype</a>(lua_State *L, <span class="keywordtype">int</span> stack_idx)
  1533. <a name="l01504"></a>01504 {
  1534. <a name="l01505"></a>01505 <span class="keywordtype">int</span> l_type = lua_type(L, stack_idx);
  1535. <a name="l01506"></a>01506
  1536. <a name="l01507"></a>01507 <span class="keywordflow">if</span> (!<a class="code" href="wxlstate_8h.html#a47f2034cabf94ca87dde758af863f4e2">wxlua_iswxluatype</a>(l_type, <a class="code" href="wxlbind_8h.html#ab722ed662e4f3b7f2624d9a71f5c5817">WXLUA_TNUMBER</a>))
  1537. <a name="l01508"></a>01508 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;a &#39;number&#39;&quot;</span>));
  1538. <a name="l01509"></a>01509
  1539. <a name="l01510"></a>01510 <span class="keywordtype">double</span> value = 0;
  1540. <a name="l01511"></a>01511 <span class="comment">// we also allow bool = 1/0 which Lua evaluates to nil in lua_tonumber</span>
  1541. <a name="l01512"></a>01512 <span class="keywordflow">if</span> (l_type == LUA_TBOOLEAN)
  1542. <a name="l01513"></a>01513 value = lua_toboolean(L, stack_idx) ? 1 : 0;
  1543. <a name="l01514"></a>01514 <span class="keywordflow">else</span>
  1544. <a name="l01515"></a>01515 value = lua_tonumber(L, stack_idx);
  1545. <a name="l01516"></a>01516
  1546. <a name="l01517"></a>01517 <span class="keywordflow">return</span> value;
  1547. <a name="l01518"></a>01518 }
  1548. <a name="l01519"></a>01519
  1549. <a name="l01520"></a><a class="code" href="wxlstate_8cpp.html#ad3f311ca85fe28d4faf3f4dd81536a18">01520</a> <span class="keyword">const</span> <span class="keywordtype">char</span>** LUACALL <a class="code" href="wxlstate_8h.html#ad3f311ca85fe28d4faf3f4dd81536a18">wxlua_getchararray</a>(lua_State *L, <span class="keywordtype">int</span> stack_idx, <span class="keywordtype">int</span> &amp;count)
  1550. <a name="l01521"></a>01521 {
  1551. <a name="l01522"></a>01522 <span class="keyword">const</span> <span class="keywordtype">char</span> **arrChar = NULL;
  1552. <a name="l01523"></a>01523 count = 0;
  1553. <a name="l01524"></a>01524
  1554. <a name="l01525"></a>01525 <span class="keywordflow">if</span> (lua_istable(L, stack_idx))
  1555. <a name="l01526"></a>01526 {
  1556. <a name="l01527"></a>01527 <span class="keywordtype">int</span> table_len = lua_objlen(L, stack_idx);
  1557. <a name="l01528"></a>01528 <span class="keywordflow">if</span> (table_len &gt; 0)
  1558. <a name="l01529"></a>01529 arrChar = <span class="keyword">new</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *[table_len];
  1559. <a name="l01530"></a>01530
  1560. <a name="l01531"></a>01531 <span class="keywordflow">if</span> (arrChar != NULL)
  1561. <a name="l01532"></a>01532 {
  1562. <a name="l01533"></a>01533 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n = 0; n &lt; table_len; ++n)
  1563. <a name="l01534"></a>01534 {
  1564. <a name="l01535"></a>01535 lua_rawgeti(L, stack_idx, n+1); <span class="comment">// Lua array starts at 1</span>
  1565. <a name="l01536"></a>01536 <span class="keyword">const</span> <span class="keywordtype">char</span> *s = <a class="code" href="wxlstate_8h.html#aa15baee6edd4446f22cf1c393a1843a3">wxlua_getstringtype</a>(L, -1);
  1566. <a name="l01537"></a>01537 arrChar[n] = s; <span class="comment">// share Lua string</span>
  1567. <a name="l01538"></a>01538 lua_pop(L, 1);
  1568. <a name="l01539"></a>01539 }
  1569. <a name="l01540"></a>01540 }
  1570. <a name="l01541"></a>01541
  1571. <a name="l01542"></a>01542 count = table_len;
  1572. <a name="l01543"></a>01543 }
  1573. <a name="l01544"></a>01544 <span class="keywordflow">else</span>
  1574. <a name="l01545"></a>01545 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;a &#39;table&#39; array of strings&quot;</span>));
  1575. <a name="l01546"></a>01546
  1576. <a name="l01547"></a>01547 <span class="keywordflow">return</span> arrChar;
  1577. <a name="l01548"></a>01548 }
  1578. <a name="l01549"></a>01549
  1579. <a name="l01550"></a><a class="code" href="wxlstate_8cpp.html#a9d0af8f1eee0d4615751565f3f2fa393">01550</a> wxString* LUACALL <a class="code" href="wxlstate_8h.html#a9d0af8f1eee0d4615751565f3f2fa393">wxlua_getwxStringarray</a>(lua_State* L, <span class="keywordtype">int</span> stack_idx, <span class="keywordtype">int</span>&amp; count)
  1580. <a name="l01551"></a>01551 {
  1581. <a name="l01552"></a>01552 wxString *strArray = NULL;
  1582. <a name="l01553"></a>01553 count = 0; <span class="comment">// zero it in case we do a long jmp</span>
  1583. <a name="l01554"></a>01554 <a class="code" href="classwxLuaSmartwxArrayString.html">wxLuaSmartwxArrayString</a> arr(<a class="code" href="wxlstate_8h.html#a0cf1f6516b7828d8f58e8fca47b0751d">wxlua_getwxArrayString</a>(L, stack_idx));
  1584. <a name="l01555"></a>01555
  1585. <a name="l01556"></a>01556 count = (int)((wxArrayString&amp;)arr).GetCount();
  1586. <a name="l01557"></a>01557 strArray = <span class="keyword">new</span> wxString[count];
  1587. <a name="l01558"></a>01558 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n = 0; n &lt; count; ++n)
  1588. <a name="l01559"></a>01559 strArray[n] = ((wxArrayString&amp;)arr)[n];
  1589. <a name="l01560"></a>01560
  1590. <a name="l01561"></a>01561 <span class="keywordflow">return</span> strArray;
  1591. <a name="l01562"></a>01562 }
  1592. <a name="l01563"></a>01563
  1593. <a name="l01564"></a><a class="code" href="wxlstate_8cpp.html#a608c006132ed91d53ce42a4221de285f">01564</a> <span class="keywordtype">int</span>* LUACALL <a class="code" href="wxlstate_8h.html#a608c006132ed91d53ce42a4221de285f">wxlua_getintarray</a>(lua_State* L, <span class="keywordtype">int</span> stack_idx, <span class="keywordtype">int</span>&amp; count)
  1594. <a name="l01565"></a>01565 {
  1595. <a name="l01566"></a>01566 <span class="keywordtype">int</span> *intArray = NULL;
  1596. <a name="l01567"></a>01567 count = 0; <span class="comment">// zero it in case we do a long jmp</span>
  1597. <a name="l01568"></a>01568 <a class="code" href="classwxLuaSmartwxArrayInt.html">wxLuaSmartwxArrayInt</a> arr(<a class="code" href="wxlstate_8h.html#a1d55c218b354f79810dbe96a5adf96a8">wxlua_getwxArrayInt</a>(L, stack_idx));
  1598. <a name="l01569"></a>01569
  1599. <a name="l01570"></a>01570 count = (int)((wxArrayInt&amp;)arr).GetCount();
  1600. <a name="l01571"></a>01571 intArray = <span class="keyword">new</span> <span class="keywordtype">int</span>[count];
  1601. <a name="l01572"></a>01572 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n = 0; n &lt; count; ++n)
  1602. <a name="l01573"></a>01573 intArray[n] = ((wxArrayInt&amp;)arr)[n];
  1603. <a name="l01574"></a>01574
  1604. <a name="l01575"></a>01575 <span class="keywordflow">return</span> intArray;
  1605. <a name="l01576"></a>01576 }
  1606. <a name="l01577"></a>01577
  1607. <a name="l01578"></a><a class="code" href="wxlstate_8cpp.html#a0cf1f6516b7828d8f58e8fca47b0751d">01578</a> <a class="code" href="classwxLuaSmartwxArrayString.html">wxLuaSmartwxArrayString</a> LUACALL <a class="code" href="wxlstate_8h.html#a0cf1f6516b7828d8f58e8fca47b0751d">wxlua_getwxArrayString</a>(lua_State* L, <span class="keywordtype">int</span> stack_idx)
  1608. <a name="l01579"></a>01579 {
  1609. <a name="l01580"></a>01580 <a class="code" href="classwxLuaSmartwxArrayString.html">wxLuaSmartwxArrayString</a> arr(NULL, <span class="keyword">true</span>); <span class="comment">// will added to or replaced</span>
  1610. <a name="l01581"></a>01581 <span class="keywordtype">int</span> count = -1; <span class="comment">// used to check for failure</span>
  1611. <a name="l01582"></a>01582
  1612. <a name="l01583"></a>01583 <span class="keywordflow">if</span> (lua_istable(L, stack_idx))
  1613. <a name="l01584"></a>01584 {
  1614. <a name="l01585"></a>01585 count = 0;
  1615. <a name="l01586"></a>01586
  1616. <a name="l01587"></a>01587 <span class="keywordflow">while</span> (1)
  1617. <a name="l01588"></a>01588 {
  1618. <a name="l01589"></a>01589 lua_rawgeti(L, stack_idx, count+1);
  1619. <a name="l01590"></a>01590
  1620. <a name="l01591"></a>01591 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a4c0ece81cd5c2a156feeda8d71e3e0f8">wxlua_iswxstringtype</a>(L, -1))
  1621. <a name="l01592"></a>01592 {
  1622. <a name="l01593"></a>01593 ((wxArrayString&amp;)arr).Add(<a class="code" href="wxlstate_8h.html#abaad17f1e38dd7397d597ed0cbc1c4ef">wxlua_getwxStringtype</a>(L, -1));
  1623. <a name="l01594"></a>01594 ++count;
  1624. <a name="l01595"></a>01595
  1625. <a name="l01596"></a>01596 lua_pop(L, 1);
  1626. <a name="l01597"></a>01597 }
  1627. <a name="l01598"></a>01598 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (lua_isnil(L, -1))
  1628. <a name="l01599"></a>01599 {
  1629. <a name="l01600"></a>01600 lua_pop(L, 1);
  1630. <a name="l01601"></a>01601 <span class="keywordflow">break</span>;
  1631. <a name="l01602"></a>01602 }
  1632. <a name="l01603"></a>01603 <span class="keywordflow">else</span>
  1633. <a name="l01604"></a>01604 {
  1634. <a name="l01605"></a>01605 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;a &#39;wxArrayString&#39; or table array of strings&quot;</span>));
  1635. <a name="l01606"></a>01606 <span class="keywordflow">return</span> arr;
  1636. <a name="l01607"></a>01607 }
  1637. <a name="l01608"></a>01608 }
  1638. <a name="l01609"></a>01609 }
  1639. <a name="l01610"></a>01610 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a00a4b27cd869a94a2edb49866accd10a">wxlua_iswxuserdata</a>(L, stack_idx))
  1640. <a name="l01611"></a>01611 {
  1641. <a name="l01612"></a>01612 <span class="keywordtype">int</span> arrstr_wxltype = <a class="code" href="wxlstate_8h.html#a44d205938ab4c0eaacaea1d58face217">wxluaT_gettype</a>(L, <span class="stringliteral">&quot;wxArrayString&quot;</span>);
  1642. <a name="l01613"></a>01613
  1643. <a name="l01614"></a>01614 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a1602757335e28069aa1d9416a5c53ac2">wxluaT_isuserdatatype</a>(L, stack_idx, arrstr_wxltype))
  1644. <a name="l01615"></a>01615 {
  1645. <a name="l01616"></a>01616 wxArrayString *arrStr = (wxArrayString *)<a class="code" href="wxlstate_8h.html#a4b840fe9dc39ed3114a3c4b271507335">wxluaT_getuserdatatype</a>(L, stack_idx, arrstr_wxltype);
  1646. <a name="l01617"></a>01617 <span class="keywordflow">if</span> (arrStr)
  1647. <a name="l01618"></a>01618 {
  1648. <a name="l01619"></a>01619 arr = <a class="code" href="classwxLuaSmartwxArrayString.html">wxLuaSmartwxArrayString</a>(arrStr, <span class="keyword">false</span>); <span class="comment">// replace</span>
  1649. <a name="l01620"></a>01620 count = arrStr-&gt;GetCount();
  1650. <a name="l01621"></a>01621 }
  1651. <a name="l01622"></a>01622 }
  1652. <a name="l01623"></a>01623 }
  1653. <a name="l01624"></a>01624
  1654. <a name="l01625"></a>01625 <span class="keywordflow">if</span> (count &lt; 0)
  1655. <a name="l01626"></a>01626 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;a &#39;wxArrayString&#39; or table array of strings&quot;</span>));
  1656. <a name="l01627"></a>01627
  1657. <a name="l01628"></a>01628 <span class="keywordflow">return</span> arr;
  1658. <a name="l01629"></a>01629 }
  1659. <a name="l01630"></a>01630
  1660. <a name="l01631"></a><a class="code" href="wxlstate_8cpp.html#a48c3f8a2da56e596561547086a5b6d5e">01631</a> <a class="code" href="classwxLuaSmartwxSortedArrayString.html">wxLuaSmartwxSortedArrayString</a> LUACALL <a class="code" href="wxlstate_8h.html#a48c3f8a2da56e596561547086a5b6d5e">wxlua_getwxSortedArrayString</a>(lua_State* L, <span class="keywordtype">int</span> stack_idx)
  1661. <a name="l01632"></a>01632 {
  1662. <a name="l01633"></a>01633 <a class="code" href="classwxLuaSmartwxSortedArrayString.html">wxLuaSmartwxSortedArrayString</a> arr(NULL, <span class="keyword">true</span>); <span class="comment">// will be replaced</span>
  1663. <a name="l01634"></a>01634 <span class="keywordtype">int</span> count = -1; <span class="comment">// used to check for failure</span>
  1664. <a name="l01635"></a>01635
  1665. <a name="l01636"></a>01636 <span class="keywordflow">if</span> (lua_istable(L, stack_idx))
  1666. <a name="l01637"></a>01637 {
  1667. <a name="l01638"></a>01638 <a class="code" href="classwxLuaSmartwxArrayString.html">wxLuaSmartwxArrayString</a> a = <a class="code" href="wxlstate_8h.html#a0cf1f6516b7828d8f58e8fca47b0751d">wxlua_getwxArrayString</a>(L, stack_idx);
  1668. <a name="l01639"></a>01639 arr = <a class="code" href="classwxLuaSmartwxSortedArrayString.html">wxLuaSmartwxSortedArrayString</a>(<span class="keyword">new</span> wxSortedArrayString(a), <span class="keyword">true</span>);
  1669. <a name="l01640"></a>01640 count = 0;
  1670. <a name="l01641"></a>01641 }
  1671. <a name="l01642"></a>01642 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a00a4b27cd869a94a2edb49866accd10a">wxlua_iswxuserdata</a>(L, stack_idx))
  1672. <a name="l01643"></a>01643 {
  1673. <a name="l01644"></a>01644 <span class="keywordtype">int</span> arrstr_wxltype = <a class="code" href="wxlstate_8h.html#a44d205938ab4c0eaacaea1d58face217">wxluaT_gettype</a>(L, <span class="stringliteral">&quot;wxArrayString&quot;</span>);
  1674. <a name="l01645"></a>01645
  1675. <a name="l01646"></a>01646 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a1602757335e28069aa1d9416a5c53ac2">wxluaT_isuserdatatype</a>(L, stack_idx, arrstr_wxltype))
  1676. <a name="l01647"></a>01647 {
  1677. <a name="l01648"></a>01648 wxSortedArrayString *arrStr = (wxSortedArrayString *)<a class="code" href="wxlstate_8h.html#a4b840fe9dc39ed3114a3c4b271507335">wxluaT_getuserdatatype</a>(L, stack_idx, arrstr_wxltype);
  1678. <a name="l01649"></a>01649 <span class="keywordflow">if</span> (arrStr)
  1679. <a name="l01650"></a>01650 {
  1680. <a name="l01651"></a>01651 arr = <a class="code" href="classwxLuaSmartwxSortedArrayString.html">wxLuaSmartwxSortedArrayString</a>(arrStr, <span class="keyword">false</span>); <span class="comment">// replace</span>
  1681. <a name="l01652"></a>01652 count = arrStr-&gt;GetCount();
  1682. <a name="l01653"></a>01653 }
  1683. <a name="l01654"></a>01654 }
  1684. <a name="l01655"></a>01655 }
  1685. <a name="l01656"></a>01656
  1686. <a name="l01657"></a>01657 <span class="keywordflow">if</span> (count &lt; 0)
  1687. <a name="l01658"></a>01658 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;a &#39;wxArrayString&#39; or table array of strings&quot;</span>));
  1688. <a name="l01659"></a>01659
  1689. <a name="l01660"></a>01660 <span class="keywordflow">return</span> arr;
  1690. <a name="l01661"></a>01661 }
  1691. <a name="l01662"></a>01662
  1692. <a name="l01663"></a><a class="code" href="wxlstate_8cpp.html#a1d55c218b354f79810dbe96a5adf96a8">01663</a> <a class="code" href="classwxLuaSmartwxArrayInt.html">wxLuaSmartwxArrayInt</a> LUACALL <a class="code" href="wxlstate_8h.html#a1d55c218b354f79810dbe96a5adf96a8">wxlua_getwxArrayInt</a>(lua_State* L, <span class="keywordtype">int</span> stack_idx)
  1693. <a name="l01664"></a>01664 {
  1694. <a name="l01665"></a>01665 <a class="code" href="classwxLuaSmartwxArrayInt.html">wxLuaSmartwxArrayInt</a> arr(NULL, <span class="keyword">true</span>); <span class="comment">// will be replaced</span>
  1695. <a name="l01666"></a>01666 <span class="keywordtype">int</span> count = -1; <span class="comment">// used to check for failure</span>
  1696. <a name="l01667"></a>01667
  1697. <a name="l01668"></a>01668 <span class="keywordflow">if</span> (lua_istable(L, stack_idx))
  1698. <a name="l01669"></a>01669 {
  1699. <a name="l01670"></a>01670 count = 0;
  1700. <a name="l01671"></a>01671
  1701. <a name="l01672"></a>01672 <span class="keywordflow">while</span>(1)
  1702. <a name="l01673"></a>01673 {
  1703. <a name="l01674"></a>01674 lua_rawgeti(L, stack_idx, count+1);
  1704. <a name="l01675"></a>01675
  1705. <a name="l01676"></a>01676 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a49a0718d6216af2f681197473f206e36">wxlua_isnumbertype</a>(L, -1))
  1706. <a name="l01677"></a>01677 {
  1707. <a name="l01678"></a>01678 ((wxArrayInt&amp;)arr).Add((<span class="keywordtype">int</span>)lua_tonumber(L, -1));
  1708. <a name="l01679"></a>01679 ++count;
  1709. <a name="l01680"></a>01680
  1710. <a name="l01681"></a>01681 lua_pop(L, 1);
  1711. <a name="l01682"></a>01682 }
  1712. <a name="l01683"></a>01683 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (lua_isnil(L, -1))
  1713. <a name="l01684"></a>01684 {
  1714. <a name="l01685"></a>01685 lua_pop(L, 1);
  1715. <a name="l01686"></a>01686 <span class="keywordflow">break</span>;
  1716. <a name="l01687"></a>01687 }
  1717. <a name="l01688"></a>01688 <span class="keywordflow">else</span>
  1718. <a name="l01689"></a>01689 {
  1719. <a name="l01690"></a>01690 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;a &#39;wxArrayInt&#39; or a table array of integers&quot;</span>));
  1720. <a name="l01691"></a>01691 <span class="keywordflow">return</span> arr;
  1721. <a name="l01692"></a>01692 }
  1722. <a name="l01693"></a>01693 }
  1723. <a name="l01694"></a>01694 }
  1724. <a name="l01695"></a>01695 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a00a4b27cd869a94a2edb49866accd10a">wxlua_iswxuserdata</a>(L, stack_idx))
  1725. <a name="l01696"></a>01696 {
  1726. <a name="l01697"></a>01697 <span class="keywordtype">int</span> arrint_wxltype = <a class="code" href="wxlstate_8h.html#a44d205938ab4c0eaacaea1d58face217">wxluaT_gettype</a>(L, <span class="stringliteral">&quot;wxArrayInt&quot;</span>);
  1727. <a name="l01698"></a>01698
  1728. <a name="l01699"></a>01699 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a1602757335e28069aa1d9416a5c53ac2">wxluaT_isuserdatatype</a>(L, stack_idx, arrint_wxltype))
  1729. <a name="l01700"></a>01700 {
  1730. <a name="l01701"></a>01701 wxArrayInt *arrInt = (wxArrayInt *)<a class="code" href="wxlstate_8h.html#a4b840fe9dc39ed3114a3c4b271507335">wxluaT_getuserdatatype</a>(L, stack_idx, arrint_wxltype);
  1731. <a name="l01702"></a>01702 <span class="keywordflow">if</span> (arrInt)
  1732. <a name="l01703"></a>01703 {
  1733. <a name="l01704"></a>01704 arr = <a class="code" href="classwxLuaSmartwxArrayInt.html">wxLuaSmartwxArrayInt</a>(arrInt, <span class="keyword">false</span>); <span class="comment">// replace</span>
  1734. <a name="l01705"></a>01705 count = arrInt-&gt;GetCount();
  1735. <a name="l01706"></a>01706 }
  1736. <a name="l01707"></a>01707 }
  1737. <a name="l01708"></a>01708 }
  1738. <a name="l01709"></a>01709
  1739. <a name="l01710"></a>01710 <span class="keywordflow">if</span> (count &lt; 0)
  1740. <a name="l01711"></a>01711 <a class="code" href="wxlstate_8h.html#aba05dfc5f8a48e264d7463a7c6fee965">wxlua_argerror</a>(L, stack_idx, wxT(<span class="stringliteral">&quot;a &#39;wxArrayInt&#39; or a table array of integers&quot;</span>));
  1741. <a name="l01712"></a>01712
  1742. <a name="l01713"></a>01713 <span class="keywordflow">return</span> arr;
  1743. <a name="l01714"></a>01714 }
  1744. <a name="l01715"></a>01715
  1745. <a name="l01716"></a>01716
  1746. <a name="l01717"></a><a class="code" href="wxlstate_8cpp.html#a4fae9b1e2b6a0669ddb701581edf24c7">01717</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlstate_8h.html#a4fae9b1e2b6a0669ddb701581edf24c7">wxlua_pushwxArrayStringtable</a>(lua_State *L, <span class="keyword">const</span> wxArrayString &amp;strArray)
  1747. <a name="l01718"></a>01718 {
  1748. <a name="l01719"></a>01719 <span class="keywordtype">size_t</span> idx, count = strArray.GetCount();
  1749. <a name="l01720"></a>01720 lua_createtable(L, count, 0);
  1750. <a name="l01721"></a>01721
  1751. <a name="l01722"></a>01722 <span class="keywordflow">for</span> (idx = 0; idx &lt; count; ++idx)
  1752. <a name="l01723"></a>01723 {
  1753. <a name="l01724"></a>01724 <a class="code" href="wxlstate_8h.html#ab5978d0116530dd0844a50120988771f">wxlua_pushwxString</a>(L, strArray[idx]);
  1754. <a name="l01725"></a>01725 lua_rawseti(L, -2, idx + 1);
  1755. <a name="l01726"></a>01726 }
  1756. <a name="l01727"></a>01727 <span class="keywordflow">return</span> idx;
  1757. <a name="l01728"></a>01728 }
  1758. <a name="l01729"></a>01729
  1759. <a name="l01730"></a><a class="code" href="wxlstate_8cpp.html#a75ae92f66c6689bad6470f689a7d190d">01730</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlstate_8h.html#a75ae92f66c6689bad6470f689a7d190d">wxlua_pushwxArrayInttable</a>(lua_State *L, <span class="keyword">const</span> wxArrayInt &amp;intArray)
  1760. <a name="l01731"></a>01731 {
  1761. <a name="l01732"></a>01732 <span class="keywordtype">size_t</span> idx, count = intArray.GetCount();
  1762. <a name="l01733"></a>01733 lua_createtable(L, count, 0);
  1763. <a name="l01734"></a>01734
  1764. <a name="l01735"></a>01735 <span class="keywordflow">for</span> (idx = 0; idx &lt; count; ++idx)
  1765. <a name="l01736"></a>01736 {
  1766. <a name="l01737"></a>01737 lua_pushnumber(L, intArray[idx]);
  1767. <a name="l01738"></a>01738 lua_rawseti(L, -2, idx + 1);
  1768. <a name="l01739"></a>01739 }
  1769. <a name="l01740"></a>01740 <span class="keywordflow">return</span> idx;
  1770. <a name="l01741"></a>01741 }
  1771. <a name="l01742"></a>01742
  1772. <a name="l01743"></a><a class="code" href="wxlstate_8cpp.html#ab5978d0116530dd0844a50120988771f">01743</a> <span class="keywordtype">void</span> LUACALL <a class="code" href="wxlstate_8h.html#ab5978d0116530dd0844a50120988771f">wxlua_pushwxString</a>(lua_State* L, <span class="keyword">const</span> wxString&amp; str)
  1773. <a name="l01744"></a>01744 {
  1774. <a name="l01745"></a>01745 lua_pushstring(L, <a class="code" href="wxlstate_8h.html#a41976a7549ef4bfa7e9a1147dc7b4d55">wx2lua</a>(str));
  1775. <a name="l01746"></a>01746 }
  1776. <a name="l01747"></a>01747
  1777. <a name="l01748"></a><a class="code" href="wxlstate_8cpp.html#ad8947416ca8b4d46a677d47769723837">01748</a> wxString <a class="code" href="wxlstate_8h.html#ab9470cf3e371887731d92e912a085319">wxlua_concatwxArrayString</a>(<span class="keyword">const</span> wxArrayString&amp; arr, <span class="keyword">const</span> wxString&amp; sep)
  1778. <a name="l01749"></a>01749 {
  1779. <a name="l01750"></a>01750 wxString s;
  1780. <a name="l01751"></a>01751 <span class="keywordtype">size_t</span> n, count = arr.GetCount();
  1781. <a name="l01752"></a>01752 <span class="keywordflow">for</span> (n = 0; n &lt; count; ++n)
  1782. <a name="l01753"></a>01753 {
  1783. <a name="l01754"></a>01754 s += arr[n];
  1784. <a name="l01755"></a>01755 <span class="keywordflow">if</span> (n &lt; count - 1) s += sep;
  1785. <a name="l01756"></a>01756 }
  1786. <a name="l01757"></a>01757
  1787. <a name="l01758"></a>01758 <span class="keywordflow">return</span> s;
  1788. <a name="l01759"></a>01759 }
  1789. <a name="l01760"></a>01760
  1790. <a name="l01761"></a><a class="code" href="wxlstate_8cpp.html#aaf858c7e146ec726f175df7c78e42a68">01761</a> <span class="keywordtype">int</span> <a class="code" href="wxlstate_8h.html#aaf858c7e146ec726f175df7c78e42a68">wxlua_pushargs</a>(lua_State* L, wxChar **argv, <span class="keywordtype">int</span> argc, <span class="keywordtype">int</span> start_n)
  1791. <a name="l01762"></a>01762 {
  1792. <a name="l01763"></a>01763 <span class="keywordflow">if</span> (argc == 0) <span class="keywordflow">return</span> 0;
  1793. <a name="l01764"></a>01764
  1794. <a name="l01765"></a>01765 <span class="keywordtype">int</span> i = 0;
  1795. <a name="l01766"></a>01766 <span class="keywordtype">int</span> narg = argc - (start_n + 1); <span class="comment">// number of arguments to the script</span>
  1796. <a name="l01767"></a>01767 luaL_checkstack(L, narg + 3, <span class="stringliteral">&quot;too many arguments to script&quot;</span>);
  1797. <a name="l01768"></a>01768 <span class="keywordflow">for</span> (i = start_n+1; i &lt; argc; i++)
  1798. <a name="l01769"></a>01769 lua_pushstring(L, <a class="code" href="wxlstate_8h.html#a41976a7549ef4bfa7e9a1147dc7b4d55">wx2lua</a>(argv[i]));
  1799. <a name="l01770"></a>01770
  1800. <a name="l01771"></a>01771 lua_createtable(L, narg, start_n + 1);
  1801. <a name="l01772"></a>01772
  1802. <a name="l01773"></a>01773 <span class="keywordflow">for</span> (i = 0; i &lt; argc; i++)
  1803. <a name="l01774"></a>01774 {
  1804. <a name="l01775"></a>01775 lua_pushstring(L, <a class="code" href="wxlstate_8h.html#a41976a7549ef4bfa7e9a1147dc7b4d55">wx2lua</a>(argv[i]));
  1805. <a name="l01776"></a>01776 lua_rawseti(L, -2, i - start_n);
  1806. <a name="l01777"></a>01777 }
  1807. <a name="l01778"></a>01778
  1808. <a name="l01779"></a>01779 lua_setglobal(L, <span class="stringliteral">&quot;arg&quot;</span>);
  1809. <a name="l01780"></a>01780
  1810. <a name="l01781"></a>01781 <span class="keywordflow">return</span> narg;
  1811. <a name="l01782"></a>01782 }
  1812. <a name="l01783"></a>01783
  1813. <a name="l01784"></a>01784 <span class="comment">//----------------------------------------------------------------------------</span>
  1814. <a name="l01785"></a>01785 <span class="comment">// Derived class member functions for classes in wxLua</span>
  1815. <a name="l01786"></a>01786 <span class="comment">//----------------------------------------------------------------------------</span>
  1816. <a name="l01787"></a>01787
  1817. <a name="l01788"></a><a class="code" href="wxlstate_8cpp.html#a1110e8f522280bc418efc5ec47ef585c">01788</a> <span class="keywordtype">bool</span> LUACALL <a class="code" href="wxlstate_8h.html#a1110e8f522280bc418efc5ec47ef585c">wxlua_setderivedmethod</a>(lua_State* L, <span class="keywordtype">void</span> *obj_ptr, <span class="keyword">const</span> <span class="keywordtype">char</span> *method_name, <a class="code" href="classwxLuaObject.html">wxLuaObject</a>* wxlObj)
  1818. <a name="l01789"></a>01789 {
  1819. <a name="l01790"></a>01790 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a274b8b7aae6f647e3e69d098962b7b1d">wxlua_lreg_derivedmethods_key</a>); <span class="comment">// push key</span>
  1820. <a name="l01791"></a>01791 lua_rawget( L, LUA_REGISTRYINDEX ); <span class="comment">// pop key, push value (table)</span>
  1821. <a name="l01792"></a>01792
  1822. <a name="l01793"></a>01793 lua_pushlightuserdata(L, (<span class="keywordtype">void</span> *)obj_ptr); <span class="comment">// push key</span>
  1823. <a name="l01794"></a>01794 lua_rawget(L, -2); <span class="comment">// get t[key] = value, pop key push value</span>
  1824. <a name="l01795"></a>01795
  1825. <a name="l01796"></a>01796 <span class="keywordflow">if</span> (!lua_istable(L, -1))
  1826. <a name="l01797"></a>01797 {
  1827. <a name="l01798"></a>01798 lua_pop(L, 1); <span class="comment">// pop nil value</span>
  1828. <a name="l01799"></a>01799
  1829. <a name="l01800"></a>01800 <span class="comment">// add new table for this object</span>
  1830. <a name="l01801"></a>01801 lua_pushlightuserdata(L, (<span class="keywordtype">void</span> *)obj_ptr); <span class="comment">// push key</span>
  1831. <a name="l01802"></a>01802 lua_newtable(L); <span class="comment">// push value</span>
  1832. <a name="l01803"></a>01803 lua_rawset(L, -3); <span class="comment">// set t[key] = value; pops key and value</span>
  1833. <a name="l01804"></a>01804
  1834. <a name="l01805"></a>01805 <span class="comment">// put the new table back on the top of the stack</span>
  1835. <a name="l01806"></a>01806 lua_pushlightuserdata(L, (<span class="keywordtype">void</span> *)obj_ptr);
  1836. <a name="l01807"></a>01807 lua_rawget(L, -2);
  1837. <a name="l01808"></a>01808 }
  1838. <a name="l01809"></a>01809 <span class="keywordflow">else</span>
  1839. <a name="l01810"></a>01810 {
  1840. <a name="l01811"></a>01811 <span class="comment">// see if there already is a method</span>
  1841. <a name="l01812"></a>01812 lua_pushstring( L, method_name );
  1842. <a name="l01813"></a>01813 lua_rawget(L, -2);
  1843. <a name="l01814"></a>01814
  1844. <a name="l01815"></a>01815 <span class="keywordflow">if</span> (lua_islightuserdata(L, -1))
  1845. <a name="l01816"></a>01816 {
  1846. <a name="l01817"></a>01817 <span class="comment">// already have a method, delete it before replacing it</span>
  1847. <a name="l01818"></a>01818 <a class="code" href="classwxLuaObject.html">wxLuaObject</a>* o = (<a class="code" href="classwxLuaObject.html">wxLuaObject</a>*)lua_touserdata( L, -1 );
  1848. <a name="l01819"></a>01819 <span class="keyword">delete</span> o;
  1849. <a name="l01820"></a>01820 }
  1850. <a name="l01821"></a>01821
  1851. <a name="l01822"></a>01822 lua_pop(L, 1); <span class="comment">// pop the deleted old object, or nil</span>
  1852. <a name="l01823"></a>01823 }
  1853. <a name="l01824"></a>01824
  1854. <a name="l01825"></a>01825 lua_pushstring( L, method_name ); <span class="comment">// push key</span>
  1855. <a name="l01826"></a>01826 lua_pushlightuserdata(L, (<span class="keywordtype">void</span>*)wxlObj); <span class="comment">// push value</span>
  1856. <a name="l01827"></a>01827 lua_rawset(L, -3); <span class="comment">// set t[key] = value; pops key and value</span>
  1857. <a name="l01828"></a>01828
  1858. <a name="l01829"></a>01829 lua_pop(L, 2); <span class="comment">// pop the object and overridden function table</span>
  1859. <a name="l01830"></a>01830
  1860. <a name="l01831"></a>01831 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  1861. <a name="l01832"></a>01832 }
  1862. <a name="l01833"></a><a class="code" href="wxlstate_8cpp.html#a602bc60e4737a25c6202d86c7c2f6c2b">01833</a> <span class="keywordtype">bool</span> LUACALL <a class="code" href="wxlstate_8h.html#a602bc60e4737a25c6202d86c7c2f6c2b">wxlua_hasderivedmethod</a>(lua_State* L, <span class="keywordtype">void</span> *obj_ptr, <span class="keyword">const</span> <span class="keywordtype">char</span> *method_name, <span class="keywordtype">bool</span> push_method)
  1863. <a name="l01834"></a>01834 {
  1864. <a name="l01835"></a>01835 <span class="keywordtype">bool</span> found = <span class="keyword">false</span>;
  1865. <a name="l01836"></a>01836 <a class="code" href="classwxLuaObject.html">wxLuaObject</a>* wxlObj = NULL;
  1866. <a name="l01837"></a>01837
  1867. <a name="l01838"></a>01838 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a274b8b7aae6f647e3e69d098962b7b1d">wxlua_lreg_derivedmethods_key</a>);
  1868. <a name="l01839"></a>01839 lua_rawget( L, LUA_REGISTRYINDEX ); <span class="comment">// pop key, push table</span>
  1869. <a name="l01840"></a>01840
  1870. <a name="l01841"></a>01841 lua_pushlightuserdata(L, (<span class="keywordtype">void</span> *)obj_ptr);
  1871. <a name="l01842"></a>01842 lua_rawget(L, -2); <span class="comment">// pop key, push table or nil</span>
  1872. <a name="l01843"></a>01843
  1873. <a name="l01844"></a>01844 <span class="keywordflow">if</span> (lua_istable(L, -1))
  1874. <a name="l01845"></a>01845 {
  1875. <a name="l01846"></a>01846 <span class="comment">// see if there is a method with the same name</span>
  1876. <a name="l01847"></a>01847 lua_pushstring( L, method_name );
  1877. <a name="l01848"></a>01848 lua_rawget(L, -2);
  1878. <a name="l01849"></a>01849
  1879. <a name="l01850"></a>01850 <span class="keywordflow">if</span> (lua_islightuserdata(L, -1))
  1880. <a name="l01851"></a>01851 wxlObj = (<a class="code" href="classwxLuaObject.html">wxLuaObject</a>*)lua_touserdata( L, -1 );
  1881. <a name="l01852"></a>01852
  1882. <a name="l01853"></a>01853 lua_pop(L, 1); <span class="comment">// pop the method object or nil</span>
  1883. <a name="l01854"></a>01854 }
  1884. <a name="l01855"></a>01855
  1885. <a name="l01856"></a>01856 lua_pop(L, 2); <span class="comment">// pop registry table and object table or nil</span>
  1886. <a name="l01857"></a>01857
  1887. <a name="l01858"></a>01858 <span class="keywordflow">if</span> (wxlObj != NULL)
  1888. <a name="l01859"></a>01859 {
  1889. <a name="l01860"></a>01860 <span class="comment">// if we&#39;ve got the object, put it on top of the stack</span>
  1890. <a name="l01861"></a>01861 <span class="keywordflow">if</span> (push_method &amp;&amp; wxlObj-&gt;<a class="code" href="classwxLuaObject.html#a69d337ef87de7bde2aecb8abda72a627">GetObject</a>())
  1891. <a name="l01862"></a>01862 found = <span class="keyword">true</span>;
  1892. <a name="l01863"></a>01863 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!push_method)
  1893. <a name="l01864"></a>01864 found = <span class="keyword">true</span>;
  1894. <a name="l01865"></a>01865 }
  1895. <a name="l01866"></a>01866
  1896. <a name="l01867"></a>01867 <span class="keywordflow">return</span> found;
  1897. <a name="l01868"></a>01868 }
  1898. <a name="l01869"></a><a class="code" href="wxlstate_8cpp.html#abfb64621a5e2ba46114e81a28731c79f">01869</a> <span class="keywordtype">bool</span> LUACALL <a class="code" href="wxlstate_8h.html#abfb64621a5e2ba46114e81a28731c79f">wxlua_removederivedmethods</a>(lua_State* L, <span class="keywordtype">void</span> *obj_ptr)
  1899. <a name="l01870"></a>01870 {
  1900. <a name="l01871"></a>01871 <span class="keywordtype">bool</span> found = <span class="keyword">false</span>;
  1901. <a name="l01872"></a>01872
  1902. <a name="l01873"></a>01873 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a274b8b7aae6f647e3e69d098962b7b1d">wxlua_lreg_derivedmethods_key</a>);
  1903. <a name="l01874"></a>01874 lua_rawget( L, LUA_REGISTRYINDEX ); <span class="comment">// pop key, push table</span>
  1904. <a name="l01875"></a>01875
  1905. <a name="l01876"></a>01876 lua_pushlightuserdata(L, (<span class="keywordtype">void</span> *)obj_ptr);
  1906. <a name="l01877"></a>01877 lua_rawget(L, -2); <span class="comment">// pop key, push table or nil</span>
  1907. <a name="l01878"></a>01878
  1908. <a name="l01879"></a>01879 <span class="keywordflow">if</span> (lua_istable(L, -1))
  1909. <a name="l01880"></a>01880 {
  1910. <a name="l01881"></a>01881 found = <span class="keyword">true</span>;
  1911. <a name="l01882"></a>01882
  1912. <a name="l01883"></a>01883 <span class="comment">// delete all of the derived methods we&#39;ve pushed</span>
  1913. <a name="l01884"></a>01884 lua_pushnil(L);
  1914. <a name="l01885"></a>01885 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
  1915. <a name="l01886"></a>01886 {
  1916. <a name="l01887"></a>01887 <span class="comment">// value at -1, key at -2, table at -3</span>
  1917. <a name="l01888"></a>01888 <span class="keywordflow">if</span> (lua_islightuserdata(L, -1))
  1918. <a name="l01889"></a>01889 {
  1919. <a name="l01890"></a>01890 <a class="code" href="classwxLuaObject.html">wxLuaObject</a>* o = (<a class="code" href="classwxLuaObject.html">wxLuaObject</a>*)lua_touserdata(L, -1);
  1920. <a name="l01891"></a>01891 <span class="keyword">delete</span> o;
  1921. <a name="l01892"></a>01892 }
  1922. <a name="l01893"></a>01893
  1923. <a name="l01894"></a>01894 lua_pop(L, 1); <span class="comment">// remove value; keep key for next iteration</span>
  1924. <a name="l01895"></a>01895 }
  1925. <a name="l01896"></a>01896
  1926. <a name="l01897"></a>01897 lua_pop(L, 1); <span class="comment">// pop the obj table</span>
  1927. <a name="l01898"></a>01898
  1928. <a name="l01899"></a>01899 lua_pushlightuserdata(L, (<span class="keywordtype">void</span> *)obj_ptr); <span class="comment">// push key</span>
  1929. <a name="l01900"></a>01900 lua_pushnil(L); <span class="comment">// push value, to remove it</span>
  1930. <a name="l01901"></a>01901 lua_rawset(L, -3); <span class="comment">// set t[key] = value; pop key and value</span>
  1931. <a name="l01902"></a>01902
  1932. <a name="l01903"></a>01903 lua_pop(L, 1); <span class="comment">// pop the derived table</span>
  1933. <a name="l01904"></a>01904 }
  1934. <a name="l01905"></a>01905 <span class="keywordflow">else</span>
  1935. <a name="l01906"></a>01906 lua_pop(L, 2); <span class="comment">// pop the derived table and nil for the obj table</span>
  1936. <a name="l01907"></a>01907
  1937. <a name="l01908"></a>01908 <span class="keywordflow">return</span> found;
  1938. <a name="l01909"></a>01909 }
  1939. <a name="l01910"></a>01910
  1940. <a name="l01911"></a>01911 <span class="comment">//----------------------------------------------------------------------------</span>
  1941. <a name="l01912"></a>01912 <span class="comment">// Other functions for wxLua&#39;s keys in the</span>
  1942. <a name="l01913"></a>01913 <span class="comment">//----------------------------------------------------------------------------</span>
  1943. <a name="l01914"></a>01914
  1944. <a name="l01915"></a><a class="code" href="wxlstate_8cpp.html#a99b292a455b84ee8f2f701ff3619d1f7">01915</a> <span class="keywordtype">bool</span> LUACALL <a class="code" href="wxlstate_8h.html#a99b292a455b84ee8f2f701ff3619d1f7">wxlua_getcallbaseclassfunction</a>(lua_State* L)
  1945. <a name="l01916"></a>01916 {
  1946. <a name="l01917"></a>01917 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a91d0a86787b3a1de5921590ce6a0b3e8">wxlua_lreg_callbaseclassfunc_key</a>);
  1947. <a name="l01918"></a>01918 lua_rawget( L, LUA_REGISTRYINDEX ); <span class="comment">// pop key, push bool</span>
  1948. <a name="l01919"></a>01919
  1949. <a name="l01920"></a>01920 <span class="keywordtype">bool</span> call_base = (bool)lua_toboolean(L, -1); <span class="comment">// nil == 0 too</span>
  1950. <a name="l01921"></a>01921 lua_pop(L, 1); <span class="comment">// pop bool</span>
  1951. <a name="l01922"></a>01922
  1952. <a name="l01923"></a>01923 <span class="keywordflow">return</span> call_base;
  1953. <a name="l01924"></a>01924 }
  1954. <a name="l01925"></a>01925
  1955. <a name="l01926"></a><a class="code" href="wxlstate_8cpp.html#a9d1c33c0999cd1ea92d9dafb83196fa8">01926</a> <span class="keywordtype">void</span> LUACALL <a class="code" href="wxlstate_8h.html#a9d1c33c0999cd1ea92d9dafb83196fa8">wxlua_setcallbaseclassfunction</a>(lua_State* L, <span class="keywordtype">bool</span> call_base)
  1956. <a name="l01927"></a>01927 {
  1957. <a name="l01928"></a>01928 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a91d0a86787b3a1de5921590ce6a0b3e8">wxlua_lreg_callbaseclassfunc_key</a>);
  1958. <a name="l01929"></a>01929 lua_pushboolean(L, call_base);
  1959. <a name="l01930"></a>01930 lua_rawset( L, LUA_REGISTRYINDEX ); <span class="comment">// pop key and bool</span>
  1960. <a name="l01931"></a>01931 }
  1961. <a name="l01932"></a>01932
  1962. <a name="l01933"></a><a class="code" href="wxlstate_8cpp.html#a5442b3e5a2f8dca8fb920c00279385ac">01933</a> wxEventType LUACALL <a class="code" href="wxlstate_8h.html#a5442b3e5a2f8dca8fb920c00279385ac">wxlua_getwxeventtype</a>(lua_State* L)
  1963. <a name="l01934"></a>01934 {
  1964. <a name="l01935"></a>01935 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#af24ccc441c899b3028cfc5d4099c739a">wxlua_lreg_wxeventtype_key</a>);
  1965. <a name="l01936"></a>01936 lua_rawget( L, LUA_REGISTRYINDEX ); <span class="comment">// pop key, push bool</span>
  1966. <a name="l01937"></a>01937
  1967. <a name="l01938"></a>01938 wxEventType evt_type = (wxEventType)lua_tonumber(L, -1);
  1968. <a name="l01939"></a>01939 lua_pop(L, 1); <span class="comment">// pop number</span>
  1969. <a name="l01940"></a>01940
  1970. <a name="l01941"></a>01941 <span class="keywordflow">return</span> evt_type;
  1971. <a name="l01942"></a>01942 }
  1972. <a name="l01943"></a>01943
  1973. <a name="l01944"></a><a class="code" href="wxlstate_8cpp.html#a3f5c8427ae033a7da28754a6e37acf0a">01944</a> <span class="keywordtype">void</span> LUACALL <a class="code" href="wxlstate_8h.html#a3f5c8427ae033a7da28754a6e37acf0a">wxlua_setwxeventtype</a>(lua_State* L, wxEventType evt_type)
  1974. <a name="l01945"></a>01945 {
  1975. <a name="l01946"></a>01946 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#af24ccc441c899b3028cfc5d4099c739a">wxlua_lreg_wxeventtype_key</a>);
  1976. <a name="l01947"></a>01947 lua_pushnumber(L, evt_type);
  1977. <a name="l01948"></a>01948 lua_rawset( L, LUA_REGISTRYINDEX ); <span class="comment">// pop key and number</span>
  1978. <a name="l01949"></a>01949 }
  1979. <a name="l01950"></a>01950
  1980. <a name="l01951"></a><a class="code" href="wxlstate_8cpp.html#a4c7701b4b056e2f84f380be559bb2482">01951</a> <a class="code" href="classwxLuaStateData.html">wxLuaStateData</a>* LUACALL <a class="code" href="wxlstate_8h.html#a4c7701b4b056e2f84f380be559bb2482">wxlua_getwxluastatedata</a>(lua_State* L)
  1981. <a name="l01952"></a>01952 {
  1982. <a name="l01953"></a>01953 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#aba1ad42faf08e4b50bca48b5ba9d8ece">wxlua_lreg_wxluastatedata_key</a>);
  1983. <a name="l01954"></a>01954 lua_rawget( L, LUA_REGISTRYINDEX ); <span class="comment">// pop key, push bool</span>
  1984. <a name="l01955"></a>01955
  1985. <a name="l01956"></a>01956 <a class="code" href="classwxLuaStateData.html">wxLuaStateData</a>* data = (<a class="code" href="classwxLuaStateData.html">wxLuaStateData</a>*)lua_touserdata(L, -1);
  1986. <a name="l01957"></a>01957 lua_pop(L, 1); <span class="comment">// pop udata</span>
  1987. <a name="l01958"></a>01958
  1988. <a name="l01959"></a>01959 <span class="keywordflow">return</span> data;
  1989. <a name="l01960"></a>01960 }
  1990. <a name="l01961"></a>01961
  1991. <a name="l01962"></a>01962 <span class="comment">// ----------------------------------------------------------------------------</span>
  1992. <a name="l01963"></a>01963 <span class="comment">// wxFindWindowByPointer - find a window by its pointer</span>
  1993. <a name="l01964"></a>01964 <span class="comment">// return NULL if doesn&#39;t exist, see wxFindWindowByID and wxFindWindowByLabel</span>
  1994. <a name="l01965"></a>01965 <span class="comment">// ----------------------------------------------------------------------------</span>
  1995. <a name="l01966"></a><a class="code" href="wxlstate_8cpp.html#a005a9ae62f4498c674a72a597160a0c0">01966</a> <span class="keyword">static</span> wxWindow *<a class="code" href="wxlstate_8cpp.html#a005a9ae62f4498c674a72a597160a0c0">wxFindWindowPointerRecursively</a>(<span class="keyword">const</span> wxWindow *parent, <span class="keyword">const</span> wxWindow *win)
  1996. <a name="l01967"></a>01967 {
  1997. <a name="l01968"></a>01968 wxCHECK_MSG(win, NULL, wxT(<span class="stringliteral">&quot;invalid window in wxFindWindowPointerRecursively&quot;</span>));
  1998. <a name="l01969"></a>01969
  1999. <a name="l01970"></a>01970 <span class="keywordflow">if</span> ( parent )
  2000. <a name="l01971"></a>01971 {
  2001. <a name="l01972"></a>01972 <span class="comment">// see if this is the one we&#39;re looking for</span>
  2002. <a name="l01973"></a>01973 <span class="keywordflow">if</span> ( parent == win )
  2003. <a name="l01974"></a>01974 <span class="keywordflow">return</span> (wxWindow*)win;
  2004. <a name="l01975"></a>01975
  2005. <a name="l01976"></a>01976 <span class="comment">// It wasn&#39;t, so check all its children</span>
  2006. <a name="l01977"></a>01977 <span class="keywordflow">for</span> ( wxWindowList::compatibility_iterator node = parent-&gt;GetChildren().GetFirst();
  2007. <a name="l01978"></a>01978 node;
  2008. <a name="l01979"></a>01979 node = node-&gt;GetNext() )
  2009. <a name="l01980"></a>01980 {
  2010. <a name="l01981"></a>01981 <span class="comment">// recursively check each child</span>
  2011. <a name="l01982"></a>01982 wxWindow *child_win = (wxWindow *)node-&gt;GetData();
  2012. <a name="l01983"></a>01983 wxWindow *retwin = <a class="code" href="wxlstate_8cpp.html#a005a9ae62f4498c674a72a597160a0c0">wxFindWindowPointerRecursively</a>(child_win, win);
  2013. <a name="l01984"></a>01984 <span class="keywordflow">if</span> (retwin)
  2014. <a name="l01985"></a>01985 <span class="keywordflow">return</span> retwin;
  2015. <a name="l01986"></a>01986 }
  2016. <a name="l01987"></a>01987 }
  2017. <a name="l01988"></a>01988
  2018. <a name="l01989"></a>01989 <span class="keywordflow">return</span> NULL; <span class="comment">// Not found</span>
  2019. <a name="l01990"></a>01990 }
  2020. <a name="l01991"></a>01991
  2021. <a name="l01992"></a>01992 <span class="comment">// Check to see if wxWidgets still thinks &quot;win&quot; is a valid window</span>
  2022. <a name="l01993"></a>01993 <span class="comment">// parent is the window to start with, if parent=NULL check all windows</span>
  2023. <a name="l01994"></a><a class="code" href="wxlstate_8cpp.html#a68714a92a573ca05e2e1efa1222c53a5">01994</a> <span class="keyword">static</span> wxWindow* <a class="code" href="wxlstate_8cpp.html#a68714a92a573ca05e2e1efa1222c53a5">wxFindWindowByPointer</a>(<span class="keyword">const</span> wxWindow *parent, <span class="keyword">const</span> wxWindow *win)
  2024. <a name="l01995"></a>01995 {
  2025. <a name="l01996"></a>01996 wxCHECK_MSG(win, NULL, wxT(<span class="stringliteral">&quot;Invalid window in wxFindWindowByPointer&quot;</span>));
  2026. <a name="l01997"></a>01997
  2027. <a name="l01998"></a>01998 <span class="keywordflow">if</span> ( parent )
  2028. <a name="l01999"></a>01999 {
  2029. <a name="l02000"></a>02000 <span class="comment">// just check parent and all its children</span>
  2030. <a name="l02001"></a>02001 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#a005a9ae62f4498c674a72a597160a0c0">wxFindWindowPointerRecursively</a>(parent, win);
  2031. <a name="l02002"></a>02002 }
  2032. <a name="l02003"></a>02003 <span class="comment">// start at very top of wx&#39;s windows</span>
  2033. <a name="l02004"></a>02004 <span class="keywordflow">for</span> ( wxWindowList::compatibility_iterator top_node = wxTopLevelWindows.GetFirst();
  2034. <a name="l02005"></a>02005 top_node;
  2035. <a name="l02006"></a>02006 top_node = top_node-&gt;GetNext() )
  2036. <a name="l02007"></a>02007 {
  2037. <a name="l02008"></a>02008 <span class="comment">// recursively check each window &amp; its children</span>
  2038. <a name="l02009"></a>02009 wxWindow *top_win = top_node-&gt;GetData();
  2039. <a name="l02010"></a>02010 wxWindow *retwin = <a class="code" href="wxlstate_8cpp.html#a005a9ae62f4498c674a72a597160a0c0">wxFindWindowPointerRecursively</a>(top_win, win);
  2040. <a name="l02011"></a>02011 <span class="keywordflow">if</span> (retwin)
  2041. <a name="l02012"></a>02012 <span class="keywordflow">return</span> retwin;
  2042. <a name="l02013"></a>02013 }
  2043. <a name="l02014"></a>02014
  2044. <a name="l02015"></a>02015 <span class="keywordflow">return</span> NULL; <span class="comment">// Not found</span>
  2045. <a name="l02016"></a>02016 }
  2046. <a name="l02017"></a>02017
  2047. <a name="l02018"></a>02018 <span class="comment">// ----------------------------------------------------------------------------</span>
  2048. <a name="l02019"></a>02019 <span class="comment">// wxLuaCleanupWindows - given a wxWindowList of wxWindows it runs wxFindWindowByPointer</span>
  2049. <a name="l02020"></a>02020 <span class="comment">// on it to remove dead pointers from the list if only_check=true or</span>
  2050. <a name="l02021"></a>02021 <span class="comment">// Destroy() the windows and remove them from the list if !only_check.</span>
  2051. <a name="l02022"></a>02022 <span class="comment">// Returns true if any windows are removed, i.e. the list has changed</span>
  2052. <a name="l02023"></a>02023 <span class="comment">// ----------------------------------------------------------------------------</span>
  2053. <a name="l02024"></a><a class="code" href="wxlstate_8cpp.html#aee3f23bcdaad403338f32516e4489796">02024</a> <span class="keywordtype">bool</span> <a class="code" href="wxlstate_8cpp.html#aee3f23bcdaad403338f32516e4489796">wxLuaCleanupWindows</a>(lua_State* L, <span class="keywordtype">bool</span> only_check)
  2054. <a name="l02025"></a>02025 {
  2055. <a name="l02026"></a>02026 wxCHECK_MSG(L, <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2056. <a name="l02027"></a>02027
  2057. <a name="l02028"></a>02028 <span class="keywordtype">bool</span> removed = <span class="keyword">false</span>;
  2058. <a name="l02029"></a>02029
  2059. <a name="l02030"></a>02030 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#aab2351a78a8949184e1910cc1f9e7463">wxlua_lreg_topwindows_key</a>); <span class="comment">// push key</span>
  2060. <a name="l02031"></a>02031 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  2061. <a name="l02032"></a>02032
  2062. <a name="l02033"></a>02033 <span class="keywordtype">bool</span> try_again = <span class="keyword">true</span>;
  2063. <a name="l02034"></a>02034
  2064. <a name="l02035"></a>02035 <span class="keywordflow">while</span> (try_again)
  2065. <a name="l02036"></a>02036 {
  2066. <a name="l02037"></a>02037 try_again = <span class="keyword">false</span>;
  2067. <a name="l02038"></a>02038
  2068. <a name="l02039"></a>02039 lua_pushnil(L);
  2069. <a name="l02040"></a>02040 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
  2070. <a name="l02041"></a>02041 {
  2071. <a name="l02042"></a>02042 <span class="comment">// value = -1, key = -2, table = -3</span>
  2072. <a name="l02043"></a>02043 wxWindow* win = (wxWindow*)lua_touserdata(L, -2);
  2073. <a name="l02044"></a>02044 wxCHECK_MSG(win, <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxWindow&quot;</span>));
  2074. <a name="l02045"></a>02045
  2075. <a name="l02046"></a>02046 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8cpp.html#a68714a92a573ca05e2e1efa1222c53a5">wxFindWindowByPointer</a>(NULL, win) == NULL)
  2076. <a name="l02047"></a>02047 {
  2077. <a name="l02048"></a>02048 <span class="comment">// simply remove dead window from the list</span>
  2078. <a name="l02049"></a>02049 removed = <span class="keyword">true</span>;
  2079. <a name="l02050"></a>02050 lua_pop(L, 1); <span class="comment">// pop value</span>
  2080. <a name="l02051"></a>02051
  2081. <a name="l02052"></a>02052 lua_pushvalue(L, -1); <span class="comment">// copy key for next iteration</span>
  2082. <a name="l02053"></a>02053 lua_pushnil(L);
  2083. <a name="l02054"></a>02054 lua_rawset(L, -4); <span class="comment">// set t[key] = nil to remove it</span>
  2084. <a name="l02055"></a>02055 }
  2085. <a name="l02056"></a>02056 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!only_check)
  2086. <a name="l02057"></a>02057 {
  2087. <a name="l02058"></a>02058 removed = <span class="keyword">true</span>;
  2088. <a name="l02059"></a>02059 <span class="keywordflow">if</span> (win-&gt;HasCapture())
  2089. <a name="l02060"></a>02060 win-&gt;ReleaseMouse();
  2090. <a name="l02061"></a>02061
  2091. <a name="l02062"></a>02062 <span class="comment">// release capture for children since we may be abruptly ending</span>
  2092. <a name="l02063"></a>02063 <span class="keywordflow">for</span> ( wxWindowList::compatibility_iterator childNode = win-&gt;GetChildren().GetFirst();
  2093. <a name="l02064"></a>02064 childNode;
  2094. <a name="l02065"></a>02065 childNode = childNode-&gt;GetNext() )
  2095. <a name="l02066"></a>02066 {
  2096. <a name="l02067"></a>02067 wxWindow *child = childNode-&gt;GetData();
  2097. <a name="l02068"></a>02068
  2098. <a name="l02069"></a>02069 lua_pushlightuserdata(L, child);
  2099. <a name="l02070"></a>02070 lua_pushnil(L);
  2100. <a name="l02071"></a>02071 lua_rawset(L, -5);
  2101. <a name="l02072"></a>02072
  2102. <a name="l02073"></a>02073 <span class="keywordflow">if</span> (child-&gt;HasCapture())
  2103. <a name="l02074"></a>02074 child-&gt;ReleaseMouse();
  2104. <a name="l02075"></a>02075 }
  2105. <a name="l02076"></a>02076
  2106. <a name="l02077"></a>02077 <span class="keywordflow">if</span> (!win-&gt;IsBeingDeleted())
  2107. <a name="l02078"></a>02078 {
  2108. <a name="l02079"></a>02079 <span class="keyword">delete</span> win;
  2109. <a name="l02080"></a>02080 }
  2110. <a name="l02081"></a>02081
  2111. <a name="l02082"></a>02082 <span class="comment">// wxLuaWindowDestroyHandler should destroy this node</span>
  2112. <a name="l02083"></a>02083 <span class="comment">// and also delete all the children and their nodes</span>
  2113. <a name="l02084"></a>02084 <span class="comment">// it&#39;s probably best to start from the top again</span>
  2114. <a name="l02085"></a>02085 lua_pop(L, 1); <span class="comment">// pop value</span>
  2115. <a name="l02086"></a>02086
  2116. <a name="l02087"></a>02087 lua_pushnil(L);
  2117. <a name="l02088"></a>02088 lua_rawset(L, -3); <span class="comment">// set t[key] = nil to remove it</span>
  2118. <a name="l02089"></a>02089
  2119. <a name="l02090"></a>02090 try_again = <span class="keyword">true</span>;
  2120. <a name="l02091"></a>02091 <span class="keywordflow">break</span>;
  2121. <a name="l02092"></a>02092 }
  2122. <a name="l02093"></a>02093 <span class="keywordflow">else</span>
  2123. <a name="l02094"></a>02094 lua_pop(L, 1); <span class="comment">// pop value, lua_next will pop key at end</span>
  2124. <a name="l02095"></a>02095 }
  2125. <a name="l02096"></a>02096 }
  2126. <a name="l02097"></a>02097
  2127. <a name="l02098"></a>02098 lua_pop(L, 1); <span class="comment">// pop table</span>
  2128. <a name="l02099"></a>02099
  2129. <a name="l02100"></a>02100 <span class="keywordflow">return</span> removed;
  2130. <a name="l02101"></a>02101 }
  2131. <a name="l02102"></a>02102
  2132. <a name="l02103"></a>02103 <span class="comment">//----------------------------------------------------------------------------</span>
  2133. <a name="l02104"></a>02104 <span class="comment">// wxLuaStateData</span>
  2134. <a name="l02105"></a>02105 <span class="comment">//----------------------------------------------------------------------------</span>
  2135. <a name="l02106"></a>02106
  2136. <a name="l02107"></a><a class="code" href="classwxLuaStateData.html#a9f2f75b8ba69061eed89585cf91a023e">02107</a> <a class="code" href="classwxLuaStateData.html#a9f2f75b8ba69061eed89585cf91a023e">wxLuaStateData::wxLuaStateData</a>()
  2137. <a name="l02108"></a>02108 :m_is_running(false),
  2138. <a name="l02109"></a>02109 m_is_closing(false),
  2139. <a name="l02110"></a>02110 m_lua_debug_hook_count(100), m_lua_debug_hook_yield(50),
  2140. <a name="l02111"></a>02111 m_lua_debug_hook(0), m_lua_debug_hook_send_evt(false),
  2141. <a name="l02112"></a>02112 m_last_debug_hook_time(0), m_debug_hook_break(false),
  2142. <a name="l02113"></a>02113 m_debug_hook_break_msg(wxT(<span class="stringliteral">&quot;Break&quot;</span>)),
  2143. <a name="l02114"></a>02114 m_evtHandler(NULL),
  2144. <a name="l02115"></a>02115 m_id(wxID_ANY)
  2145. <a name="l02116"></a>02116 {
  2146. <a name="l02117"></a>02117 }
  2147. <a name="l02118"></a>02118
  2148. <a name="l02119"></a><a class="code" href="classwxLuaStateData.html#a9c719b6b6d0108722c51fd8827f2f3c0">02119</a> <a class="code" href="classwxLuaStateData.html#a9c719b6b6d0108722c51fd8827f2f3c0">wxLuaStateData::~wxLuaStateData</a>()
  2149. <a name="l02120"></a>02120 {
  2150. <a name="l02121"></a>02121 <span class="comment">// no events here, the handler may already be gone</span>
  2151. <a name="l02122"></a>02122 <a class="code" href="classwxLuaStateData.html#aa6142d41d0fc7ce6cac933f84783859f">m_evtHandler</a> = NULL;
  2152. <a name="l02123"></a>02123 }
  2153. <a name="l02124"></a>02124
  2154. <a name="l02125"></a>02125 <span class="comment">//----------------------------------------------------------------------------</span>
  2155. <a name="l02126"></a>02126 <span class="comment">// wxLuaStateRefData</span>
  2156. <a name="l02127"></a>02127 <span class="comment">//----------------------------------------------------------------------------</span>
  2157. <a name="l02128"></a>02128
  2158. <a name="l02129"></a><a class="code" href="classwxLuaStateRefData.html#a8977b8fc4dc43aa99ce0fce992b1a918">02129</a> <a class="code" href="classwxLuaStateRefData.html#a8977b8fc4dc43aa99ce0fce992b1a918">wxLuaStateRefData::wxLuaStateRefData</a>(<span class="keywordtype">bool</span> create_data)
  2159. <a name="l02130"></a>02130 :m_lua_State(NULL),
  2160. <a name="l02131"></a>02131 m_lua_State_static(false),
  2161. <a name="l02132"></a>02132 m_lua_State_coroutine(false),
  2162. <a name="l02133"></a>02133 m_wxlStateData(NULL),
  2163. <a name="l02134"></a>02134 m_own_stateData(false)
  2164. <a name="l02135"></a>02135 {
  2165. <a name="l02136"></a>02136 <span class="keywordflow">if</span> (create_data)
  2166. <a name="l02137"></a>02137 {
  2167. <a name="l02138"></a>02138 <a class="code" href="classwxLuaStateRefData.html#a02dde1df32ae7c7749b63a829b12ed05">m_wxlStateData</a> = <span class="keyword">new</span> <a class="code" href="classwxLuaStateData.html">wxLuaStateData</a>();
  2168. <a name="l02139"></a>02139 <a class="code" href="classwxLuaStateRefData.html#acc0ef3bdd953f88a8506fa42de6e2120">m_own_stateData</a> = <span class="keyword">true</span>;
  2169. <a name="l02140"></a>02140 }
  2170. <a name="l02141"></a>02141 }
  2171. <a name="l02142"></a>02142
  2172. <a name="l02143"></a><a class="code" href="classwxLuaStateRefData.html#afa24a92b02c1eede4b7a446f75e45870">02143</a> <a class="code" href="classwxLuaStateRefData.html#afa24a92b02c1eede4b7a446f75e45870">wxLuaStateRefData::~wxLuaStateRefData</a>()
  2173. <a name="l02144"></a>02144 {
  2174. <a name="l02145"></a>02145 wxCHECK_RET((<a class="code" href="classwxLuaStateRefData.html#a6c977816cfdec8f29531e99e32ae2538">m_lua_State_static</a> == <span class="keyword">true</span>) || (<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a> == NULL),
  2175. <a name="l02146"></a>02146 wxT(<span class="stringliteral">&quot;You must ALWAYS call wxLuaState::Destroy and not wxObject::UnRef&quot;</span>));
  2176. <a name="l02147"></a>02147
  2177. <a name="l02148"></a>02148 <a class="code" href="classwxLuaStateRefData.html#aa6781f20d3b1fcb88ccf8ddf2ca44740">CloseLuaState</a>(<span class="keyword">true</span>);
  2178. <a name="l02149"></a>02149 <span class="keywordflow">if</span> (<a class="code" href="classwxLuaStateRefData.html#acc0ef3bdd953f88a8506fa42de6e2120">m_own_stateData</a>)
  2179. <a name="l02150"></a>02150 <span class="keyword">delete</span> <a class="code" href="classwxLuaStateRefData.html#a02dde1df32ae7c7749b63a829b12ed05">m_wxlStateData</a>;
  2180. <a name="l02151"></a>02151 }
  2181. <a name="l02152"></a>02152
  2182. <a name="l02153"></a><a class="code" href="classwxLuaStateRefData.html#aa6781f20d3b1fcb88ccf8ddf2ca44740">02153</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaStateRefData.html#aa6781f20d3b1fcb88ccf8ddf2ca44740">wxLuaStateRefData::CloseLuaState</a>(<span class="keywordtype">bool</span> force)
  2183. <a name="l02154"></a>02154 {
  2184. <a name="l02155"></a>02155 <span class="keywordflow">if</span> ((<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a> == NULL) || <a class="code" href="classwxLuaStateRefData.html#a02dde1df32ae7c7749b63a829b12ed05">m_wxlStateData</a>-&gt;<a class="code" href="classwxLuaStateData.html#ae5ffbed5dbd5df2cfbaf79d85758c482">m_is_closing</a> || <a class="code" href="classwxLuaStateRefData.html#a756bf884311f556e99ea2b4e71d9b725">m_lua_State_coroutine</a>)
  2185. <a name="l02156"></a>02156 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  2186. <a name="l02157"></a>02157
  2187. <a name="l02158"></a>02158 <a class="code" href="classwxLuaStateRefData.html#a02dde1df32ae7c7749b63a829b12ed05">m_wxlStateData</a>-&gt;<a class="code" href="classwxLuaStateData.html#ae5ffbed5dbd5df2cfbaf79d85758c482">m_is_closing</a> = <span class="keyword">true</span>;
  2188. <a name="l02159"></a>02159
  2189. <a name="l02160"></a>02160 <span class="comment">//wxCHECK_MSG(m_lua_State, false, wxT(&quot;Interpreter not created&quot;));</span>
  2190. <a name="l02161"></a>02161 <span class="comment">// wxCHECK_MSG(!m_is_running, false, wxT(&quot;Interpreter still running, can&#39;t destroy&quot;)); FIXME</span>
  2191. <a name="l02162"></a>02162
  2192. <a name="l02163"></a>02163 <span class="comment">// remove deleted windows first</span>
  2193. <a name="l02164"></a>02164 <a class="code" href="wxlstate_8cpp.html#aee3f23bcdaad403338f32516e4489796">wxLuaCleanupWindows</a>(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, <span class="keyword">true</span>);
  2194. <a name="l02165"></a>02165
  2195. <a name="l02166"></a>02166 <span class="comment">// are there still windows? ask to abort deleting them if !force</span>
  2196. <a name="l02167"></a>02167 <span class="keywordtype">bool</span> tlwindows_open = <span class="keyword">false</span>;
  2197. <a name="l02168"></a>02168 lua_pushlightuserdata(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, &amp;<a class="code" href="wxlstate_8h.html#aab2351a78a8949184e1910cc1f9e7463">wxlua_lreg_topwindows_key</a>); <span class="comment">// push key</span>
  2198. <a name="l02169"></a>02169 lua_rawget(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  2199. <a name="l02170"></a>02170
  2200. <a name="l02171"></a>02171 lua_pushnil(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>);
  2201. <a name="l02172"></a>02172 <span class="keywordflow">if</span> (lua_next(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, -2))
  2202. <a name="l02173"></a>02173 {
  2203. <a name="l02174"></a>02174 tlwindows_open = <span class="keyword">true</span>;
  2204. <a name="l02175"></a>02175 lua_pop(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, 3); <span class="comment">// pop key, value, table</span>
  2205. <a name="l02176"></a>02176 }
  2206. <a name="l02177"></a>02177 <span class="keywordflow">else</span>
  2207. <a name="l02178"></a>02178 lua_pop(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, 1); <span class="comment">// pop table</span>
  2208. <a name="l02179"></a>02179
  2209. <a name="l02180"></a>02180 <span class="keywordflow">if</span> (tlwindows_open)
  2210. <a name="l02181"></a>02181 {
  2211. <a name="l02182"></a>02182 <span class="keywordtype">int</span> ret = wxOK;
  2212. <a name="l02183"></a>02183
  2213. <a name="l02184"></a>02184 <span class="keywordflow">if</span> (!force)
  2214. <a name="l02185"></a>02185 {
  2215. <a name="l02186"></a>02186 ret = wxMessageBox(wxT(<span class="stringliteral">&quot;Windows are still open, would you like to delete them?&quot;</span>),
  2216. <a name="l02187"></a>02187 wxT(<span class="stringliteral">&quot;Delete existing windows?&quot;</span>), wxOK|wxCANCEL|wxICON_QUESTION);
  2217. <a name="l02188"></a>02188 }
  2218. <a name="l02189"></a>02189
  2219. <a name="l02190"></a>02190 <span class="keywordflow">if</span> (ret == wxCANCEL)
  2220. <a name="l02191"></a>02191 {
  2221. <a name="l02192"></a>02192 <a class="code" href="classwxLuaStateRefData.html#a02dde1df32ae7c7749b63a829b12ed05">m_wxlStateData</a>-&gt;<a class="code" href="classwxLuaStateData.html#ae5ffbed5dbd5df2cfbaf79d85758c482">m_is_closing</a> = <span class="keyword">false</span>;
  2222. <a name="l02193"></a>02193 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  2223. <a name="l02194"></a>02194 }
  2224. <a name="l02195"></a>02195
  2225. <a name="l02196"></a>02196 <span class="comment">//wxPrintf(wxT(&quot;Deleting windows\n&quot;));</span>
  2226. <a name="l02197"></a>02197
  2227. <a name="l02198"></a>02198 <span class="comment">// delete windows and their eventhandler since they delete the wxLuaEventCallbacks</span>
  2228. <a name="l02199"></a>02199 <span class="comment">// which require a lua_State</span>
  2229. <a name="l02200"></a>02200 <a class="code" href="wxlstate_8cpp.html#aee3f23bcdaad403338f32516e4489796">wxLuaCleanupWindows</a>(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, <span class="keyword">false</span>);
  2230. <a name="l02201"></a>02201 <span class="comment">// wait for wxWindow::Destroy() to really delete the windows</span>
  2231. <a name="l02202"></a>02202 <span class="comment">//wxYieldIfNeeded();</span>
  2232. <a name="l02203"></a>02203 }
  2233. <a name="l02204"></a>02204
  2234. <a name="l02205"></a>02205 <span class="comment">// clear the wxlua_lreg_wxluastatedata_key which we test for in the debug hook</span>
  2235. <a name="l02206"></a>02206 <span class="comment">// to know if the lua_State is being closed</span>
  2236. <a name="l02207"></a>02207 lua_pushlightuserdata(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, &amp;<a class="code" href="wxlstate_8h.html#aba1ad42faf08e4b50bca48b5ba9d8ece">wxlua_lreg_wxluastatedata_key</a>);
  2237. <a name="l02208"></a>02208 lua_pushnil(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>);
  2238. <a name="l02209"></a>02209 lua_rawset( <a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, LUA_REGISTRYINDEX ); <span class="comment">// pop key, push bool</span>
  2239. <a name="l02210"></a>02210
  2240. <a name="l02211"></a>02211 <a class="code" href="classwxLuaStateRefData.html#a9fae13fa0b450175d418506f8db20fe2">ClearCallbacks</a>();
  2241. <a name="l02212"></a>02212
  2242. <a name="l02213"></a>02213 <span class="comment">/*</span>
  2243. <a name="l02214"></a>02214 <span class="comment"> // Let the Lua garbage collector do it for shutdown.</span>
  2244. <a name="l02215"></a>02215 <span class="comment"></span>
  2245. <a name="l02216"></a>02216 <span class="comment"> // Delete all the wxObject data</span>
  2246. <a name="l02217"></a>02217 <span class="comment"> lua_pushlightuserdata(m_lua_State, &amp;wxlua_lreg_gcobjects_key);</span>
  2247. <a name="l02218"></a>02218 <span class="comment"> lua_rawget(m_lua_State, LUA_REGISTRYINDEX);</span>
  2248. <a name="l02219"></a>02219 <span class="comment"></span>
  2249. <a name="l02220"></a>02220 <span class="comment"> lua_pushnil(m_lua_State);</span>
  2250. <a name="l02221"></a>02221 <span class="comment"> while (lua_next(m_lua_State, -2) != 0)</span>
  2251. <a name="l02222"></a>02222 <span class="comment"> {</span>
  2252. <a name="l02223"></a>02223 <span class="comment"> // value = -1, key = -2, table = -3</span>
  2253. <a name="l02224"></a>02224 <span class="comment"> wxObject* o = (wxObject*)lua_touserdata(m_lua_State, -1); // delete object not key</span>
  2254. <a name="l02225"></a>02225 <span class="comment"> delete o;</span>
  2255. <a name="l02226"></a>02226 <span class="comment"></span>
  2256. <a name="l02227"></a>02227 <span class="comment"> lua_pop(m_lua_State, 1); // pop value, lua_next will pop key at end</span>
  2257. <a name="l02228"></a>02228 <span class="comment"> }</span>
  2258. <a name="l02229"></a>02229 <span class="comment"></span>
  2259. <a name="l02230"></a>02230 <span class="comment"> lua_pop(m_lua_State, 1); // pop table</span>
  2260. <a name="l02231"></a>02231 <span class="comment"></span>
  2261. <a name="l02232"></a>02232 <span class="comment"> // remove table since we&#39;ve deleted everything in it</span>
  2262. <a name="l02233"></a>02233 <span class="comment"> lua_pushlightuserdata(m_lua_State, &amp;wxlua_lreg_gcobjects_key);</span>
  2263. <a name="l02234"></a>02234 <span class="comment"> lua_newtable(m_lua_State);</span>
  2264. <a name="l02235"></a>02235 <span class="comment"> lua_rawset(m_lua_State, LUA_REGISTRYINDEX);</span>
  2265. <a name="l02236"></a>02236 <span class="comment">*/</span>
  2266. <a name="l02237"></a>02237
  2267. <a name="l02238"></a>02238 <span class="comment">// remove refs table to try to clear memory gracefully</span>
  2268. <a name="l02239"></a>02239 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, &amp;<a class="code" href="wxlstate_8h.html#ac4ac0a3575fafde31e659ced85f69c4d">wxlua_lreg_refs_key</a>);
  2269. <a name="l02240"></a>02240 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, &amp;<a class="code" href="wxlstate_8h.html#a30c2d5556a4a278368b48fe0b7bb3fda">wxlua_lreg_debug_refs_key</a>);
  2270. <a name="l02241"></a>02241 <span class="comment">//wxlua_lreg_createtable(m_lua_State, &amp;wxlua_lreg_derivedmethods_key); // gc will delete them</span>
  2271. <a name="l02242"></a>02242
  2272. <a name="l02243"></a>02243 lua_gc(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, LUA_GCCOLLECT, 0); <span class="comment">// round up dead refs</span>
  2273. <a name="l02244"></a>02244
  2274. <a name="l02245"></a>02245 <span class="keywordflow">if</span> (!<a class="code" href="classwxLuaStateRefData.html#a6c977816cfdec8f29531e99e32ae2538">m_lua_State_static</a>)
  2275. <a name="l02246"></a>02246 lua_close(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>);
  2276. <a name="l02247"></a>02247
  2277. <a name="l02248"></a>02248 <span class="comment">// Clear out the wxLuaState we hashed, note it&#39;s not refed so we have</span>
  2278. <a name="l02249"></a>02249 <span class="comment">// NULL its ref data.</span>
  2279. <a name="l02250"></a>02250 <span class="comment">// Note: even though the lua_State is closed the pointer value is still good.</span>
  2280. <a name="l02251"></a>02251 <span class="comment">// The wxLuaState we pushed into the reg table is a light userdata so</span>
  2281. <a name="l02252"></a>02252 <span class="comment">// it didn&#39;t get deleted.</span>
  2282. <a name="l02253"></a>02253 wxHashMapLuaState::iterator it = <a class="code" href="classwxLuaState.html#ab8261cd3629c21d1cbaeb5a6e0777272">wxLuaState::s_wxHashMapLuaState</a>.find(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>);
  2283. <a name="l02254"></a>02254 <span class="keywordflow">if</span> (it != <a class="code" href="classwxLuaState.html#ab8261cd3629c21d1cbaeb5a6e0777272">wxLuaState::s_wxHashMapLuaState</a>.end())
  2284. <a name="l02255"></a>02255 {
  2285. <a name="l02256"></a>02256 <a class="code" href="classwxLuaState.html">wxLuaState</a>* wxlState = it-&gt;second;
  2286. <a name="l02257"></a>02257 wxlState-&gt;SetRefData(NULL);
  2287. <a name="l02258"></a>02258 <span class="keyword">delete</span> wxlState;
  2288. <a name="l02259"></a>02259 <a class="code" href="classwxLuaState.html#ab8261cd3629c21d1cbaeb5a6e0777272">wxLuaState::s_wxHashMapLuaState</a>.erase(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>);
  2289. <a name="l02260"></a>02260 }
  2290. <a name="l02261"></a>02261
  2291. <a name="l02262"></a>02262 <a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a> = NULL;
  2292. <a name="l02263"></a>02263
  2293. <a name="l02264"></a>02264 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  2294. <a name="l02265"></a>02265 }
  2295. <a name="l02266"></a>02266
  2296. <a name="l02267"></a><a class="code" href="classwxLuaStateRefData.html#a9fae13fa0b450175d418506f8db20fe2">02267</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaStateRefData.html#a9fae13fa0b450175d418506f8db20fe2">wxLuaStateRefData::ClearCallbacks</a>()
  2297. <a name="l02268"></a>02268 {
  2298. <a name="l02269"></a>02269 wxCHECK_RET(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, wxT(<span class="stringliteral">&quot;Invalid lua_State&quot;</span>));
  2299. <a name="l02270"></a>02270
  2300. <a name="l02271"></a>02271 lua_State* L = <a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>;
  2301. <a name="l02272"></a>02272
  2302. <a name="l02273"></a>02273 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a034985fb7df51670c3b6a024329496fa">wxlua_lreg_evtcallbacks_key</a>); <span class="comment">// push key</span>
  2303. <a name="l02274"></a>02274 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  2304. <a name="l02275"></a>02275
  2305. <a name="l02276"></a>02276 lua_pushnil(L);
  2306. <a name="l02277"></a>02277 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
  2307. <a name="l02278"></a>02278 {
  2308. <a name="l02279"></a>02279 <span class="comment">// value = -1, key = -2, table = -3</span>
  2309. <a name="l02280"></a>02280 <a class="code" href="classwxLuaEventCallback.html">wxLuaEventCallback</a>* cb = (<a class="code" href="classwxLuaEventCallback.html">wxLuaEventCallback</a>*)lua_touserdata(L, -2);
  2310. <a name="l02281"></a>02281 cb-&gt;<a class="code" href="classwxLuaEventCallback.html#a6a9159713a598aca57598912af845070">ClearwxLuaState</a>();
  2311. <a name="l02282"></a>02282
  2312. <a name="l02283"></a>02283 lua_pop(L, 1); <span class="comment">// pop value, lua_next will pop key at end</span>
  2313. <a name="l02284"></a>02284 }
  2314. <a name="l02285"></a>02285
  2315. <a name="l02286"></a>02286 lua_pop(L, 1); <span class="comment">// pop table</span>
  2316. <a name="l02287"></a>02287
  2317. <a name="l02288"></a>02288 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, &amp;<a class="code" href="wxlstate_8h.html#a034985fb7df51670c3b6a024329496fa">wxlua_lreg_evtcallbacks_key</a>);
  2318. <a name="l02289"></a>02289
  2319. <a name="l02290"></a>02290 <span class="comment">// ----------------------------------------------------------------------</span>
  2320. <a name="l02291"></a>02291 <span class="comment">// These should already be gone from wxLuaCleanupWindows, make sure...</span>
  2321. <a name="l02292"></a>02292
  2322. <a name="l02293"></a>02293 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#ae13b14073477671929c41823f198c33d">wxlua_lreg_windestroycallbacks_key</a>); <span class="comment">// push key</span>
  2323. <a name="l02294"></a>02294 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  2324. <a name="l02295"></a>02295
  2325. <a name="l02296"></a>02296 lua_pushnil(L);
  2326. <a name="l02297"></a>02297 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
  2327. <a name="l02298"></a>02298 {
  2328. <a name="l02299"></a>02299 <span class="comment">// value = -1, key = -2, table = -3</span>
  2329. <a name="l02300"></a>02300 <a class="code" href="classwxLuaWinDestroyCallback.html">wxLuaWinDestroyCallback</a>* cb = (<a class="code" href="classwxLuaWinDestroyCallback.html">wxLuaWinDestroyCallback</a>*)lua_touserdata(L, -1);
  2330. <a name="l02301"></a>02301 cb-&gt;<a class="code" href="classwxLuaWinDestroyCallback.html#adfc7590cb179efa4d3eb4c38fb903aba">ClearwxLuaState</a>();
  2331. <a name="l02302"></a>02302
  2332. <a name="l02303"></a>02303 lua_pop(L, 1); <span class="comment">// pop value, lua_next will pop key at end</span>
  2333. <a name="l02304"></a>02304 }
  2334. <a name="l02305"></a>02305
  2335. <a name="l02306"></a>02306 lua_pop(L, 1); <span class="comment">// pop table</span>
  2336. <a name="l02307"></a>02307
  2337. <a name="l02308"></a>02308 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a>, &amp;<a class="code" href="wxlstate_8h.html#ae13b14073477671929c41823f198c33d">wxlua_lreg_windestroycallbacks_key</a>);
  2338. <a name="l02309"></a>02309 }
  2339. <a name="l02310"></a>02310
  2340. <a name="l02311"></a>02311 <span class="comment">//----------------------------------------------------------------------------</span>
  2341. <a name="l02312"></a>02312 <span class="comment">// wxLuaState</span>
  2342. <a name="l02313"></a>02313 <span class="comment">//----------------------------------------------------------------------------</span>
  2343. <a name="l02314"></a>02314
  2344. <a name="l02315"></a>02315 IMPLEMENT_DYNAMIC_CLASS(<a class="code" href="classwxLuaState.html">wxLuaState</a>, wxObject)
  2345. <a name="l02316"></a>02316
  2346. <a name="l02317"></a>02317 wxHashMapLuaState <a class="code" href="classwxLuaState.html">wxLuaState</a>::s_wxHashMapLuaState;
  2347. <a name="l02318"></a>02318 <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html">wxLuaState</a>::sm_wxAppMainLoop_will_run = false;
  2348. <a name="l02319"></a>02319
  2349. <a name="l02320"></a>02320
  2350. <a name="l02321"></a><a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">02321</a> <span class="preprocessor">#define M_WXLSTATEDATA ((wxLuaStateRefData*)m_refData)</span>
  2351. <a name="l02322"></a>02322 <span class="preprocessor"></span>
  2352. <a name="l02323"></a><a class="code" href="classwxLuaState.html#a423dffae6fc222acd56ab565db3ac831">02323</a> wxObjectRefData *<a class="code" href="classwxLuaState.html#a423dffae6fc222acd56ab565db3ac831">wxLuaState::CreateRefData</a>()<span class="keyword"> const</span>
  2353. <a name="l02324"></a>02324 <span class="keyword"></span>{
  2354. <a name="l02325"></a>02325 <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classwxLuaStateRefData.html">wxLuaStateRefData</a>;
  2355. <a name="l02326"></a>02326 }
  2356. <a name="l02327"></a>02327 <span class="comment">//wxObjectRefData *wxLuaState::CloneRefData(const wxObjectRefData *data) const</span>
  2357. <a name="l02328"></a>02328 <span class="comment">//{</span>
  2358. <a name="l02329"></a>02329 <span class="comment">// return new wxLuaStateRefData(*(const wxLuaStateRefData *)data);</span>
  2359. <a name="l02330"></a>02330 <span class="comment">//}</span>
  2360. <a name="l02331"></a>02331
  2361. <a name="l02332"></a><a class="code" href="classwxLuaState.html#a3b188fe18c4e6aa91d5be1a0df9d396a">02332</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a3b188fe18c4e6aa91d5be1a0df9d396a">wxLuaState::Create</a>( <span class="keyword">const</span> <a class="code" href="classwxLuaState.html">wxLuaState</a>&amp; wxlState )
  2362. <a name="l02333"></a>02333 {
  2363. <a name="l02334"></a>02334 <a class="code" href="classwxLuaState.html#aba756d4ded8f0df8df880a34eddee0fe">Destroy</a>();
  2364. <a name="l02335"></a>02335 Ref(wxlState);
  2365. <a name="l02336"></a>02336 }
  2366. <a name="l02337"></a>02337
  2367. <a name="l02338"></a><a class="code" href="classwxLuaState.html#a9aa934e5b0488808b16c8a61d9b46e0d">02338</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a3b188fe18c4e6aa91d5be1a0df9d396a">wxLuaState::Create</a>(wxEvtHandler *handler, wxWindowID <span class="keywordtype">id</span>)
  2368. <a name="l02339"></a>02339 {
  2369. <a name="l02340"></a>02340 <a class="code" href="classwxLuaState.html#aba756d4ded8f0df8df880a34eddee0fe">Destroy</a>();
  2370. <a name="l02341"></a>02341
  2371. <a name="l02342"></a>02342 lua_State* L = lua_open();
  2372. <a name="l02343"></a>02343 <span class="comment">// load some useful libraries, loads all of them</span>
  2373. <a name="l02344"></a>02344 luaL_openlibs(L);
  2374. <a name="l02345"></a>02345
  2375. <a name="l02346"></a>02346 <span class="keywordtype">bool</span> ok = <a class="code" href="classwxLuaState.html#a3b188fe18c4e6aa91d5be1a0df9d396a">Create</a>(L, <a class="code" href="wxlstate_8h.html#a1c0edb51752e95310d3fa8dc274d18c1a3932f86f62ab04efe4d37aee9aa34802">wxLUASTATE_SETSTATE</a>|<a class="code" href="wxlstate_8h.html#a1c0edb51752e95310d3fa8dc274d18c1aa79da132f935b36c1bed3081a2efdf8e">wxLUASTATE_OPENBINDINGS</a>);
  2376. <a name="l02347"></a>02347
  2377. <a name="l02348"></a>02348 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_evtHandler = handler;
  2378. <a name="l02349"></a>02349 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_id = id;
  2379. <a name="l02350"></a>02350
  2380. <a name="l02351"></a>02351 <span class="comment">// alert people that we&#39;ve been created so they can finish setting us up</span>
  2381. <a name="l02352"></a>02352 <a class="code" href="classwxLuaEvent.html">wxLuaEvent</a> event(wxEVT_LUA_CREATION, <a class="code" href="classwxLuaState.html#a92715872ca9f5f4b6e77344410963350">GetId</a>(), *<span class="keyword">this</span>);
  2382. <a name="l02353"></a>02353 <a class="code" href="classwxLuaState.html#a1f0e0a065e8c3ea25c0ebe5c7258f7ae">SendEvent</a>( event );
  2383. <a name="l02354"></a>02354
  2384. <a name="l02355"></a>02355 <span class="keywordflow">return</span> ok;
  2385. <a name="l02356"></a>02356 }
  2386. <a name="l02357"></a>02357
  2387. <a name="l02358"></a><a class="code" href="classwxLuaState.html#a4fdf732b66d6f128d11814ee8c463d3f">02358</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a3b188fe18c4e6aa91d5be1a0df9d396a">wxLuaState::Create</a>(lua_State* L, <span class="keywordtype">int</span> state_type)
  2388. <a name="l02359"></a>02359 {
  2389. <a name="l02360"></a>02360 wxCHECK_MSG(L != NULL, <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid lua_State&quot;</span>));
  2390. <a name="l02361"></a>02361 <a class="code" href="classwxLuaState.html#aba756d4ded8f0df8df880a34eddee0fe">Destroy</a>();
  2391. <a name="l02362"></a>02362
  2392. <a name="l02363"></a>02363 <span class="keywordflow">if</span> (<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(state_type, <a class="code" href="wxlstate_8h.html#a1c0edb51752e95310d3fa8dc274d18c1aa45d65bc60575889af53a41b330b27b9">wxLUASTATE_GETSTATE</a>))
  2393. <a name="l02364"></a>02364 {
  2394. <a name="l02365"></a>02365 <span class="comment">// returns an invalid, wxNullLuaState on failure</span>
  2395. <a name="l02366"></a>02366 Ref(<a class="code" href="classwxLuaState.html#a43734e72a210c012cdc240772db7d762">wxLuaState::GetwxLuaState</a>(L));
  2396. <a name="l02367"></a>02367 }
  2397. <a name="l02368"></a>02368 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(state_type, <a class="code" href="wxlstate_8h.html#a1c0edb51752e95310d3fa8dc274d18c1a3932f86f62ab04efe4d37aee9aa34802">wxLUASTATE_SETSTATE</a>))
  2398. <a name="l02369"></a>02369 {
  2399. <a name="l02370"></a>02370 m_refData = <span class="keyword">new</span> <a class="code" href="classwxLuaStateRefData.html">wxLuaStateRefData</a>();
  2400. <a name="l02371"></a>02371
  2401. <a name="l02372"></a>02372 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State = L;
  2402. <a name="l02373"></a>02373 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State_static = <a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(state_type, <a class="code" href="wxlstate_8h.html#a1c0edb51752e95310d3fa8dc274d18c1a58f35479bcc2796b33a8ac067c6109a3">wxLUASTATE_STATICSTATE</a>);
  2403. <a name="l02374"></a>02374
  2404. <a name="l02375"></a>02375 <span class="comment">// Make the GC a little more aggressive since we push void* data</span>
  2405. <a name="l02376"></a>02376 <span class="comment">// that may be quite large. The upshot is that Lua runs faster.</span>
  2406. <a name="l02377"></a>02377 <span class="comment">// Empirically found by timing: &quot;for i = 1, 1E6 do local p = wx.wxPoint() end&quot;</span>
  2407. <a name="l02378"></a>02378 lua_gc(L, LUA_GCSETPAUSE, 120);
  2408. <a name="l02379"></a>02379 lua_gc(L, LUA_GCSETSTEPMUL, 400);
  2409. <a name="l02380"></a>02380
  2410. <a name="l02381"></a>02381 <span class="comment">// Create a new state to push into Lua, the last wxLuaStateRefData will delete it.</span>
  2411. <a name="l02382"></a>02382 <span class="comment">// Note: we call SetRefData() so that we don&#39;t increase the ref count.</span>
  2412. <a name="l02383"></a>02383 <a class="code" href="classwxLuaState.html">wxLuaState</a>* hashState = <span class="keyword">new</span> <a class="code" href="classwxLuaState.html#a40c4a82d65e02d0f5e05dc197b85b978">wxLuaState</a>(<span class="keyword">false</span>);
  2413. <a name="l02384"></a>02384 hashState-&gt;SetRefData(m_refData);
  2414. <a name="l02385"></a>02385 <a class="code" href="classwxLuaState.html#ab8261cd3629c21d1cbaeb5a6e0777272">wxLuaState::s_wxHashMapLuaState</a>[L] = hashState;
  2415. <a name="l02386"></a>02386
  2416. <a name="l02387"></a>02387 <span class="comment">// Stick us into the Lua registry table - push key, value</span>
  2417. <a name="l02388"></a>02388 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a921299ed63513972e3bda3678fc835c0">wxlua_lreg_wxluastate_key</a>);
  2418. <a name="l02389"></a>02389 lua_pushlightuserdata( L, (<span class="keywordtype">void</span>*)hashState );
  2419. <a name="l02390"></a>02390 lua_rawset( L, LUA_REGISTRYINDEX ); <span class="comment">// set the value</span>
  2420. <a name="l02391"></a>02391
  2421. <a name="l02392"></a>02392 <span class="comment">// start off not in an event</span>
  2422. <a name="l02393"></a>02393 <a class="code" href="wxlstate_8h.html#a3f5c8427ae033a7da28754a6e37acf0a">wxlua_setwxeventtype</a>(L, wxEVT_NULL);
  2423. <a name="l02394"></a>02394
  2424. <a name="l02395"></a>02395 <span class="comment">// Push our wxLuaStateData</span>
  2425. <a name="l02396"></a>02396 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#aba1ad42faf08e4b50bca48b5ba9d8ece">wxlua_lreg_wxluastatedata_key</a>);
  2426. <a name="l02397"></a>02397 lua_pushlightuserdata(L, <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData);
  2427. <a name="l02398"></a>02398 lua_rawset(L, LUA_REGISTRYINDEX); <span class="comment">// set the value</span>
  2428. <a name="l02399"></a>02399
  2429. <a name="l02400"></a>02400 <span class="comment">// These tables are expected to exist no matter what.</span>
  2430. <a name="l02401"></a>02401 <span class="comment">// They&#39;re in the registry so even if they&#39;re not used they</span>
  2431. <a name="l02402"></a>02402 <span class="comment">// shouldn&#39;t bother anyone.</span>
  2432. <a name="l02403"></a>02403
  2433. <a name="l02404"></a>02404 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#ab84cb2515893ab069d7d165208e68aad">wxlua_lreg_regtable_key</a>);
  2434. <a name="l02405"></a>02405 lua_newtable(L); <span class="comment">// main table</span>
  2435. <a name="l02406"></a>02406 lua_newtable(L); <span class="comment">// metatable</span>
  2436. <a name="l02407"></a>02407 lua_pushlstring(L, <span class="stringliteral">&quot;__mode&quot;</span>, 6);
  2437. <a name="l02408"></a>02408 lua_pushlstring(L, <span class="stringliteral">&quot;kv&quot;</span>, 2);
  2438. <a name="l02409"></a>02409 lua_rawset(L, -3); <span class="comment">// set mode of main table</span>
  2439. <a name="l02410"></a>02410 lua_setmetatable(L, -2); <span class="comment">// via the metatable</span>
  2440. <a name="l02411"></a>02411 lua_rawset(L, LUA_REGISTRYINDEX); <span class="comment">// set the value</span>
  2441. <a name="l02412"></a>02412
  2442. <a name="l02413"></a>02413 <span class="comment">// create the types table in registry</span>
  2443. <a name="l02414"></a>02414 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(L, &amp;<a class="code" href="wxlstate_8h.html#a0ef6804bd2cb63f4fa705727f8871cbd">wxlua_lreg_types_key</a>);
  2444. <a name="l02415"></a>02415
  2445. <a name="l02416"></a>02416 <span class="comment">// create the refs table in registry</span>
  2446. <a name="l02417"></a>02417 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(L, &amp;<a class="code" href="wxlstate_8h.html#ac4ac0a3575fafde31e659ced85f69c4d">wxlua_lreg_refs_key</a>);
  2447. <a name="l02418"></a>02418
  2448. <a name="l02419"></a>02419 <span class="comment">// create the debug refs table in registry</span>
  2449. <a name="l02420"></a>02420 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(L, &amp;<a class="code" href="wxlstate_8h.html#a30c2d5556a4a278368b48fe0b7bb3fda">wxlua_lreg_debug_refs_key</a>);
  2450. <a name="l02421"></a>02421
  2451. <a name="l02422"></a>02422 <span class="comment">// create the wxLuaBindClasses table in the registry</span>
  2452. <a name="l02423"></a>02423 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(L, &amp;<a class="code" href="wxlstate_8h.html#a0bcf696ed6d6e2b4218e9a8852a164ef">wxlua_lreg_classes_key</a>);
  2453. <a name="l02424"></a>02424
  2454. <a name="l02425"></a>02425 <span class="comment">// Create a table for overridden methods for C++ userdata objects</span>
  2455. <a name="l02426"></a>02426 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(L, &amp;<a class="code" href="wxlstate_8h.html#a274b8b7aae6f647e3e69d098962b7b1d">wxlua_lreg_derivedmethods_key</a>);
  2456. <a name="l02427"></a>02427
  2457. <a name="l02428"></a>02428 <span class="comment">// Create a table for the wxLuaBindings we&#39;ve installed</span>
  2458. <a name="l02429"></a>02429 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(L, &amp;<a class="code" href="wxlstate_8h.html#a80a0d4c84529abdcf6b46237431832ce">wxlua_lreg_wxluabindings_key</a>);
  2459. <a name="l02430"></a>02430
  2460. <a name="l02431"></a>02431 <span class="comment">// Create a table for the userdata that we&#39;ve pushed into Lua</span>
  2461. <a name="l02432"></a>02432 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(L, &amp;<a class="code" href="wxlstate_8h.html#af255531a04d81a0d82556c0d1fe8e7e7">wxlua_lreg_weakobjects_key</a>);
  2462. <a name="l02433"></a>02433
  2463. <a name="l02434"></a>02434 <span class="comment">// Create a table for objects to delete</span>
  2464. <a name="l02435"></a>02435 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(L, &amp;<a class="code" href="wxlstate_8h.html#a7ec5afec8a64a29e28fefec4a1105790">wxlua_lreg_gcobjects_key</a>);
  2465. <a name="l02436"></a>02436
  2466. <a name="l02437"></a>02437 <span class="comment">// Create a table for wxLuaEventCallbacks</span>
  2467. <a name="l02438"></a>02438 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(L, &amp;<a class="code" href="wxlstate_8h.html#a034985fb7df51670c3b6a024329496fa">wxlua_lreg_evtcallbacks_key</a>);
  2468. <a name="l02439"></a>02439
  2469. <a name="l02440"></a>02440 <span class="comment">// Create a table for wxLuaWinDestroyCallbacks</span>
  2470. <a name="l02441"></a>02441 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(L, &amp;<a class="code" href="wxlstate_8h.html#ae13b14073477671929c41823f198c33d">wxlua_lreg_windestroycallbacks_key</a>);
  2471. <a name="l02442"></a>02442
  2472. <a name="l02443"></a>02443 <span class="comment">// Create a table for top level wxWindows</span>
  2473. <a name="l02444"></a>02444 <a class="code" href="wxlstate_8h.html#a78fe2540c7e61145be1372073f0c37f7">wxlua_lreg_createtable</a>(L, &amp;<a class="code" href="wxlstate_8h.html#aab2351a78a8949184e1910cc1f9e7463">wxlua_lreg_topwindows_key</a>);
  2474. <a name="l02445"></a>02445
  2475. <a name="l02446"></a>02446 <span class="comment">// copy Lua&#39;s print function in case someone really wants to use it</span>
  2476. <a name="l02447"></a>02447 lua_pushlstring(L, <span class="stringliteral">&quot;print&quot;</span>, 5);
  2477. <a name="l02448"></a>02448 lua_rawget( L, LUA_GLOBALSINDEX ); <span class="comment">// pop key, push print function</span>
  2478. <a name="l02449"></a>02449 lua_pushlstring(L, <span class="stringliteral">&quot;print_lua&quot;</span>, 9);
  2479. <a name="l02450"></a>02450 lua_pushvalue(L, -2); <span class="comment">// copy print function</span>
  2480. <a name="l02451"></a>02451 lua_rawset(L, LUA_GLOBALSINDEX); <span class="comment">// set t[key] = value, pops key and value</span>
  2481. <a name="l02452"></a>02452 lua_pop(L, 1); <span class="comment">// pop the print function</span>
  2482. <a name="l02453"></a>02453
  2483. <a name="l02454"></a>02454 <span class="comment">// register wxLua&#39;s print handler to send events, replaces Lua&#39;s print function</span>
  2484. <a name="l02455"></a>02455 <a class="code" href="classwxLuaState.html#a0e1287b64bb07f12f4a55d5f9b0ba8c7">RegisterFunction</a>(<a class="code" href="wxlstate_8cpp.html#a7c982cbdf126f61b0868fe40baf150c4">wxlua_printFunction</a>, <span class="stringliteral">&quot;print&quot;</span>);
  2485. <a name="l02456"></a>02456
  2486. <a name="l02457"></a>02457 <span class="comment">// register our NULL type</span>
  2487. <a name="l02458"></a>02458 <span class="comment">//wxluatype_NULL = wxluaT_newmetatable(L, wxluatype_NULL);</span>
  2488. <a name="l02459"></a>02459 <a class="code" href="classwxLuaBinding.html#a076f769e1fc9d52361832f1be869022e">wxLuaBinding::InstallClassMetatable</a>(L, &amp;<a class="code" href="wxlbind_8cpp.html#a4aa9b7bff8761a6fb183f52ad9d35fdf">wxLuaBindClass_NULL</a>);
  2489. <a name="l02460"></a>02460
  2490. <a name="l02461"></a>02461 <span class="comment">// now register bindings</span>
  2491. <a name="l02462"></a>02462 <span class="keywordflow">if</span> (<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(state_type, <a class="code" href="wxlstate_8h.html#a1c0edb51752e95310d3fa8dc274d18c1aa79da132f935b36c1bed3081a2efdf8e">wxLUASTATE_OPENBINDINGS</a>))
  2492. <a name="l02463"></a>02463 {
  2493. <a name="l02464"></a>02464 <span class="comment">// load the bit lib, this is the accepted way, see luaL_openlibs(L)</span>
  2494. <a name="l02465"></a>02465 lua_pushcfunction(L, <a class="code" href="wxlstate_8cpp.html#ab03a3095ab5d0f4a427b4c5b10aa4e5c">luaopen_bit</a>);
  2495. <a name="l02466"></a>02466 lua_pushstring(L, <span class="stringliteral">&quot;bit&quot;</span>);
  2496. <a name="l02467"></a>02467 lua_call(L, 1, 0);
  2497. <a name="l02468"></a>02468
  2498. <a name="l02469"></a>02469 <a class="code" href="classwxLuaState.html#a32b493d7437004027b3e7f20799e6e18">RegisterBindings</a>();
  2499. <a name="l02470"></a>02470 }
  2500. <a name="l02471"></a>02471 }
  2501. <a name="l02472"></a>02472 <span class="keywordflow">else</span>
  2502. <a name="l02473"></a>02473 wxFAIL_MSG(wxT(<span class="stringliteral">&quot;Unknown state_type for wxLuaState::Create()&quot;</span>));
  2503. <a name="l02474"></a>02474
  2504. <a name="l02475"></a>02475 <span class="keywordflow">return</span> <a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>();
  2505. <a name="l02476"></a>02476 }
  2506. <a name="l02477"></a>02477
  2507. <a name="l02478"></a>02478 <span class="comment">// --------------------------------------------------------------------------</span>
  2508. <a name="l02479"></a>02479
  2509. <a name="l02480"></a><a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">02480</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">wxLuaState::Ok</a>()<span class="keyword"> const</span>
  2510. <a name="l02481"></a>02481 <span class="keyword"></span>{
  2511. <a name="l02482"></a>02482 <span class="keywordflow">return</span> (m_refData != NULL) &amp;&amp; (<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State != NULL);
  2512. <a name="l02483"></a>02483 }
  2513. <a name="l02484"></a>02484
  2514. <a name="l02485"></a>02485 <span class="comment">// --------------------------------------------------------------------------</span>
  2515. <a name="l02486"></a>02486
  2516. <a name="l02487"></a><a class="code" href="classwxLuaState.html#aba756d4ded8f0df8df880a34eddee0fe">02487</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#aba756d4ded8f0df8df880a34eddee0fe">wxLuaState::Destroy</a>()
  2517. <a name="l02488"></a>02488 {
  2518. <a name="l02489"></a>02489 <span class="keywordflow">if</span> (m_refData == NULL) <span class="keywordflow">return</span>;
  2519. <a name="l02490"></a>02490
  2520. <a name="l02491"></a>02491 <span class="comment">// we don&#39;t want recursion in UnRef and wxlua_garbageCollect</span>
  2521. <a name="l02492"></a>02492 <span class="keywordflow">if</span> (GetRefData()-&gt;GetRefCount() == 1)
  2522. <a name="l02493"></a>02493 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;CloseLuaState(<span class="keyword">true</span>);
  2523. <a name="l02494"></a>02494
  2524. <a name="l02495"></a>02495 UnRef();
  2525. <a name="l02496"></a>02496 }
  2526. <a name="l02497"></a>02497
  2527. <a name="l02498"></a><a class="code" href="classwxLuaState.html#ac2e2e6a8fe585ee5202769bc503ce47d">02498</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#ac2e2e6a8fe585ee5202769bc503ce47d">wxLuaState::CloseLuaState</a>(<span class="keywordtype">bool</span> force)
  2528. <a name="l02499"></a>02499 {
  2529. <a name="l02500"></a>02500 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2530. <a name="l02501"></a>02501 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;CloseLuaState(force);
  2531. <a name="l02502"></a>02502 }
  2532. <a name="l02503"></a>02503
  2533. <a name="l02504"></a><a class="code" href="classwxLuaState.html#afa5bd7f676094317e2a0c383344be837">02504</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#afa5bd7f676094317e2a0c383344be837">wxLuaState::IsClosing</a>()<span class="keyword"> const</span>
  2534. <a name="l02505"></a>02505 <span class="keyword"></span>{
  2535. <a name="l02506"></a>02506 wxCHECK_MSG(m_refData &amp;&amp; <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData, <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2536. <a name="l02507"></a>02507 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_is_closing;
  2537. <a name="l02508"></a>02508 }
  2538. <a name="l02509"></a>02509
  2539. <a name="l02510"></a>02510 <span class="comment">// --------------------------------------------------------------------------</span>
  2540. <a name="l02511"></a>02511
  2541. <a name="l02512"></a><a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">02512</a> lua_State* <a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">wxLuaState::GetLuaState</a>()<span class="keyword"> const</span>
  2542. <a name="l02513"></a>02513 <span class="keyword"></span>{
  2543. <a name="l02514"></a>02514 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2544. <a name="l02515"></a>02515 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State;
  2545. <a name="l02516"></a>02516 }
  2546. <a name="l02517"></a>02517
  2547. <a name="l02518"></a><a class="code" href="classwxLuaState.html#a2db823b328b9062b044c133e1fcb0393">02518</a> <a class="code" href="classwxLuaStateData.html">wxLuaStateData</a>* <a class="code" href="classwxLuaState.html#a2db823b328b9062b044c133e1fcb0393">wxLuaState::GetLuaStateData</a>()<span class="keyword"> const</span>
  2548. <a name="l02519"></a>02519 <span class="keyword"></span>{
  2549. <a name="l02520"></a>02520 wxCHECK_MSG(m_refData != NULL, NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState, missing ref data&quot;</span>));
  2550. <a name="l02521"></a>02521 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData;
  2551. <a name="l02522"></a>02522 }
  2552. <a name="l02523"></a>02523
  2553. <a name="l02524"></a><a class="code" href="classwxLuaState.html#a43734e72a210c012cdc240772db7d762">02524</a> <a class="code" href="classwxLuaState.html">wxLuaState</a> <a class="code" href="classwxLuaState.html#a43734e72a210c012cdc240772db7d762">wxLuaState::GetwxLuaState</a>(lua_State* L) <span class="comment">// static function</span>
  2554. <a name="l02525"></a>02525 {
  2555. <a name="l02526"></a>02526 <span class="comment">// try our hashtable for faster lookup</span>
  2556. <a name="l02527"></a>02527 wxHashMapLuaState::iterator it = s_wxHashMapLuaState.find(L);
  2557. <a name="l02528"></a>02528 <span class="keywordflow">if</span> (it != s_wxHashMapLuaState.end())
  2558. <a name="l02529"></a>02529 {
  2559. <a name="l02530"></a>02530 <span class="keywordflow">return</span> <a class="code" href="classwxLuaState.html#a40c4a82d65e02d0f5e05dc197b85b978">wxLuaState</a>(*it-&gt;second);
  2560. <a name="l02531"></a>02531 }
  2561. <a name="l02532"></a>02532
  2562. <a name="l02533"></a>02533 <span class="comment">// else it&#39;s a coroutine? look up the state data from Lua</span>
  2563. <a name="l02534"></a>02534 <a class="code" href="classwxLuaState.html">wxLuaState</a>* wxlState = NULL;
  2564. <a name="l02535"></a>02535
  2565. <a name="l02536"></a>02536 <span class="comment">// try to get the state we&#39;ve stored</span>
  2566. <a name="l02537"></a>02537 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a921299ed63513972e3bda3678fc835c0">wxlua_lreg_wxluastate_key</a>);
  2567. <a name="l02538"></a>02538 lua_rawget( L, LUA_REGISTRYINDEX );
  2568. <a name="l02539"></a>02539
  2569. <a name="l02540"></a>02540 <span class="comment">// if nothing was returned or it wasn&#39;t a ptr, abort</span>
  2570. <a name="l02541"></a>02541 <span class="keywordflow">if</span> ( lua_islightuserdata(L, -1) )
  2571. <a name="l02542"></a>02542 wxlState = (<a class="code" href="classwxLuaState.html">wxLuaState</a>*)lua_touserdata( L, -1 );
  2572. <a name="l02543"></a>02543
  2573. <a name="l02544"></a>02544 lua_pop(L, 1); <span class="comment">// pop the wxLuaStateRefData or nil on failure</span>
  2574. <a name="l02545"></a>02545
  2575. <a name="l02546"></a>02546 <span class="keywordflow">if</span> (wxlState &amp;&amp; (wxlState-&gt;<a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">GetLuaState</a>() != L))
  2576. <a name="l02547"></a>02547 {
  2577. <a name="l02548"></a>02548 <span class="comment">// Create a new wxLuaState for the coroutine and set the wxLuaStateData</span>
  2578. <a name="l02549"></a>02549 <span class="comment">// to the original wxLuaState&#39;s data</span>
  2579. <a name="l02550"></a>02550 <a class="code" href="classwxLuaStateRefData.html">wxLuaStateRefData</a>* refData = <span class="keyword">new</span> <a class="code" href="classwxLuaStateRefData.html">wxLuaStateRefData</a>(<span class="keyword">false</span>);
  2580. <a name="l02551"></a>02551 refData-&gt;<a class="code" href="classwxLuaStateRefData.html#a55361195d24f0fc248de2acb090f84a3">m_lua_State</a> = L;
  2581. <a name="l02552"></a>02552 refData-&gt;<a class="code" href="classwxLuaStateRefData.html#a6c977816cfdec8f29531e99e32ae2538">m_lua_State_static</a> = <span class="keyword">true</span>;
  2582. <a name="l02553"></a>02553 refData-&gt;<a class="code" href="classwxLuaStateRefData.html#a756bf884311f556e99ea2b4e71d9b725">m_lua_State_coroutine</a> = <span class="keyword">true</span>;
  2583. <a name="l02554"></a>02554
  2584. <a name="l02555"></a>02555 refData-&gt;<a class="code" href="classwxLuaStateRefData.html#a02dde1df32ae7c7749b63a829b12ed05">m_wxlStateData</a> = wxlState-&gt;<a class="code" href="classwxLuaState.html#a2db823b328b9062b044c133e1fcb0393">GetLuaStateData</a>();
  2585. <a name="l02556"></a>02556 refData-&gt;<a class="code" href="classwxLuaStateRefData.html#acc0ef3bdd953f88a8506fa42de6e2120">m_own_stateData</a> = <span class="keyword">false</span>;
  2586. <a name="l02557"></a>02557
  2587. <a name="l02558"></a>02558 <a class="code" href="classwxLuaState.html">wxLuaState</a> wxlState2(<span class="keyword">false</span>);
  2588. <a name="l02559"></a>02559 wxlState2.SetRefData(refData);
  2589. <a name="l02560"></a>02560 <span class="keywordflow">return</span> wxlState2;
  2590. <a name="l02561"></a>02561 }
  2591. <a name="l02562"></a>02562 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (wxlState)
  2592. <a name="l02563"></a>02563 {
  2593. <a name="l02564"></a>02564 <span class="keywordflow">return</span> <a class="code" href="classwxLuaState.html#a40c4a82d65e02d0f5e05dc197b85b978">wxLuaState</a>(*wxlState); <span class="comment">// Ref it</span>
  2594. <a name="l02565"></a>02565 }
  2595. <a name="l02566"></a>02566
  2596. <a name="l02567"></a>02567 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#aef06b6591011cd68b9e370d5e702d255">wxNullLuaState</a>;
  2597. <a name="l02568"></a>02568 }
  2598. <a name="l02569"></a>02569
  2599. <a name="l02570"></a>02570 <span class="comment">// --------------------------------------------------------------------------</span>
  2600. <a name="l02571"></a>02571
  2601. <a name="l02572"></a><a class="code" href="classwxLuaState.html#a48c2f73c3cc376e0a8d9df62baa2c6a2">02572</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a48c2f73c3cc376e0a8d9df62baa2c6a2">wxLuaState::SetEventHandler</a>(wxEvtHandler *evtHandler)
  2602. <a name="l02573"></a>02573 {
  2603. <a name="l02574"></a>02574 wxCHECK_RET(m_refData &amp;&amp; <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2604. <a name="l02575"></a>02575 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_evtHandler = evtHandler;
  2605. <a name="l02576"></a>02576 }
  2606. <a name="l02577"></a><a class="code" href="classwxLuaState.html#a1f285ff9d7d9b8ef1cece01254b2141f">02577</a> wxEvtHandler *<a class="code" href="classwxLuaState.html#a1f285ff9d7d9b8ef1cece01254b2141f">wxLuaState::GetEventHandler</a>()<span class="keyword"> const</span>
  2607. <a name="l02578"></a>02578 <span class="keyword"></span>{
  2608. <a name="l02579"></a>02579 wxCHECK_MSG(m_refData &amp;&amp; <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData, NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2609. <a name="l02580"></a>02580 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_evtHandler;
  2610. <a name="l02581"></a>02581 }
  2611. <a name="l02582"></a>02582
  2612. <a name="l02583"></a><a class="code" href="classwxLuaState.html#a090ba91725fb52608821639697d70e4e">02583</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a090ba91725fb52608821639697d70e4e">wxLuaState::SetId</a>(wxWindowID <span class="keywordtype">id</span>)
  2613. <a name="l02584"></a>02584 {
  2614. <a name="l02585"></a>02585 wxCHECK_RET(m_refData &amp;&amp; <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2615. <a name="l02586"></a>02586 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_id = id;
  2616. <a name="l02587"></a>02587 }
  2617. <a name="l02588"></a><a class="code" href="classwxLuaState.html#a92715872ca9f5f4b6e77344410963350">02588</a> wxWindowID <a class="code" href="classwxLuaState.html#a92715872ca9f5f4b6e77344410963350">wxLuaState::GetId</a>()<span class="keyword"> const</span>
  2618. <a name="l02589"></a>02589 <span class="keyword"></span>{
  2619. <a name="l02590"></a>02590 wxCHECK_MSG(m_refData &amp;&amp; <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData, wxID_ANY, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2620. <a name="l02591"></a>02591 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_id;
  2621. <a name="l02592"></a>02592 }
  2622. <a name="l02593"></a>02593
  2623. <a name="l02594"></a><a class="code" href="classwxLuaState.html#a1f0e0a065e8c3ea25c0ebe5c7258f7ae">02594</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a1f0e0a065e8c3ea25c0ebe5c7258f7ae">wxLuaState::SendEvent</a>( <a class="code" href="classwxLuaEvent.html">wxLuaEvent</a> &amp;event )<span class="keyword"> const</span>
  2624. <a name="l02595"></a>02595 <span class="keyword"></span>{
  2625. <a name="l02596"></a>02596 wxCHECK_MSG(m_refData &amp;&amp; <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData, <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2626. <a name="l02597"></a>02597
  2627. <a name="l02598"></a>02598 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_evtHandler)
  2628. <a name="l02599"></a>02599 {
  2629. <a name="l02600"></a>02600 <span class="keyword">event</span>.SetEventObject( (wxObject*)<span class="keyword">this</span> );
  2630. <a name="l02601"></a>02601 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_evtHandler-&gt;ProcessEvent(event);
  2631. <a name="l02602"></a>02602 }
  2632. <a name="l02603"></a>02603
  2633. <a name="l02604"></a>02604 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  2634. <a name="l02605"></a>02605 }
  2635. <a name="l02606"></a>02606
  2636. <a name="l02607"></a>02607 <span class="comment">// ----------------------------------------------------------------------------</span>
  2637. <a name="l02608"></a>02608
  2638. <a name="l02609"></a><a class="code" href="classwxLuaState.html#a64b0f527f824cf2a4e1af53be94715ba">02609</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a64b0f527f824cf2a4e1af53be94715ba">wxLuaState::RunFile</a>(<span class="keyword">const</span> wxString &amp;filename, <span class="keywordtype">int</span> nresults)
  2639. <a name="l02610"></a>02610 {
  2640. <a name="l02611"></a>02611 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), LUA_ERRRUN, wxT(<span class="stringliteral">&quot;Lua interpreter not created&quot;</span>));
  2641. <a name="l02612"></a>02612 wxCHECK_MSG(!<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_is_running, LUA_ERRRUN, wxT(<span class="stringliteral">&quot;Lua interpreter is already running&quot;</span>));
  2642. <a name="l02613"></a>02613
  2643. <a name="l02614"></a>02614 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_debug_hook_break = <span class="keyword">false</span>;
  2644. <a name="l02615"></a>02615 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_is_running = <span class="keyword">true</span>;
  2645. <a name="l02616"></a>02616
  2646. <a name="l02617"></a>02617 <span class="keywordtype">int</span> top = <a class="code" href="classwxLuaState.html#ae9d1c33abd2af7e081fa71a42ca28a26">lua_GetTop</a>();
  2647. <a name="l02618"></a>02618 <span class="keywordtype">int</span> status = <a class="code" href="classwxLuaState.html#a2bb08c8b0bd5ab2640bd6a14d9cb1744">luaL_LoadFile</a>(<a class="code" href="wxlstate_8h.html#a41976a7549ef4bfa7e9a1147dc7b4d55">wx2lua</a>(filename));
  2648. <a name="l02619"></a>02619 <span class="keywordflow">if</span> (status == 0)
  2649. <a name="l02620"></a>02620 status = <a class="code" href="classwxLuaState.html#a9359504a70a5819c3c27a14c590d8d46">LuaPCall</a>(0, nresults); <span class="comment">// no args and nresults</span>
  2650. <a name="l02621"></a>02621 <span class="keywordflow">else</span>
  2651. <a name="l02622"></a>02622 <a class="code" href="classwxLuaState.html#ac407802949d44c3399686ae6e65d5dc9">SendLuaErrorEvent</a>(status, top); <span class="comment">// compilation error</span>
  2652. <a name="l02623"></a>02623
  2653. <a name="l02624"></a>02624 <span class="keywordflow">if</span> (nresults == 0)
  2654. <a name="l02625"></a>02625 <a class="code" href="classwxLuaState.html#ad39adb85b7e7010691f51bd3f6fe3161">lua_SetTop</a>(top); <span class="comment">// restore original top (removes err msg)</span>
  2655. <a name="l02626"></a>02626
  2656. <a name="l02627"></a>02627 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_debug_hook_break = <span class="keyword">false</span>;
  2657. <a name="l02628"></a>02628 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_is_running = <span class="keyword">false</span>;
  2658. <a name="l02629"></a>02629
  2659. <a name="l02630"></a>02630 <span class="keywordflow">return</span> status;
  2660. <a name="l02631"></a>02631 }
  2661. <a name="l02632"></a>02632
  2662. <a name="l02633"></a><a class="code" href="classwxLuaState.html#a6603ae3ba3101d74645b739d9524abda">02633</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a6603ae3ba3101d74645b739d9524abda">wxLuaState::RunString</a>(<span class="keyword">const</span> wxString &amp;script, <span class="keyword">const</span> wxString&amp; name, <span class="keywordtype">int</span> nresults)
  2663. <a name="l02634"></a>02634 {
  2664. <a name="l02635"></a>02635 <a class="code" href="classwxLuaCharBuffer.html">wxLuaCharBuffer</a> buf(script);
  2665. <a name="l02636"></a>02636 <span class="keywordflow">return</span> <a class="code" href="classwxLuaState.html#aa91ecad44e66a933f9053801fcaa0344">RunBuffer</a>(buf.<a class="code" href="classwxLuaCharBuffer.html#a10cddf8fb7f9eea348494ece843f20f6">GetData</a>(), buf.<a class="code" href="classwxLuaCharBuffer.html#a27a6ba04d86b6ebefd310b9e3b001564">Length</a>(), name, nresults);
  2666. <a name="l02637"></a>02637 }
  2667. <a name="l02638"></a>02638
  2668. <a name="l02639"></a><a class="code" href="classwxLuaState.html#aa91ecad44e66a933f9053801fcaa0344">02639</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#aa91ecad44e66a933f9053801fcaa0344">wxLuaState::RunBuffer</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> buf[], <span class="keywordtype">size_t</span> size, <span class="keyword">const</span> wxString &amp;name, <span class="keywordtype">int</span> nresults)
  2669. <a name="l02640"></a>02640 {
  2670. <a name="l02641"></a>02641 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), LUA_ERRRUN, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2671. <a name="l02642"></a>02642 wxCHECK_MSG(!<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_is_running, LUA_ERRRUN, wxT(<span class="stringliteral">&quot;Lua interpreter is already running&quot;</span>));
  2672. <a name="l02643"></a>02643
  2673. <a name="l02644"></a>02644 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_debug_hook_break = <span class="keyword">false</span>;
  2674. <a name="l02645"></a>02645 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_is_running = <span class="keyword">true</span>;
  2675. <a name="l02646"></a>02646
  2676. <a name="l02647"></a>02647 <span class="keywordtype">int</span> top = <a class="code" href="classwxLuaState.html#ae9d1c33abd2af7e081fa71a42ca28a26">lua_GetTop</a>();
  2677. <a name="l02648"></a>02648 <span class="keywordtype">int</span> status = <a class="code" href="classwxLuaState.html#aa6a8a233ffc3bb740456d655b4de9f5c">luaL_LoadBuffer</a>(buf, size, <a class="code" href="wxlstate_8h.html#a41976a7549ef4bfa7e9a1147dc7b4d55">wx2lua</a>(name));
  2678. <a name="l02649"></a>02649 <span class="keywordflow">if</span> (status == 0)
  2679. <a name="l02650"></a>02650 status = <a class="code" href="classwxLuaState.html#a9359504a70a5819c3c27a14c590d8d46">LuaPCall</a>(0, nresults); <span class="comment">// no args and nresults</span>
  2680. <a name="l02651"></a>02651 <span class="keywordflow">else</span>
  2681. <a name="l02652"></a>02652 <a class="code" href="classwxLuaState.html#ac407802949d44c3399686ae6e65d5dc9">SendLuaErrorEvent</a>(status, top); <span class="comment">// compilation error</span>
  2682. <a name="l02653"></a>02653
  2683. <a name="l02654"></a>02654 <span class="keywordflow">if</span> (nresults == 0)
  2684. <a name="l02655"></a>02655 <a class="code" href="classwxLuaState.html#ad39adb85b7e7010691f51bd3f6fe3161">lua_SetTop</a>(top); <span class="comment">// restore original top (removes err msg)</span>
  2685. <a name="l02656"></a>02656
  2686. <a name="l02657"></a>02657 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_debug_hook_break = <span class="keyword">false</span>;
  2687. <a name="l02658"></a>02658 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_is_running = <span class="keyword">false</span>;
  2688. <a name="l02659"></a>02659
  2689. <a name="l02660"></a>02660 <span class="keywordflow">return</span> status;
  2690. <a name="l02661"></a>02661 }
  2691. <a name="l02662"></a>02662
  2692. <a name="l02663"></a><a class="code" href="classwxLuaState.html#aed84ecb2a4fe3540363b636f085463cf">02663</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#aed84ecb2a4fe3540363b636f085463cf">wxLuaState::IsRunning</a>()<span class="keyword"> const</span>
  2693. <a name="l02664"></a>02664 <span class="keyword"></span>{
  2694. <a name="l02665"></a>02665 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2695. <a name="l02666"></a>02666 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_is_running;
  2696. <a name="l02667"></a>02667 }
  2697. <a name="l02668"></a>02668
  2698. <a name="l02669"></a>02669 <span class="comment">// this function taken from lua.c, the lua executable</span>
  2699. <a name="l02670"></a><a class="code" href="wxlstate_8cpp.html#a06a0423ee4a323779c83506ab9351421">02670</a> <span class="keyword">static</span> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlstate_8cpp.html#a06a0423ee4a323779c83506ab9351421">wxlua_traceback</a> (lua_State *L) {
  2700. <a name="l02671"></a>02671 <span class="keywordflow">if</span> (!lua_isstring(L, 1)) <span class="comment">/* &#39;message&#39; not a string? */</span>
  2701. <a name="l02672"></a>02672 <span class="keywordflow">return</span> 1; <span class="comment">/* keep it intact */</span>
  2702. <a name="l02673"></a>02673 lua_getfield(L, LUA_GLOBALSINDEX, <span class="stringliteral">&quot;debug&quot;</span>);
  2703. <a name="l02674"></a>02674 <span class="keywordflow">if</span> (!lua_istable(L, -1)) {
  2704. <a name="l02675"></a>02675 lua_pop(L, 1);
  2705. <a name="l02676"></a>02676 }
  2706. <a name="l02677"></a>02677 lua_getfield(L, -1, <span class="stringliteral">&quot;traceback&quot;</span>);
  2707. <a name="l02678"></a>02678 <span class="keywordflow">if</span> (!lua_isfunction(L, -1)) {
  2708. <a name="l02679"></a>02679 lua_pop(L, 2);
  2709. <a name="l02680"></a>02680 <span class="keywordflow">return</span> 1;
  2710. <a name="l02681"></a>02681 }
  2711. <a name="l02682"></a>02682 lua_pushvalue(L, 1); <span class="comment">/* pass error message */</span>
  2712. <a name="l02683"></a>02683 lua_pushinteger(L, 2); <span class="comment">/* skip this function and traceback */</span>
  2713. <a name="l02684"></a>02684 lua_call(L, 2, 1); <span class="comment">/* call debug.traceback */</span>
  2714. <a name="l02685"></a>02685 <span class="keywordflow">return</span> 1;
  2715. <a name="l02686"></a>02686 }
  2716. <a name="l02687"></a>02687
  2717. <a name="l02688"></a><a class="code" href="classwxLuaState.html#a9359504a70a5819c3c27a14c590d8d46">02688</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a9359504a70a5819c3c27a14c590d8d46">wxLuaState::LuaPCall</a>(<span class="keywordtype">int</span> narg, <span class="keywordtype">int</span> nresults)
  2718. <a name="l02689"></a>02689 {
  2719. <a name="l02690"></a>02690 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), LUA_ERRRUN, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2720. <a name="l02691"></a>02691 lua_State* L = <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State;
  2721. <a name="l02692"></a>02692
  2722. <a name="l02693"></a>02693 <span class="keywordtype">int</span> status = 0;
  2723. <a name="l02694"></a>02694 <span class="keywordtype">int</span> top = lua_gettop(L);
  2724. <a name="l02695"></a>02695 <span class="keywordtype">int</span> base = top - narg; <span class="comment">// function index</span>
  2725. <a name="l02696"></a>02696
  2726. <a name="l02697"></a>02697 lua_pushcfunction(L, <a class="code" href="wxlstate_8cpp.html#a06a0423ee4a323779c83506ab9351421">wxlua_traceback</a>); <span class="comment">// push our traceback function</span>
  2727. <a name="l02698"></a>02698
  2728. <a name="l02699"></a>02699 lua_insert(L, base); <span class="comment">// put it under chunk and args</span>
  2729. <a name="l02700"></a>02700 status = lua_pcall(L, narg, nresults, base);
  2730. <a name="l02701"></a>02701 lua_remove(L, base); <span class="comment">// remove traceback function</span>
  2731. <a name="l02702"></a>02702
  2732. <a name="l02703"></a>02703 <span class="keywordflow">if</span> (status != 0)
  2733. <a name="l02704"></a>02704 {
  2734. <a name="l02705"></a>02705 <a class="code" href="classwxLuaState.html#ac407802949d44c3399686ae6e65d5dc9">SendLuaErrorEvent</a>(status, top - (narg + 1));
  2735. <a name="l02706"></a>02706 lua_settop(L, top); <span class="comment">// restore original top (removes err msg)</span>
  2736. <a name="l02707"></a>02707 }
  2737. <a name="l02708"></a>02708
  2738. <a name="l02709"></a>02709 <span class="keywordflow">return</span> status;
  2739. <a name="l02710"></a>02710 }
  2740. <a name="l02711"></a>02711
  2741. <a name="l02712"></a><a class="code" href="classwxLuaState.html#ac407802949d44c3399686ae6e65d5dc9">02712</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#ac407802949d44c3399686ae6e65d5dc9">wxLuaState::SendLuaErrorEvent</a>(<span class="keywordtype">int</span> status, <span class="keywordtype">int</span> top)
  2742. <a name="l02713"></a>02713 {
  2743. <a name="l02714"></a>02714 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2744. <a name="l02715"></a>02715 wxString errorMsg;
  2745. <a name="l02716"></a>02716 <span class="keywordtype">int</span> line_num = -1;
  2746. <a name="l02717"></a>02717
  2747. <a name="l02718"></a>02718 <a class="code" href="wxlstate_8h.html#a34d4dc64c6615a3e7c4fea5f6fb5840f">wxlua_errorinfo</a>(<a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">GetLuaState</a>(), status, top, &amp;errorMsg, &amp;line_num);
  2748. <a name="l02719"></a>02719
  2749. <a name="l02720"></a>02720 <a class="code" href="classwxLuaEvent.html">wxLuaEvent</a> event(wxEVT_LUA_ERROR, <a class="code" href="classwxLuaState.html#a92715872ca9f5f4b6e77344410963350">GetId</a>(), *<span class="keyword">this</span>);
  2750. <a name="l02721"></a>02721 <span class="keyword">event</span>.SetString(errorMsg);
  2751. <a name="l02722"></a>02722 <span class="keyword">event</span>.SetInt(line_num);
  2752. <a name="l02723"></a>02723 <span class="keywordflow">return</span> <a class="code" href="classwxLuaState.html#a1f0e0a065e8c3ea25c0ebe5c7258f7ae">SendEvent</a>(event);
  2753. <a name="l02724"></a>02724 }
  2754. <a name="l02725"></a>02725
  2755. <a name="l02726"></a><a class="code" href="classwxLuaState.html#a5acf4d28cd89220d9e04ba2e9513a04b">02726</a> wxEventType <a class="code" href="classwxLuaState.html#a5acf4d28cd89220d9e04ba2e9513a04b">wxLuaState::GetInEventType</a>()<span class="keyword"> const</span>
  2756. <a name="l02727"></a>02727 <span class="keyword"></span>{
  2757. <a name="l02728"></a>02728 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxEVT_NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2758. <a name="l02729"></a>02729 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a5442b3e5a2f8dca8fb920c00279385ac">wxlua_getwxeventtype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State);
  2759. <a name="l02730"></a>02730 }
  2760. <a name="l02731"></a>02731
  2761. <a name="l02732"></a><a class="code" href="classwxLuaState.html#a66e0a475e952fd7d6208902cc834ce17">02732</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a66e0a475e952fd7d6208902cc834ce17">wxLuaState::SetInEventType</a>(wxEventType eventType)
  2762. <a name="l02733"></a>02733 {
  2763. <a name="l02734"></a>02734 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2764. <a name="l02735"></a>02735 <a class="code" href="wxlstate_8h.html#a3f5c8427ae033a7da28754a6e37acf0a">wxlua_setwxeventtype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, eventType);
  2765. <a name="l02736"></a>02736 }
  2766. <a name="l02737"></a>02737
  2767. <a name="l02738"></a><a class="code" href="classwxLuaState.html#a193bd4e51c5ce9ddd2e3f1c74114bd13">02738</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a193bd4e51c5ce9ddd2e3f1c74114bd13">wxLuaState::CompileString</a>(<span class="keyword">const</span> wxString &amp;script, <span class="keyword">const</span> wxString&amp; name, wxString* errMsg_, <span class="keywordtype">int</span>* line_num_)
  2768. <a name="l02739"></a>02739 {
  2769. <a name="l02740"></a>02740 <a class="code" href="classwxLuaCharBuffer.html">wxLuaCharBuffer</a> buf(script);
  2770. <a name="l02741"></a>02741 <span class="keywordflow">return</span> <a class="code" href="classwxLuaState.html#a545fe13254b31dc09f7ff870dc5edb89">CompileBuffer</a>(buf.<a class="code" href="classwxLuaCharBuffer.html#a10cddf8fb7f9eea348494ece843f20f6">GetData</a>(), buf.<a class="code" href="classwxLuaCharBuffer.html#a27a6ba04d86b6ebefd310b9e3b001564">Length</a>(), name, errMsg_, line_num_);
  2771. <a name="l02742"></a>02742 }
  2772. <a name="l02743"></a><a class="code" href="classwxLuaState.html#a545fe13254b31dc09f7ff870dc5edb89">02743</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a545fe13254b31dc09f7ff870dc5edb89">wxLuaState::CompileBuffer</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> buf[], <span class="keywordtype">size_t</span> size, <span class="keyword">const</span> wxString &amp;name, wxString* errMsg_, <span class="keywordtype">int</span>* line_num_)
  2773. <a name="l02744"></a>02744 {
  2774. <a name="l02745"></a>02745 <span class="comment">// create a new lua_State so we don&#39;t mess up our own</span>
  2775. <a name="l02746"></a>02746 lua_State *L = lua_open();
  2776. <a name="l02747"></a>02747 luaL_openlibs(L); <span class="comment">// load some useful libraries, loads all of them</span>
  2777. <a name="l02748"></a>02748 <span class="keywordtype">int</span> top = lua_gettop(L);
  2778. <a name="l02749"></a>02749 <span class="keywordtype">int</span> status = luaL_loadbuffer(L, (<span class="keyword">const</span> <span class="keywordtype">char</span>*)buf, size, <a class="code" href="wxlstate_8h.html#a41976a7549ef4bfa7e9a1147dc7b4d55">wx2lua</a>(name));
  2779. <a name="l02750"></a>02750 <a class="code" href="wxlstate_8h.html#a34d4dc64c6615a3e7c4fea5f6fb5840f">wxlua_errorinfo</a>(L, status, top, errMsg_, line_num_);
  2780. <a name="l02751"></a>02751 lua_close(L);
  2781. <a name="l02752"></a>02752 <span class="keywordflow">return</span> status;
  2782. <a name="l02753"></a>02753 }
  2783. <a name="l02754"></a>02754
  2784. <a name="l02755"></a><a class="code" href="classwxLuaState.html#ad81c2d1ae33f1c58bc4b53d3718cc14b">02755</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#ad81c2d1ae33f1c58bc4b53d3718cc14b">wxLuaState::DebugHookBreak</a>(<span class="keyword">const</span> wxString &amp;msg)
  2785. <a name="l02756"></a>02756 {
  2786. <a name="l02757"></a>02757 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2787. <a name="l02758"></a>02758 wxCHECK_RET(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_is_running, wxT(<span class="stringliteral">&quot;Lua interpreter not running&quot;</span>));
  2788. <a name="l02759"></a>02759
  2789. <a name="l02760"></a>02760 <span class="comment">// Lua likes to be stopped within the debug hook, you get funny wxYield</span>
  2790. <a name="l02761"></a>02761 <span class="comment">// recursion asserts if you call wxlua_Error() within another wxYield, i.e. from a gui button</span>
  2791. <a name="l02762"></a>02762
  2792. <a name="l02763"></a>02763 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_debug_hook_break_msg = msg;
  2793. <a name="l02764"></a>02764 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_debug_hook_break = <span class="keyword">true</span>;
  2794. <a name="l02765"></a>02765 lua_sethook(<a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">GetLuaState</a>(), <a class="code" href="wxlstate_8cpp.html#a9eab35a72e3a0d8e1a669fb831a5272d">wxlua_debugHookFunction</a>, LUA_MASKCALL|LUA_MASKRET|LUA_MASKLINE|LUA_MASKCOUNT, 1);
  2795. <a name="l02766"></a>02766 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_is_running = <span class="keyword">false</span>;
  2796. <a name="l02767"></a>02767 }
  2797. <a name="l02768"></a>02768
  2798. <a name="l02769"></a><a class="code" href="classwxLuaState.html#a61b2c790f1b50df9c8b41ef6cc8e58e9">02769</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a61b2c790f1b50df9c8b41ef6cc8e58e9">wxLuaState::ClearDebugHookBreak</a>()
  2799. <a name="l02770"></a>02770 {
  2800. <a name="l02771"></a>02771 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2801. <a name="l02772"></a>02772
  2802. <a name="l02773"></a>02773 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_debug_hook_break = <span class="keyword">false</span>;
  2803. <a name="l02774"></a>02774 <a class="code" href="classwxLuaState.html#a2b8ab0b1fa506b5e33006617d5a9928f">SetLuaDebugHook</a>(<a class="code" href="classwxLuaState.html#a42352f303a4f154d690d9b76161e5665">GetLuaDebugHookCount</a>(),
  2804. <a name="l02775"></a>02775 <a class="code" href="classwxLuaState.html#a5676b5639a6b274b227ab8f7e4aee69a">GetLuaDebugHookYield</a>(),
  2805. <a name="l02776"></a>02776 <a class="code" href="classwxLuaState.html#aa120c49f0b9c203990abf7ba344618db">GetLuaDebugHookSendEvt</a>(),
  2806. <a name="l02777"></a>02777 <a class="code" href="classwxLuaState.html#a0340c32927e3740c2fa0b3290daf663a">GetLuaDebugHook</a>());
  2807. <a name="l02778"></a>02778 }
  2808. <a name="l02779"></a>02779
  2809. <a name="l02780"></a><a class="code" href="classwxLuaState.html#a0cf13f6fd1ca742c77727798a6cb66fd">02780</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a0cf13f6fd1ca742c77727798a6cb66fd">wxLuaState::GetDebugHookBreak</a>()<span class="keyword"> const</span>
  2810. <a name="l02781"></a>02781 <span class="keyword"></span>{
  2811. <a name="l02782"></a>02782 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2812. <a name="l02783"></a>02783 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_debug_hook_break;
  2813. <a name="l02784"></a>02784 }
  2814. <a name="l02785"></a><a class="code" href="classwxLuaState.html#a1f7dfcadd9b74ce7ca3152a423c6ada6">02785</a> wxString <a class="code" href="classwxLuaState.html#a1f7dfcadd9b74ce7ca3152a423c6ada6">wxLuaState::GetDebugHookBreakMessage</a>()<span class="keyword"> const</span>
  2815. <a name="l02786"></a>02786 <span class="keyword"></span>{
  2816. <a name="l02787"></a>02787 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2817. <a name="l02788"></a>02788 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_debug_hook_break_msg;
  2818. <a name="l02789"></a>02789 }
  2819. <a name="l02790"></a>02790
  2820. <a name="l02791"></a>02791 <span class="comment">// ----------------------------------------------------------------------------</span>
  2821. <a name="l02792"></a>02792
  2822. <a name="l02793"></a><a class="code" href="classwxLuaState.html#a2b8ab0b1fa506b5e33006617d5a9928f">02793</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a2b8ab0b1fa506b5e33006617d5a9928f">wxLuaState::SetLuaDebugHook</a>(<span class="keywordtype">int</span> hook, <span class="keywordtype">int</span> count, <span class="keywordtype">int</span> yield_ms, <span class="keywordtype">bool</span> send_debug_evt)
  2823. <a name="l02794"></a>02794 {
  2824. <a name="l02795"></a>02795 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2825. <a name="l02796"></a>02796
  2826. <a name="l02797"></a>02797 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_lua_debug_hook = hook;
  2827. <a name="l02798"></a>02798 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_lua_debug_hook_count = count;
  2828. <a name="l02799"></a>02799 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_lua_debug_hook_yield = yield_ms;
  2829. <a name="l02800"></a>02800 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_lua_debug_hook_send_evt = send_debug_evt;
  2830. <a name="l02801"></a>02801
  2831. <a name="l02802"></a>02802 <span class="comment">// These are the various hooks you can install</span>
  2832. <a name="l02803"></a>02803 <span class="comment">//LUA_MASKCALL, LUA_MASKRET, LUA_MASKLINE, and LUA_MASKCOUNT</span>
  2833. <a name="l02804"></a>02804 lua_sethook(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, <a class="code" href="wxlstate_8cpp.html#a9eab35a72e3a0d8e1a669fb831a5272d">wxlua_debugHookFunction</a>, hook, count);
  2834. <a name="l02805"></a>02805 }
  2835. <a name="l02806"></a>02806
  2836. <a name="l02807"></a><a class="code" href="classwxLuaState.html#a0340c32927e3740c2fa0b3290daf663a">02807</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a0340c32927e3740c2fa0b3290daf663a">wxLuaState::GetLuaDebugHook</a>()<span class="keyword"> const</span>
  2837. <a name="l02808"></a>02808 <span class="keyword"></span>{
  2838. <a name="l02809"></a>02809 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2839. <a name="l02810"></a>02810 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_lua_debug_hook;
  2840. <a name="l02811"></a>02811 }
  2841. <a name="l02812"></a><a class="code" href="classwxLuaState.html#a42352f303a4f154d690d9b76161e5665">02812</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a42352f303a4f154d690d9b76161e5665">wxLuaState::GetLuaDebugHookCount</a>()<span class="keyword"> const</span>
  2842. <a name="l02813"></a>02813 <span class="keyword"></span>{
  2843. <a name="l02814"></a>02814 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2844. <a name="l02815"></a>02815 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_lua_debug_hook_count;
  2845. <a name="l02816"></a>02816 }
  2846. <a name="l02817"></a><a class="code" href="classwxLuaState.html#a5676b5639a6b274b227ab8f7e4aee69a">02817</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a5676b5639a6b274b227ab8f7e4aee69a">wxLuaState::GetLuaDebugHookYield</a>()<span class="keyword"> const</span>
  2847. <a name="l02818"></a>02818 <span class="keyword"></span>{
  2848. <a name="l02819"></a>02819 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2849. <a name="l02820"></a>02820 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_lua_debug_hook_yield;
  2850. <a name="l02821"></a>02821 }
  2851. <a name="l02822"></a><a class="code" href="classwxLuaState.html#aa120c49f0b9c203990abf7ba344618db">02822</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#aa120c49f0b9c203990abf7ba344618db">wxLuaState::GetLuaDebugHookSendEvt</a>()<span class="keyword"> const</span>
  2852. <a name="l02823"></a>02823 <span class="keyword"></span>{
  2853. <a name="l02824"></a>02824 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2854. <a name="l02825"></a>02825 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_lua_debug_hook_send_evt;
  2855. <a name="l02826"></a>02826 }
  2856. <a name="l02827"></a>02827
  2857. <a name="l02828"></a><a class="code" href="classwxLuaState.html#a7aa7718bb77198c813f48f00c268bede">02828</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classwxLuaState.html#a7aa7718bb77198c813f48f00c268bede">wxLuaState::GetLastLuaDebugHookTime</a>()<span class="keyword"> const</span>
  2858. <a name="l02829"></a>02829 <span class="keyword"></span>{
  2859. <a name="l02830"></a>02830 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2860. <a name="l02831"></a>02831 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_last_debug_hook_time;
  2861. <a name="l02832"></a>02832 }
  2862. <a name="l02833"></a><a class="code" href="classwxLuaState.html#a02c1bc02032a04227f692e9bb2262292">02833</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a02c1bc02032a04227f692e9bb2262292">wxLuaState::SetLastLuaDebugHookTime</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> t)
  2863. <a name="l02834"></a>02834 {
  2864. <a name="l02835"></a>02835 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2865. <a name="l02836"></a>02836 <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_wxlStateData-&gt;m_last_debug_hook_time = t;
  2866. <a name="l02837"></a>02837 }
  2867. <a name="l02838"></a>02838
  2868. <a name="l02839"></a>02839 <span class="comment">// ----------------------------------------------------------------------------</span>
  2869. <a name="l02840"></a>02840
  2870. <a name="l02841"></a><a class="code" href="classwxLuaState.html#a0e1287b64bb07f12f4a55d5f9b0ba8c7">02841</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a0e1287b64bb07f12f4a55d5f9b0ba8c7">wxLuaState::RegisterFunction</a>(lua_CFunction func, <span class="keyword">const</span> <span class="keywordtype">char</span>* funcName)
  2871. <a name="l02842"></a>02842 {
  2872. <a name="l02843"></a>02843 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2873. <a name="l02844"></a>02844 lua_register( <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, funcName, func );
  2874. <a name="l02845"></a>02845 }
  2875. <a name="l02846"></a>02846
  2876. <a name="l02847"></a><a class="code" href="classwxLuaState.html#a51765af55c10f920b3de2c7bb60f0570">02847</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a51765af55c10f920b3de2c7bb60f0570">wxLuaState::RegisterBinding</a>(<a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding)
  2877. <a name="l02848"></a>02848 {
  2878. <a name="l02849"></a>02849 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2879. <a name="l02850"></a>02850 wxCHECK_MSG(binding, <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2880. <a name="l02851"></a>02851
  2881. <a name="l02852"></a>02852 <a class="code" href="classwxLuaBinding.html#aba730ce7a36b85518da9ed7858c13d91">wxLuaBinding::InitAllBindings</a>(); <span class="comment">// only runs the first time through</span>
  2882. <a name="l02853"></a>02853
  2883. <a name="l02854"></a>02854 <span class="keywordtype">bool</span> ret = binding-&gt;<a class="code" href="classwxLuaBinding.html#a56f0796417c56b0ecee1366ec68484aa">RegisterBinding</a>(*<span class="keyword">this</span>);
  2884. <a name="l02855"></a>02855 <span class="keywordflow">if</span> (ret) <a class="code" href="classwxLuaState.html#a2efa05a8ce69d8344c5ea14b4fe02bf0">lua_Pop</a>(1);
  2885. <a name="l02856"></a>02856
  2886. <a name="l02857"></a>02857 <span class="keywordflow">return</span> ret;
  2887. <a name="l02858"></a>02858 }
  2888. <a name="l02859"></a>02859
  2889. <a name="l02860"></a><a class="code" href="classwxLuaState.html#a32b493d7437004027b3e7f20799e6e18">02860</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a32b493d7437004027b3e7f20799e6e18">wxLuaState::RegisterBindings</a>()
  2890. <a name="l02861"></a>02861 {
  2891. <a name="l02862"></a>02862 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2892. <a name="l02863"></a>02863 <a class="code" href="classwxLuaBinding.html#aba730ce7a36b85518da9ed7858c13d91">wxLuaBinding::InitAllBindings</a>(); <span class="comment">// only runs the first time through</span>
  2893. <a name="l02864"></a>02864
  2894. <a name="l02865"></a>02865 <span class="comment">// Register bindings</span>
  2895. <a name="l02866"></a>02866 wxLuaBindingList::compatibility_iterator node = <a class="code" href="classwxLuaBinding.html#a8a87ea1c329629e69266ea82196e681c">wxLuaBinding::GetBindingList</a>()-&gt;GetFirst();
  2896. <a name="l02867"></a>02867 <span class="keywordflow">while</span> (node)
  2897. <a name="l02868"></a>02868 {
  2898. <a name="l02869"></a>02869 <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding = node-&gt;GetData();
  2899. <a name="l02870"></a>02870 binding-&gt;<a class="code" href="classwxLuaBinding.html#a56f0796417c56b0ecee1366ec68484aa">RegisterBinding</a>(*<span class="keyword">this</span>);
  2900. <a name="l02871"></a>02871 <a class="code" href="classwxLuaState.html#a2efa05a8ce69d8344c5ea14b4fe02bf0">lua_Pop</a>(1); <span class="comment">// pop the Lua table the binding was installed into</span>
  2901. <a name="l02872"></a>02872
  2902. <a name="l02873"></a>02873 node = node-&gt;GetNext();
  2903. <a name="l02874"></a>02874 }
  2904. <a name="l02875"></a>02875
  2905. <a name="l02876"></a>02876 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  2906. <a name="l02877"></a>02877 }
  2907. <a name="l02878"></a>02878
  2908. <a name="l02879"></a><a class="code" href="classwxLuaState.html#ae89620a3a838e95e98e1335c9bad76b5">02879</a> <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* <a class="code" href="classwxLuaState.html#ae89620a3a838e95e98e1335c9bad76b5">wxLuaState::GetLuaBinding</a>(<span class="keyword">const</span> wxString&amp; bindingName)<span class="keyword"> const</span>
  2909. <a name="l02880"></a>02880 <span class="keyword"></span>{
  2910. <a name="l02881"></a>02881 wxCHECK_MSG(GetRefData() != NULL, NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2911. <a name="l02882"></a>02882 <span class="keywordflow">return</span> <a class="code" href="classwxLuaState.html#ae89620a3a838e95e98e1335c9bad76b5">wxLuaBinding::GetLuaBinding</a>(bindingName);
  2912. <a name="l02883"></a>02883 }
  2913. <a name="l02884"></a>02884
  2914. <a name="l02885"></a><a class="code" href="classwxLuaState.html#a40bd580168967f978143eadfcbc43aa5">02885</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* <a class="code" href="classwxLuaState.html#a40bd580168967f978143eadfcbc43aa5">wxLuaState::GetBindClass</a>(<span class="keywordtype">int</span> wxluatype)<span class="keyword"> const</span>
  2915. <a name="l02886"></a>02886 <span class="keyword"></span>{
  2916. <a name="l02887"></a>02887 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2917. <a name="l02888"></a>02888
  2918. <a name="l02889"></a>02889 <span class="comment">// try to get the wxLuaBindClass from the Lua registry table first</span>
  2919. <a name="l02890"></a>02890 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = <a class="code" href="wxlstate_8h.html#a4a7a8f2cc1d3b1ba337295b6d02ab97f">wxluaT_getclass</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, wxluatype);
  2920. <a name="l02891"></a>02891
  2921. <a name="l02892"></a>02892 <span class="comment">// we shouldn&#39;t ever need this code</span>
  2922. <a name="l02893"></a>02893 <span class="keywordflow">if</span> (wxlClass == NULL)
  2923. <a name="l02894"></a>02894 wxlClass = <a class="code" href="classwxLuaBinding.html#a7ee5e4f66198a0ef9e8cc4c2a6d0318e">wxLuaBinding::FindBindClass</a>(wxluatype);
  2924. <a name="l02895"></a>02895
  2925. <a name="l02896"></a>02896 <span class="keywordflow">return</span> wxlClass;
  2926. <a name="l02897"></a>02897 }
  2927. <a name="l02898"></a><a class="code" href="classwxLuaState.html#a40aca6b31d2dc967536d697fea9a9608">02898</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* <a class="code" href="classwxLuaState.html#a40bd580168967f978143eadfcbc43aa5">wxLuaState::GetBindClass</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* className)<span class="keyword"> const</span>
  2928. <a name="l02899"></a>02899 <span class="keyword"></span>{
  2929. <a name="l02900"></a>02900 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2930. <a name="l02901"></a>02901 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a4a7a8f2cc1d3b1ba337295b6d02ab97f">wxluaT_getclass</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, className);
  2931. <a name="l02902"></a>02902 }
  2932. <a name="l02903"></a><a class="code" href="classwxLuaState.html#aeab98c09392147f1121ec0cbca27d6c4">02903</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* <a class="code" href="classwxLuaState.html#a40bd580168967f978143eadfcbc43aa5">wxLuaState::GetBindClass</a>(<span class="keyword">const</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod)<span class="keyword"> const</span>
  2933. <a name="l02904"></a>02904 <span class="keyword"></span>{
  2934. <a name="l02905"></a>02905 wxCHECK_MSG(GetRefData() != NULL, NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2935. <a name="l02906"></a>02906 <span class="keywordflow">return</span> <a class="code" href="classwxLuaBinding.html#a7ee5e4f66198a0ef9e8cc4c2a6d0318e">wxLuaBinding::FindBindClass</a>(wxlMethod);
  2936. <a name="l02907"></a>02907 }
  2937. <a name="l02908"></a><a class="code" href="classwxLuaState.html#ab1217fd9674e516833ad0b3dcfd30045">02908</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* <a class="code" href="classwxLuaState.html#a40bd580168967f978143eadfcbc43aa5">wxLuaState::GetBindClass</a>(<span class="keyword">const</span> <a class="code" href="structwxLuaBindCFunc.html">wxLuaBindCFunc</a>* wxlClass)<span class="keyword"> const</span>
  2938. <a name="l02909"></a>02909 <span class="keyword"></span>{
  2939. <a name="l02910"></a>02910 wxCHECK_MSG(GetRefData() != NULL, NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2940. <a name="l02911"></a>02911 <span class="keywordflow">return</span> <a class="code" href="classwxLuaBinding.html#a7ee5e4f66198a0ef9e8cc4c2a6d0318e">wxLuaBinding::FindBindClass</a>(wxlClass);
  2941. <a name="l02912"></a>02912 }
  2942. <a name="l02913"></a>02913
  2943. <a name="l02914"></a><a class="code" href="classwxLuaState.html#a3134431b4b1c175f0185776bc8297126">02914</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a3134431b4b1c175f0185776bc8297126">wxLuaState::IsDerivedType</a>(<span class="keywordtype">int</span> wxl_type, <span class="keywordtype">int</span> base_wxl_type)<span class="keyword"> const</span>
  2944. <a name="l02915"></a>02915 <span class="keyword"></span>{
  2945. <a name="l02916"></a>02916 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), -1, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2946. <a name="l02917"></a>02917 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a1a5e4f51c5902cbd8e3047f7a99b871d">wxluaT_isderivedtype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, wxl_type, base_wxl_type);
  2947. <a name="l02918"></a>02918 }
  2948. <a name="l02919"></a>02919
  2949. <a name="l02920"></a><a class="code" href="classwxLuaState.html#abe8b0a31282c3e7e02a277502224109c">02920</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindEvent.html">wxLuaBindEvent</a>* <a class="code" href="classwxLuaState.html#abe8b0a31282c3e7e02a277502224109c">wxLuaState::GetBindEvent</a>(wxEventType eventType)<span class="keyword"> const</span>
  2950. <a name="l02921"></a>02921 <span class="keyword"></span>{
  2951. <a name="l02922"></a>02922 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2952. <a name="l02923"></a>02923 <span class="keywordflow">return</span> <a class="code" href="classwxLuaBinding.html#acb5add21a46e8c314d94069bb639ca96">wxLuaBinding::FindBindEvent</a>(eventType);
  2953. <a name="l02924"></a>02924 }
  2954. <a name="l02925"></a>02925
  2955. <a name="l02926"></a><a class="code" href="classwxLuaState.html#ae817c75f3042c9528bc537c334715285">02926</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#ae817c75f3042c9528bc537c334715285">wxLuaState::SetCallBaseClassFunction</a>(<span class="keywordtype">bool</span> call_base)
  2956. <a name="l02927"></a>02927 {
  2957. <a name="l02928"></a>02928 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2958. <a name="l02929"></a>02929 <a class="code" href="wxlstate_8h.html#a9d1c33c0999cd1ea92d9dafb83196fa8">wxlua_setcallbaseclassfunction</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, call_base);
  2959. <a name="l02930"></a>02930 }
  2960. <a name="l02931"></a><a class="code" href="classwxLuaState.html#a8acd73b75948fe0cd093657feaaf912f">02931</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a8acd73b75948fe0cd093657feaaf912f">wxLuaState::GetCallBaseClassFunction</a>()
  2961. <a name="l02932"></a>02932 {
  2962. <a name="l02933"></a>02933 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2963. <a name="l02934"></a>02934 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a99b292a455b84ee8f2f701ff3619d1f7">wxlua_getcallbaseclassfunction</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State);
  2964. <a name="l02935"></a>02935 }
  2965. <a name="l02936"></a>02936
  2966. <a name="l02937"></a>02937 <span class="comment">// ----------------------------------------------------------------------------</span>
  2967. <a name="l02938"></a>02938 <span class="comment">// memory tracking functions</span>
  2968. <a name="l02939"></a>02939
  2969. <a name="l02940"></a><a class="code" href="classwxLuaState.html#a82b2b342c1436840165274ed7d19e59b">02940</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a82b2b342c1436840165274ed7d19e59b">wxLuaState::AddGCObject</a>(wxObject *wxobj)
  2970. <a name="l02941"></a>02941 {
  2971. <a name="l02942"></a>02942 <a class="code" href="classwxLuaState.html#a82b2b342c1436840165274ed7d19e59b">AddGCObject</a>(wxobj, wxobj);
  2972. <a name="l02943"></a>02943 }
  2973. <a name="l02944"></a>02944
  2974. <a name="l02945"></a><a class="code" href="classwxLuaState.html#a1e464842e0ffed5660c738d14e15eba2">02945</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a82b2b342c1436840165274ed7d19e59b">wxLuaState::AddGCObject</a>(<span class="keywordtype">void</span>* obj_ptr, wxObject *wxobj)
  2975. <a name="l02946"></a>02946 {
  2976. <a name="l02947"></a>02947 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>() &amp;&amp; wxobj, wxT(<span class="stringliteral">&quot;Invalid wxLuaState or wxObject to track&quot;</span>));
  2977. <a name="l02948"></a>02948 <a class="code" href="wxlstate_8h.html#a0f23c00339db80dbf392740133c531aa">wxluaO_addgcobject</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, obj_ptr, wxobj);
  2978. <a name="l02949"></a>02949 }
  2979. <a name="l02950"></a>02950
  2980. <a name="l02951"></a><a class="code" href="classwxLuaState.html#a6c037661ddd41d504290eb087d5a8cad">02951</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a6c037661ddd41d504290eb087d5a8cad">wxLuaState::DeleteGCObject</a>(<span class="keywordtype">void</span>* udata, <span class="keywordtype">void</span> *obj_ptr, <span class="keywordtype">int</span> flags)
  2981. <a name="l02952"></a>02952 {
  2982. <a name="l02953"></a>02953 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>() &amp;&amp; obj_ptr, <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState or object&quot;</span>));
  2983. <a name="l02954"></a>02954 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#aba83aa14c215deca6e72da965f29c4a4">wxluaO_deletegcobject</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, udata, obj_ptr, flags);
  2984. <a name="l02955"></a>02955 }
  2985. <a name="l02956"></a>02956
  2986. <a name="l02957"></a><a class="code" href="classwxLuaState.html#a0fdff75d324d209be0bd0da623eb379e">02957</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a0fdff75d324d209be0bd0da623eb379e">wxLuaState::IsGCObject</a>(<span class="keywordtype">void</span> *obj_ptr)<span class="keyword"> const</span>
  2987. <a name="l02958"></a>02958 <span class="keyword"></span>{
  2988. <a name="l02959"></a>02959 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2989. <a name="l02960"></a>02960 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a10a0351ed2d2abe300bf0e5db307cdd0">wxluaO_isgcobject</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, obj_ptr);
  2990. <a name="l02961"></a>02961 }
  2991. <a name="l02962"></a>02962
  2992. <a name="l02963"></a><a class="code" href="classwxLuaState.html#ab6703f46e27322f0e4aface6280d3177">02963</a> wxArrayString <a class="code" href="classwxLuaState.html#ab6703f46e27322f0e4aface6280d3177">wxLuaState::GetGCObjectInfo</a>()<span class="keyword"> const</span>
  2993. <a name="l02964"></a>02964 <span class="keyword"></span>{
  2994. <a name="l02965"></a>02965 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxArrayString(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  2995. <a name="l02966"></a>02966 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a1731f8112f747955ec5f3c15232429ba">wxluaO_getgcobjectinfo</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State);
  2996. <a name="l02967"></a>02967 }
  2997. <a name="l02968"></a>02968
  2998. <a name="l02969"></a><a class="code" href="classwxLuaState.html#a6b953ba5f704158bb8ccb39b29f4ed7d">02969</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a6b953ba5f704158bb8ccb39b29f4ed7d">wxLuaState::AddTrackedWindow</a>(wxObject *obj)
  2999. <a name="l02970"></a>02970 {
  3000. <a name="l02971"></a>02971 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3001. <a name="l02972"></a>02972 <a class="code" href="wxlstate_8h.html#a6acba6e5567b9a9c3d3e90f6fdb42456">wxluaW_addtrackedwindow</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, obj);
  3002. <a name="l02973"></a>02973 }
  3003. <a name="l02974"></a>02974
  3004. <a name="l02975"></a><a class="code" href="classwxLuaState.html#aa94f7693d356d05c4b5fc2019fe02031">02975</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#aa94f7693d356d05c4b5fc2019fe02031">wxLuaState::RemoveTrackedWindow</a>(wxWindow *win)
  3005. <a name="l02976"></a>02976 {
  3006. <a name="l02977"></a>02977 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>() &amp;&amp; win, wxT(<span class="stringliteral">&quot;Invalid wxLuaState or wxWindow&quot;</span>));
  3007. <a name="l02978"></a>02978 <a class="code" href="wxlstate_8h.html#af1bf3244574d51336b5efb38479c103f">wxluaW_removetrackedwindow</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, win);
  3008. <a name="l02979"></a>02979 }
  3009. <a name="l02980"></a>02980
  3010. <a name="l02981"></a><a class="code" href="classwxLuaState.html#a45e2022d6f25101e9ae8ee71a30a7f09">02981</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a45e2022d6f25101e9ae8ee71a30a7f09">wxLuaState::IsTrackedWindow</a>(wxWindow *win, <span class="keywordtype">bool</span> check_parents)<span class="keyword"> const</span>
  3011. <a name="l02982"></a>02982 <span class="keyword"></span>{
  3012. <a name="l02983"></a>02983 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>() &amp;&amp; win, <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState or wxWindow&quot;</span>));
  3013. <a name="l02984"></a>02984 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a1ea46fab0293690fb38fb3cee9ffccd0">wxluaW_istrackedwindow</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, win, check_parents);
  3014. <a name="l02985"></a>02985 }
  3015. <a name="l02986"></a>02986
  3016. <a name="l02987"></a><a class="code" href="classwxLuaState.html#a63c0cc3bdcf26acefe7385599cb55153">02987</a> wxArrayString <a class="code" href="classwxLuaState.html#a63c0cc3bdcf26acefe7385599cb55153">wxLuaState::GetTrackedWindowInfo</a>()<span class="keyword"> const</span>
  3017. <a name="l02988"></a>02988 <span class="keyword"></span>{
  3018. <a name="l02989"></a>02989 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxArrayString(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3019. <a name="l02990"></a>02990 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#affb2d1ff4f80af7ac7bb6a39ea15a70d">wxluaW_gettrackedwindowinfo</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State);
  3020. <a name="l02991"></a>02991 }
  3021. <a name="l02992"></a>02992
  3022. <a name="l02993"></a><a class="code" href="classwxLuaState.html#af8b396a0deb4fd38bb2a0e6110a1a9b6">02993</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#af8b396a0deb4fd38bb2a0e6110a1a9b6">wxLuaState::GarbageCollectWindows</a>(<span class="keywordtype">bool</span> closeWindows)
  3023. <a name="l02994"></a>02994 {
  3024. <a name="l02995"></a>02995 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3025. <a name="l02996"></a>02996 <span class="comment">// remove deleted windows</span>
  3026. <a name="l02997"></a>02997 <a class="code" href="wxlstate_8cpp.html#aee3f23bcdaad403338f32516e4489796">wxLuaCleanupWindows</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, !closeWindows);
  3027. <a name="l02998"></a>02998 }
  3028. <a name="l02999"></a>02999
  3029. <a name="l03000"></a><a class="code" href="classwxLuaState.html#a4d98dc069a76be3a6bd87ee957ba7b2a">03000</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a4d98dc069a76be3a6bd87ee957ba7b2a">wxLuaState::AddTrackedEventCallback</a>(<a class="code" href="classwxLuaEventCallback.html">wxLuaEventCallback</a>* callback)
  3030. <a name="l03001"></a>03001 {
  3031. <a name="l03002"></a>03002 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3032. <a name="l03003"></a>03003 lua_State* L = <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State;
  3033. <a name="l03004"></a>03004
  3034. <a name="l03005"></a>03005 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a034985fb7df51670c3b6a024329496fa">wxlua_lreg_evtcallbacks_key</a>); <span class="comment">// push key</span>
  3035. <a name="l03006"></a>03006 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  3036. <a name="l03007"></a>03007
  3037. <a name="l03008"></a>03008 lua_pushlightuserdata(L, callback); <span class="comment">// push key</span>
  3038. <a name="l03009"></a>03009 lua_pushlightuserdata(L, callback-&gt;<a class="code" href="classwxLuaEventCallback.html#a43a1795558a72d6ba6f4f5a563d7a8e6">GetEvtHandler</a>()); <span class="comment">// push value</span>
  3039. <a name="l03010"></a>03010 lua_rawset(L, -3); <span class="comment">// set t[key] = value; pops key and value</span>
  3040. <a name="l03011"></a>03011
  3041. <a name="l03012"></a>03012 lua_pop(L, 1); <span class="comment">// pop table</span>
  3042. <a name="l03013"></a>03013 }
  3043. <a name="l03014"></a><a class="code" href="classwxLuaState.html#ad2dcccb0c2ceb53b801faf492b513044">03014</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#ad2dcccb0c2ceb53b801faf492b513044">wxLuaState::RemoveTrackedEventCallback</a>(<a class="code" href="classwxLuaEventCallback.html">wxLuaEventCallback</a>* callback)
  3044. <a name="l03015"></a>03015 {
  3045. <a name="l03016"></a>03016 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3046. <a name="l03017"></a>03017 lua_State* L = <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State;
  3047. <a name="l03018"></a>03018
  3048. <a name="l03019"></a>03019 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a034985fb7df51670c3b6a024329496fa">wxlua_lreg_evtcallbacks_key</a>); <span class="comment">// push key</span>
  3049. <a name="l03020"></a>03020 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  3050. <a name="l03021"></a>03021
  3051. <a name="l03022"></a>03022 lua_pushlightuserdata(L, callback); <span class="comment">// push key</span>
  3052. <a name="l03023"></a>03023 lua_pushnil(L); <span class="comment">// push value</span>
  3053. <a name="l03024"></a>03024 lua_rawset(L, -3); <span class="comment">// set t[key] = value; pops key and value</span>
  3054. <a name="l03025"></a>03025
  3055. <a name="l03026"></a>03026 lua_pop(L, 1); <span class="comment">// pop table</span>
  3056. <a name="l03027"></a>03027
  3057. <a name="l03028"></a>03028 <span class="keywordflow">return</span> <span class="keyword">true</span>; <span class="comment">// FIXME return a real value</span>
  3058. <a name="l03029"></a>03029 }
  3059. <a name="l03030"></a>03030
  3060. <a name="l03031"></a><a class="code" href="classwxLuaState.html#aea8e44598ddfdcba9939c86fba60056b">03031</a> wxArrayString <a class="code" href="classwxLuaState.html#aea8e44598ddfdcba9939c86fba60056b">wxLuaState::GetTrackedEventCallbackInfo</a>()<span class="keyword"> const</span>
  3061. <a name="l03032"></a>03032 <span class="keyword"></span>{
  3062. <a name="l03033"></a>03033 wxArrayString names;
  3063. <a name="l03034"></a>03034
  3064. <a name="l03035"></a>03035 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), names, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3065. <a name="l03036"></a>03036 lua_State* L = <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State;
  3066. <a name="l03037"></a>03037
  3067. <a name="l03038"></a>03038 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a034985fb7df51670c3b6a024329496fa">wxlua_lreg_evtcallbacks_key</a>); <span class="comment">// push key</span>
  3068. <a name="l03039"></a>03039 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  3069. <a name="l03040"></a>03040
  3070. <a name="l03041"></a>03041 lua_pushnil(L);
  3071. <a name="l03042"></a>03042 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
  3072. <a name="l03043"></a>03043 {
  3073. <a name="l03044"></a>03044 <span class="comment">// value = -1, key = -2, table = -3</span>
  3074. <a name="l03045"></a>03045 <a class="code" href="classwxLuaEventCallback.html">wxLuaEventCallback</a>* wxlCallback = (<a class="code" href="classwxLuaEventCallback.html">wxLuaEventCallback</a>*)lua_touserdata(L, -2);
  3075. <a name="l03046"></a>03046 wxCHECK_MSG(wxlCallback, names, wxT(<span class="stringliteral">&quot;Invalid wxLuaEventCallback&quot;</span>));
  3076. <a name="l03047"></a>03047
  3077. <a name="l03048"></a>03048 names.Add(wxlCallback-&gt;<a class="code" href="classwxLuaEventCallback.html#a7d2dbf42ab8d4ddc22df1bd75ab095b6">GetInfo</a>());
  3078. <a name="l03049"></a>03049
  3079. <a name="l03050"></a>03050 lua_pop(L, 1); <span class="comment">// pop value, lua_next will pop key at end</span>
  3080. <a name="l03051"></a>03051 }
  3081. <a name="l03052"></a>03052
  3082. <a name="l03053"></a>03053 lua_pop(L, 1); <span class="comment">// pop table</span>
  3083. <a name="l03054"></a>03054
  3084. <a name="l03055"></a>03055 names.Sort();
  3085. <a name="l03056"></a>03056 <span class="keywordflow">return</span> names;
  3086. <a name="l03057"></a>03057 }
  3087. <a name="l03058"></a>03058
  3088. <a name="l03059"></a><a class="code" href="classwxLuaState.html#abadd6ad48428db83e226bbf1b900f450">03059</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#abadd6ad48428db83e226bbf1b900f450">wxLuaState::AddTrackedWinDestroyCallback</a>(<a class="code" href="classwxLuaWinDestroyCallback.html">wxLuaWinDestroyCallback</a>* callback)
  3089. <a name="l03060"></a>03060 {
  3090. <a name="l03061"></a>03061 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3091. <a name="l03062"></a>03062 lua_State* L = <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State;
  3092. <a name="l03063"></a>03063
  3093. <a name="l03064"></a>03064 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#ae13b14073477671929c41823f198c33d">wxlua_lreg_windestroycallbacks_key</a>); <span class="comment">// push key</span>
  3094. <a name="l03065"></a>03065 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  3095. <a name="l03066"></a>03066
  3096. <a name="l03067"></a>03067 lua_pushlightuserdata(L, callback-&gt;<a class="code" href="classwxLuaWinDestroyCallback.html#ae2572b116622d6d8af56593ef68d923e">GetWindow</a>()); <span class="comment">// push key</span>
  3097. <a name="l03068"></a>03068 lua_pushlightuserdata(L, callback); <span class="comment">// push value</span>
  3098. <a name="l03069"></a>03069 lua_rawset(L, -3); <span class="comment">// set t[key] = value; pops key and value</span>
  3099. <a name="l03070"></a>03070
  3100. <a name="l03071"></a>03071 lua_pop(L, 1); <span class="comment">// pop table</span>
  3101. <a name="l03072"></a>03072 }
  3102. <a name="l03073"></a><a class="code" href="classwxLuaState.html#a871e9608f89114885a076d2c11605fa4">03073</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a871e9608f89114885a076d2c11605fa4">wxLuaState::RemoveTrackedWinDestroyCallback</a>(<a class="code" href="classwxLuaWinDestroyCallback.html">wxLuaWinDestroyCallback</a>* callback)
  3103. <a name="l03074"></a>03074 {
  3104. <a name="l03075"></a>03075 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3105. <a name="l03076"></a>03076 lua_State* L = <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State;
  3106. <a name="l03077"></a>03077
  3107. <a name="l03078"></a>03078 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#ae13b14073477671929c41823f198c33d">wxlua_lreg_windestroycallbacks_key</a>); <span class="comment">// push key</span>
  3108. <a name="l03079"></a>03079 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  3109. <a name="l03080"></a>03080
  3110. <a name="l03081"></a>03081 lua_pushlightuserdata(L, callback-&gt;<a class="code" href="classwxLuaWinDestroyCallback.html#ae2572b116622d6d8af56593ef68d923e">GetWindow</a>()); <span class="comment">// push key</span>
  3111. <a name="l03082"></a>03082 lua_pushnil(L); <span class="comment">// push value</span>
  3112. <a name="l03083"></a>03083 lua_rawset(L, -3); <span class="comment">// set t[key] = value; pops key and value</span>
  3113. <a name="l03084"></a>03084
  3114. <a name="l03085"></a>03085 lua_pop(L, 1); <span class="comment">// pop table</span>
  3115. <a name="l03086"></a>03086
  3116. <a name="l03087"></a>03087 <span class="keywordflow">return</span> <span class="keyword">true</span>; <span class="comment">// FIXME return if it was here or not</span>
  3117. <a name="l03088"></a>03088 }
  3118. <a name="l03089"></a>03089
  3119. <a name="l03090"></a><a class="code" href="classwxLuaState.html#ab920981a273ee5249b221011cd6b0b7c">03090</a> wxArrayString <a class="code" href="classwxLuaState.html#ab920981a273ee5249b221011cd6b0b7c">wxLuaState::GetTrackedWinDestroyCallbackInfo</a>()<span class="keyword"> const</span>
  3120. <a name="l03091"></a>03091 <span class="keyword"></span>{
  3121. <a name="l03092"></a>03092 wxArrayString names;
  3122. <a name="l03093"></a>03093
  3123. <a name="l03094"></a>03094 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), names, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3124. <a name="l03095"></a>03095 lua_State* L = <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State;
  3125. <a name="l03096"></a>03096
  3126. <a name="l03097"></a>03097 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#ae13b14073477671929c41823f198c33d">wxlua_lreg_windestroycallbacks_key</a>); <span class="comment">// push key</span>
  3127. <a name="l03098"></a>03098 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (table)</span>
  3128. <a name="l03099"></a>03099
  3129. <a name="l03100"></a>03100 lua_pushnil(L);
  3130. <a name="l03101"></a>03101 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
  3131. <a name="l03102"></a>03102 {
  3132. <a name="l03103"></a>03103 <span class="comment">// value = -1, key = -2, table = -3</span>
  3133. <a name="l03104"></a>03104 <a class="code" href="classwxLuaWinDestroyCallback.html">wxLuaWinDestroyCallback</a>* wxlDestroyCallBack = (<a class="code" href="classwxLuaWinDestroyCallback.html">wxLuaWinDestroyCallback</a>*)lua_touserdata(L, -1);
  3134. <a name="l03105"></a>03105 wxCHECK_MSG(wxlDestroyCallBack, names, wxT(<span class="stringliteral">&quot;Invalid wxLuaWinDestroyCallback&quot;</span>));
  3135. <a name="l03106"></a>03106
  3136. <a name="l03107"></a>03107 names.Add(wxlDestroyCallBack-&gt;<a class="code" href="classwxLuaWinDestroyCallback.html#aa1ebb2002abc2ffc7d09c3c33a94e852">GetInfo</a>());
  3137. <a name="l03108"></a>03108
  3138. <a name="l03109"></a>03109 lua_pop(L, 1); <span class="comment">// pop value, lua_next will pop key at end</span>
  3139. <a name="l03110"></a>03110 }
  3140. <a name="l03111"></a>03111
  3141. <a name="l03112"></a>03112 names.Sort();
  3142. <a name="l03113"></a>03113 <span class="keywordflow">return</span> names;
  3143. <a name="l03114"></a>03114 }
  3144. <a name="l03115"></a>03115
  3145. <a name="l03116"></a>03116 <span class="comment">// ----------------------------------------------------------------------------</span>
  3146. <a name="l03117"></a>03117
  3147. <a name="l03118"></a><a class="code" href="classwxLuaState.html#a4925fb35a1622f81fc9c5dc5820e27d8">03118</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a4925fb35a1622f81fc9c5dc5820e27d8">wxLuaState::wxlua_Error</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *errorMsg)<span class="keyword"> const</span>
  3148. <a name="l03119"></a>03119 <span class="keyword"></span>{
  3149. <a name="l03120"></a>03120 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3150. <a name="l03121"></a>03121 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, errorMsg);
  3151. <a name="l03122"></a>03122 }
  3152. <a name="l03123"></a>03123
  3153. <a name="l03124"></a><a class="code" href="classwxLuaState.html#afdc2d9c0e976c0d6636206dd0e1ea3c9">03124</a> <span class="keywordtype">void</span>* <a class="code" href="classwxLuaState.html#afdc2d9c0e976c0d6636206dd0e1ea3c9">wxLuaState::wxlua_ToUserdata</a>(<span class="keywordtype">int</span> stack_idx, <span class="keywordtype">bool</span> reset <span class="comment">/* = false*/</span>)<span class="keyword"> const</span>
  3154. <a name="l03125"></a>03125 <span class="keyword"></span>{
  3155. <a name="l03126"></a>03126 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3156. <a name="l03127"></a>03127 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#ac5a0a65665274df59adbed667480e93e">wxlua_touserdata</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx, reset);
  3157. <a name="l03128"></a>03128 }
  3158. <a name="l03129"></a>03129
  3159. <a name="l03130"></a>03130 <span class="comment">// ----------------------------------------------------------------------------</span>
  3160. <a name="l03131"></a>03131 <span class="comment">// wxLua Lua Registry Table Functions</span>
  3161. <a name="l03132"></a>03132
  3162. <a name="l03133"></a><a class="code" href="classwxLuaState.html#a1c041e98055317fdcb53f23e3e2172e2">03133</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a1c041e98055317fdcb53f23e3e2172e2">wxLuaState::wxluaR_Ref</a>(<span class="keywordtype">int</span> stack_idx, <span class="keywordtype">void</span>* lightuserdata_reg_key)
  3163. <a name="l03134"></a>03134 {
  3164. <a name="l03135"></a>03135 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), LUA_REFNIL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3165. <a name="l03136"></a>03136 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#acbf0a32ad4b828026bd7f643557646d0">wxluaR_ref</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx, lightuserdata_reg_key);
  3166. <a name="l03137"></a>03137 }
  3167. <a name="l03138"></a>03138
  3168. <a name="l03139"></a><a class="code" href="classwxLuaState.html#a26d311d6ee816331696ec18b4b1ee1d4">03139</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a26d311d6ee816331696ec18b4b1ee1d4">wxLuaState::wxluaR_Unref</a>(<span class="keywordtype">int</span> wxlref_index, <span class="keywordtype">void</span>* lightuserdata_reg_key)
  3169. <a name="l03140"></a>03140 {
  3170. <a name="l03141"></a>03141 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3171. <a name="l03142"></a>03142 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a0578d177f35b4dd05177067425410009">wxluaR_unref</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, wxlref_index, lightuserdata_reg_key);
  3172. <a name="l03143"></a>03143 }
  3173. <a name="l03144"></a>03144
  3174. <a name="l03145"></a><a class="code" href="classwxLuaState.html#a119cc5105d9f11af426a6bb5db6fe863">03145</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a119cc5105d9f11af426a6bb5db6fe863">wxLuaState::wxluaR_GetRef</a>(<span class="keywordtype">int</span> wxlref_index, <span class="keywordtype">void</span>* lightuserdata_reg_key)
  3175. <a name="l03146"></a>03146 {
  3176. <a name="l03147"></a>03147 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3177. <a name="l03148"></a>03148 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#ae7108b396d79179f517a7dc478c2cb43">wxluaR_getref</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, wxlref_index, lightuserdata_reg_key);
  3178. <a name="l03149"></a>03149 }
  3179. <a name="l03150"></a>03150
  3180. <a name="l03151"></a>03151 <span class="comment">// ----------------------------------------------------------------------------</span>
  3181. <a name="l03152"></a>03152
  3182. <a name="l03153"></a><a class="code" href="classwxLuaState.html#a18fe402bb81bd618b4e1a3b5b638ed40">03153</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a18fe402bb81bd618b4e1a3b5b638ed40">wxLuaState::wxluaT_NewMetatable</a>(<span class="keywordtype">int</span> wxl_type)
  3183. <a name="l03154"></a>03154 {
  3184. <a name="l03155"></a>03155 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <a class="code" href="wxlbind_8h.html#aeb150b964405f526ef77087288f403b2">WXLUA_TUNKNOWN</a>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3185. <a name="l03156"></a>03156 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a6e860df2af8f36918348b8b92abfbfb4">wxluaT_newmetatable</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, wxl_type);
  3186. <a name="l03157"></a>03157 }
  3187. <a name="l03158"></a>03158
  3188. <a name="l03159"></a><a class="code" href="classwxLuaState.html#ab031693b7fc417d2bb1a87ec3ad0ce7f">03159</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#ab031693b7fc417d2bb1a87ec3ad0ce7f">wxLuaState::wxluaT_SetMetatable</a>(<span class="keywordtype">int</span> wxl_type)
  3189. <a name="l03160"></a>03160 {
  3190. <a name="l03161"></a>03161 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3191. <a name="l03162"></a>03162 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a5fb71259953328a8fd54939518cbe455">wxluaT_setmetatable</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, wxl_type);
  3192. <a name="l03163"></a>03163 }
  3193. <a name="l03164"></a>03164
  3194. <a name="l03165"></a><a class="code" href="classwxLuaState.html#a97074610ac5206ab1e6008f6a69fa58f">03165</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a97074610ac5206ab1e6008f6a69fa58f">wxLuaState::wxluaT_Type</a>(<span class="keywordtype">int</span> stack_idx)<span class="keyword"> const</span>
  3195. <a name="l03166"></a>03166 <span class="keyword"></span>{
  3196. <a name="l03167"></a>03167 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <a class="code" href="wxlbind_8h.html#aeb150b964405f526ef77087288f403b2">WXLUA_TUNKNOWN</a>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3197. <a name="l03168"></a>03168 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx);
  3198. <a name="l03169"></a>03169 }
  3199. <a name="l03170"></a>03170
  3200. <a name="l03171"></a><a class="code" href="classwxLuaState.html#a1ddca063dc0adeabba008a3249ac92cc">03171</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a1ddca063dc0adeabba008a3249ac92cc">wxLuaState::wxluaT_PushUserDataType</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *obj_ptr, <span class="keywordtype">int</span> wxl_type, <span class="keywordtype">bool</span> track)
  3201. <a name="l03172"></a>03172 {
  3202. <a name="l03173"></a>03173 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3203. <a name="l03174"></a>03174 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a4cd81a70613d64cac4f0f363807df6a6">wxluaT_pushuserdatatype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, obj_ptr, wxl_type, track);
  3204. <a name="l03175"></a>03175 }
  3205. <a name="l03176"></a>03176
  3206. <a name="l03177"></a>03177 <span class="comment">// ----------------------------------------------------------------------------</span>
  3207. <a name="l03178"></a>03178 <span class="comment">// wxLua get data type</span>
  3208. <a name="l03179"></a>03179
  3209. <a name="l03180"></a><a class="code" href="classwxLuaState.html#ae62161f63c9a690acf57bc3e0eda7b41">03180</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#ae62161f63c9a690acf57bc3e0eda7b41">wxLuaState::IswxLuaType</a>(<span class="keywordtype">int</span> luatype, <span class="keywordtype">int</span> wxl_type)<span class="keyword"> const</span>
  3210. <a name="l03181"></a>03181 <span class="keyword"></span>{
  3211. <a name="l03182"></a>03182 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), -1, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3212. <a name="l03183"></a>03183 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a47f2034cabf94ca87dde758af863f4e2">wxlua_iswxluatype</a>(luatype, wxl_type, <a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State);
  3213. <a name="l03184"></a>03184 }
  3214. <a name="l03185"></a>03185
  3215. <a name="l03186"></a><a class="code" href="classwxLuaState.html#a3f599ee35b808c24d9a3b7bd6138b8c3">03186</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a3f599ee35b808c24d9a3b7bd6138b8c3">wxLuaState::IsUserDataType</a>(<span class="keywordtype">int</span> stack_idx, <span class="keywordtype">int</span> wxl_type)<span class="keyword"> const</span>
  3216. <a name="l03187"></a>03187 <span class="keyword"></span>{
  3217. <a name="l03188"></a>03188 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3218. <a name="l03189"></a>03189 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a1602757335e28069aa1d9416a5c53ac2">wxluaT_isuserdatatype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx, wxl_type);
  3219. <a name="l03190"></a>03190 }
  3220. <a name="l03191"></a>03191
  3221. <a name="l03192"></a><a class="code" href="classwxLuaState.html#ab296a23ec0ab798a7e825dfae5fbb2df">03192</a> <span class="keywordtype">void</span>* <a class="code" href="classwxLuaState.html#ab296a23ec0ab798a7e825dfae5fbb2df">wxLuaState::GetUserDataType</a>(<span class="keywordtype">int</span> stack_idx, <span class="keywordtype">int</span> wxl_type)<span class="keyword"> const</span>
  3222. <a name="l03193"></a>03193 <span class="keyword"></span>{
  3223. <a name="l03194"></a>03194 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3224. <a name="l03195"></a>03195 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a4b840fe9dc39ed3114a3c4b271507335">wxluaT_getuserdatatype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx, wxl_type);
  3225. <a name="l03196"></a>03196 }
  3226. <a name="l03197"></a>03197
  3227. <a name="l03198"></a><a class="code" href="classwxLuaState.html#a239e60dca24057c56d7716cd4e43c7c9">03198</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classwxLuaState.html#a239e60dca24057c56d7716cd4e43c7c9">wxLuaState::GetStringType</a>(<span class="keywordtype">int</span> stack_idx)
  3228. <a name="l03199"></a>03199 {
  3229. <a name="l03200"></a>03200 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3230. <a name="l03201"></a>03201 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#aa15baee6edd4446f22cf1c393a1843a3">wxlua_getstringtype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx);
  3231. <a name="l03202"></a>03202 }
  3232. <a name="l03203"></a><a class="code" href="classwxLuaState.html#a3f9656c86c1be672adc4ed1b56cd2063">03203</a> wxString <a class="code" href="classwxLuaState.html#a3f9656c86c1be672adc4ed1b56cd2063">wxLuaState::GetwxStringType</a>(<span class="keywordtype">int</span> stack_idx)
  3233. <a name="l03204"></a>03204 {
  3234. <a name="l03205"></a>03205 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3235. <a name="l03206"></a>03206 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#abaad17f1e38dd7397d597ed0cbc1c4ef">wxlua_getwxStringtype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx);
  3236. <a name="l03207"></a>03207 }
  3237. <a name="l03208"></a><a class="code" href="classwxLuaState.html#a07591f1783aac73d092e74feeeda6d7d">03208</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a07591f1783aac73d092e74feeeda6d7d">wxLuaState::GetBooleanType</a>(<span class="keywordtype">int</span> stack_idx)
  3238. <a name="l03209"></a>03209 {
  3239. <a name="l03210"></a>03210 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3240. <a name="l03211"></a>03211 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a77238c0018900d9c06b0163fa202c21d">wxlua_getbooleantype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx);
  3241. <a name="l03212"></a>03212 }
  3242. <a name="l03213"></a><a class="code" href="classwxLuaState.html#a24bed36d1bfbf23e4c8cedaff29b745f">03213</a> <span class="keywordtype">long</span> <a class="code" href="classwxLuaState.html#a24bed36d1bfbf23e4c8cedaff29b745f">wxLuaState::GetIntegerType</a>(<span class="keywordtype">int</span> stack_idx)
  3243. <a name="l03214"></a>03214 {
  3244. <a name="l03215"></a>03215 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3245. <a name="l03216"></a>03216 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a5b0ffce73ad80800d0b756e49d31bf0e">wxlua_getintegertype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx);
  3246. <a name="l03217"></a>03217 }
  3247. <a name="l03218"></a><a class="code" href="classwxLuaState.html#ae490897ae0c2f9363964525eb218bd40">03218</a> <span class="keywordtype">double</span> <a class="code" href="classwxLuaState.html#ae490897ae0c2f9363964525eb218bd40">wxLuaState::GetNumberType</a>(<span class="keywordtype">int</span> stack_idx)
  3248. <a name="l03219"></a>03219 {
  3249. <a name="l03220"></a>03220 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3250. <a name="l03221"></a>03221 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a7e0788737b729042ceddba8b630b4e53">wxlua_getnumbertype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx);
  3251. <a name="l03222"></a>03222 }
  3252. <a name="l03223"></a>03223
  3253. <a name="l03224"></a><a class="code" href="classwxLuaState.html#aa207ffd263dcb705a3ec6ec19234351e">03224</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#aa207ffd263dcb705a3ec6ec19234351e">wxLuaState::IsStringType</a>(<span class="keywordtype">int</span> stack_idx)<span class="keyword"> const</span>
  3254. <a name="l03225"></a>03225 <span class="keyword"></span>{
  3255. <a name="l03226"></a>03226 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3256. <a name="l03227"></a>03227 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a608577522e6393650240dddfba01d8b4">wxlua_isstringtype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx);
  3257. <a name="l03228"></a>03228 }
  3258. <a name="l03229"></a>03229
  3259. <a name="l03230"></a><a class="code" href="classwxLuaState.html#ad09b13a609b965ae56359a0abc227d3d">03230</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#ad09b13a609b965ae56359a0abc227d3d">wxLuaState::IswxStringType</a>(<span class="keywordtype">int</span> stack_idx)<span class="keyword"> const</span>
  3260. <a name="l03231"></a>03231 <span class="keyword"></span>{
  3261. <a name="l03232"></a>03232 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3262. <a name="l03233"></a>03233 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a4c0ece81cd5c2a156feeda8d71e3e0f8">wxlua_iswxstringtype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx);
  3263. <a name="l03234"></a>03234 }
  3264. <a name="l03235"></a>03235
  3265. <a name="l03236"></a><a class="code" href="classwxLuaState.html#a9d42ae5c02c0e27465654416509f0646">03236</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a9d42ae5c02c0e27465654416509f0646">wxLuaState::IsBooleanType</a>(<span class="keywordtype">int</span> stack_idx)<span class="keyword"> const</span>
  3266. <a name="l03237"></a>03237 <span class="keyword"></span>{
  3267. <a name="l03238"></a>03238 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3268. <a name="l03239"></a>03239 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#ac24c9e36c8ac2a1e9321fd3a8cba6b48">wxlua_isbooleantype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx);
  3269. <a name="l03240"></a>03240 }
  3270. <a name="l03241"></a><a class="code" href="classwxLuaState.html#aec78696177cee6982225c97cfec82e92">03241</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#aec78696177cee6982225c97cfec82e92">wxLuaState::IsIntegerType</a>(<span class="keywordtype">int</span> stack_idx)<span class="keyword"> const</span>
  3271. <a name="l03242"></a>03242 <span class="keyword"></span>{
  3272. <a name="l03243"></a>03243 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3273. <a name="l03244"></a>03244 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#aa0e02f2c0ba42fa8125a87f7d1f3b862">wxlua_isintegertype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx);
  3274. <a name="l03245"></a>03245 }
  3275. <a name="l03246"></a><a class="code" href="classwxLuaState.html#ae745dee49f18b07a50a954fce9b17a9e">03246</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#ae745dee49f18b07a50a954fce9b17a9e">wxLuaState::IsNumberType</a>(<span class="keywordtype">int</span> stack_idx)<span class="keyword"> const</span>
  3276. <a name="l03247"></a>03247 <span class="keyword"></span>{
  3277. <a name="l03248"></a>03248 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3278. <a name="l03249"></a>03249 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a49a0718d6216af2f681197473f206e36">wxlua_isnumbertype</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx);
  3279. <a name="l03250"></a>03250 }
  3280. <a name="l03251"></a>03251
  3281. <a name="l03252"></a><a class="code" href="classwxLuaState.html#ac5bcf4056fefd063a586fc4e0eaa9068">03252</a> wxString* <a class="code" href="classwxLuaState.html#ac5bcf4056fefd063a586fc4e0eaa9068">wxLuaState::GetwxStringArray</a>(<span class="keywordtype">int</span> stack_idx, <span class="keywordtype">int</span> &amp;count)
  3282. <a name="l03253"></a>03253 {
  3283. <a name="l03254"></a>03254 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3284. <a name="l03255"></a>03255 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a9d0af8f1eee0d4615751565f3f2fa393">wxlua_getwxStringarray</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx, count);
  3285. <a name="l03256"></a>03256 }
  3286. <a name="l03257"></a>03257
  3287. <a name="l03258"></a><a class="code" href="classwxLuaState.html#a7fc4f3e955169f1c02be0dff23e14ad4">03258</a> <a class="code" href="classwxLuaSmartwxArrayString.html">wxLuaSmartwxArrayString</a> <a class="code" href="classwxLuaState.html#a7fc4f3e955169f1c02be0dff23e14ad4">wxLuaState::GetwxArrayString</a>(<span class="keywordtype">int</span> stack_idx)
  3288. <a name="l03259"></a>03259 {
  3289. <a name="l03260"></a>03260 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <a class="code" href="classwxLuaSmartwxArrayString.html">wxLuaSmartwxArrayString</a>(NULL, <span class="keyword">true</span>), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3290. <a name="l03261"></a>03261 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a0cf1f6516b7828d8f58e8fca47b0751d">wxlua_getwxArrayString</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx);
  3291. <a name="l03262"></a>03262 }
  3292. <a name="l03263"></a>03263
  3293. <a name="l03264"></a><a class="code" href="classwxLuaState.html#adbc41d2371297460eb66e623db4c9ba8">03264</a> <span class="keyword">const</span> <span class="keywordtype">char</span>** <a class="code" href="classwxLuaState.html#adbc41d2371297460eb66e623db4c9ba8">wxLuaState::GetCharArray</a>(<span class="keywordtype">int</span> stack_idx, <span class="keywordtype">int</span> &amp;count)
  3294. <a name="l03265"></a>03265 {
  3295. <a name="l03266"></a>03266 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3296. <a name="l03267"></a>03267 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#ad3f311ca85fe28d4faf3f4dd81536a18">wxlua_getchararray</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx, count);
  3297. <a name="l03268"></a>03268 }
  3298. <a name="l03269"></a>03269
  3299. <a name="l03270"></a><a class="code" href="classwxLuaState.html#a87b4de23fd03b7401851d5d211c05095">03270</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a87b4de23fd03b7401851d5d211c05095">wxLuaState::PushwxArrayStringTable</a>(<span class="keyword">const</span> wxArrayString &amp;strArray)
  3300. <a name="l03271"></a>03271 {
  3301. <a name="l03272"></a>03272 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3302. <a name="l03273"></a>03273 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a4fae9b1e2b6a0669ddb701581edf24c7">wxlua_pushwxArrayStringtable</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, strArray);
  3303. <a name="l03274"></a>03274 }
  3304. <a name="l03275"></a>03275
  3305. <a name="l03276"></a><a class="code" href="classwxLuaState.html#adb26f16e89f454279fd6e2678e7a9f91">03276</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#adb26f16e89f454279fd6e2678e7a9f91">wxLuaState::PushwxArrayIntTable</a>(<span class="keyword">const</span> wxArrayInt &amp;intArray)
  3306. <a name="l03277"></a>03277 {
  3307. <a name="l03278"></a>03278 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3308. <a name="l03279"></a>03279 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a75ae92f66c6689bad6470f689a7d190d">wxlua_pushwxArrayInttable</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, intArray);
  3309. <a name="l03280"></a>03280 }
  3310. <a name="l03281"></a>03281
  3311. <a name="l03282"></a><a class="code" href="classwxLuaState.html#a3b22af2477a4a6329e00355572eb2bc1">03282</a> <span class="keywordtype">int</span>* <a class="code" href="classwxLuaState.html#a3b22af2477a4a6329e00355572eb2bc1">wxLuaState::GetIntArray</a>(<span class="keywordtype">int</span> stack_idx, <span class="keywordtype">int</span> &amp;count)
  3312. <a name="l03283"></a>03283 {
  3313. <a name="l03284"></a>03284 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3314. <a name="l03285"></a>03285 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a608c006132ed91d53ce42a4221de285f">wxlua_getintarray</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx, count);
  3315. <a name="l03286"></a>03286 }
  3316. <a name="l03287"></a>03287
  3317. <a name="l03288"></a><a class="code" href="classwxLuaState.html#a8bdaaaa42d76dfc8b0ea9548b386b892">03288</a> <a class="code" href="classwxLuaSmartwxArrayInt.html">wxLuaSmartwxArrayInt</a> <a class="code" href="classwxLuaState.html#a8bdaaaa42d76dfc8b0ea9548b386b892">wxLuaState::GetwxArrayInt</a>(<span class="keywordtype">int</span> stack_idx)
  3318. <a name="l03289"></a>03289 {
  3319. <a name="l03290"></a>03290 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <a class="code" href="classwxLuaSmartwxArrayInt.html">wxLuaSmartwxArrayInt</a>(NULL, <span class="keyword">true</span>), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3320. <a name="l03291"></a>03291 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a1d55c218b354f79810dbe96a5adf96a8">wxlua_getwxArrayInt</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, stack_idx);
  3321. <a name="l03292"></a>03292 }
  3322. <a name="l03293"></a>03293
  3323. <a name="l03294"></a><a class="code" href="classwxLuaState.html#a2479a06481b5a8e28f292f4e4b81b517">03294</a> wxString <a class="code" href="classwxLuaState.html#a2479a06481b5a8e28f292f4e4b81b517">wxLuaState::GetwxLuaTypeName</a>(<span class="keywordtype">int</span> wxl_type)<span class="keyword"> const</span>
  3324. <a name="l03295"></a>03295 <span class="keyword"></span>{
  3325. <a name="l03296"></a>03296 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3326. <a name="l03297"></a>03297 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a6621fa5a456448acfd515112aa7b23e1">wxluaT_typename</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, wxl_type);
  3327. <a name="l03298"></a>03298 }
  3328. <a name="l03299"></a>03299
  3329. <a name="l03300"></a><a class="code" href="classwxLuaState.html#aeb0ff5486cb4e7c52e7fad87cbd5c39a">03300</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#aeb0ff5486cb4e7c52e7fad87cbd5c39a">wxLuaState::SetDerivedMethod</a>(<span class="keywordtype">void</span> *obj_ptr, <span class="keyword">const</span> <span class="keywordtype">char</span> *method_name, <a class="code" href="classwxLuaObject.html">wxLuaObject</a>* wxlObj)
  3330. <a name="l03301"></a>03301 {
  3331. <a name="l03302"></a>03302 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>() &amp;&amp; obj_ptr, <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState or object to set derived method for.&quot;</span>));
  3332. <a name="l03303"></a>03303 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a1110e8f522280bc418efc5ec47ef585c">wxlua_setderivedmethod</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, obj_ptr, method_name, wxlObj);
  3333. <a name="l03304"></a>03304 }
  3334. <a name="l03305"></a>03305
  3335. <a name="l03306"></a><a class="code" href="classwxLuaState.html#a45151e3be4e968047fce2c100fbc8979">03306</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a45151e3be4e968047fce2c100fbc8979">wxLuaState::HasDerivedMethod</a>(<span class="keywordtype">void</span> *obj_ptr, <span class="keyword">const</span> <span class="keywordtype">char</span> *method_name, <span class="keywordtype">bool</span> push_method)<span class="keyword"> const</span>
  3336. <a name="l03307"></a>03307 <span class="keyword"></span>{
  3337. <a name="l03308"></a>03308 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3338. <a name="l03309"></a>03309 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#a602bc60e4737a25c6202d86c7c2f6c2b">wxlua_hasderivedmethod</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, obj_ptr, method_name, push_method);
  3339. <a name="l03310"></a>03310 }
  3340. <a name="l03311"></a>03311
  3341. <a name="l03312"></a><a class="code" href="classwxLuaState.html#a8e3dbd9c493af6564e5c77ce9e77cf01">03312</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a8e3dbd9c493af6564e5c77ce9e77cf01">wxLuaState::RemoveDerivedMethods</a>(<span class="keywordtype">void</span> *obj_ptr)<span class="keyword"> const</span>
  3342. <a name="l03313"></a>03313 <span class="keyword"></span>{
  3343. <a name="l03314"></a>03314 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>() &amp;&amp; obj_ptr, <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState or object to remove.&quot;</span>));
  3344. <a name="l03315"></a>03315 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#abfb64621a5e2ba46114e81a28731c79f">wxlua_removederivedmethods</a>(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, obj_ptr);
  3345. <a name="l03316"></a>03316 }
  3346. <a name="l03317"></a>03317
  3347. <a name="l03318"></a><a class="code" href="classwxLuaState.html#a023c855242b3be44442da7cfc7a5175f">03318</a> <a class="code" href="classwxLuaState.html">wxLuaState</a> <a class="code" href="classwxLuaState.html#a023c855242b3be44442da7cfc7a5175f">wxLuaState::GetDerivedMethodState</a>(<span class="keywordtype">void</span> *obj_ptr, <span class="keyword">const</span> <span class="keywordtype">char</span> *method_name)
  3348. <a name="l03319"></a>03319 {
  3349. <a name="l03320"></a>03320 wxCHECK_MSG(obj_ptr, <a class="code" href="wxlstate_8h.html#aef06b6591011cd68b9e370d5e702d255">wxNullLuaState</a>, wxT(<span class="stringliteral">&quot;Invalid object to wxLuaState::GetDerivedMethod&quot;</span>));
  3350. <a name="l03321"></a>03321
  3351. <a name="l03322"></a>03322 wxHashMapLuaState::iterator it;
  3352. <a name="l03323"></a>03323 <span class="keywordflow">for</span> (it = <a class="code" href="classwxLuaState.html#ab8261cd3629c21d1cbaeb5a6e0777272">wxLuaState::s_wxHashMapLuaState</a>.begin();
  3353. <a name="l03324"></a>03324 it != <a class="code" href="classwxLuaState.html#ab8261cd3629c21d1cbaeb5a6e0777272">wxLuaState::s_wxHashMapLuaState</a>.end(); ++it)
  3354. <a name="l03325"></a>03325 {
  3355. <a name="l03326"></a>03326 <a class="code" href="classwxLuaState.html">wxLuaState</a> wxlState((<a class="code" href="classwxLuaState.html">wxLuaState</a>*)it-&gt;second);
  3356. <a name="l03327"></a>03327 <span class="keywordflow">if</span> (wxlState.<a class="code" href="classwxLuaState.html#a45151e3be4e968047fce2c100fbc8979">HasDerivedMethod</a>(obj_ptr, method_name, <span class="keyword">false</span>))
  3357. <a name="l03328"></a>03328 <span class="keywordflow">return</span> wxlState;
  3358. <a name="l03329"></a>03329 }
  3359. <a name="l03330"></a>03330
  3360. <a name="l03331"></a>03331 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#aef06b6591011cd68b9e370d5e702d255">wxNullLuaState</a>;
  3361. <a name="l03332"></a>03332 }
  3362. <a name="l03333"></a>03333
  3363. <a name="l03334"></a>03334 <span class="comment">// ----------------------------------------------------------------------------</span>
  3364. <a name="l03335"></a>03335 <span class="comment">// Raw basic Lua stack functions.</span>
  3365. <a name="l03336"></a>03336
  3366. <a name="l03337"></a><a class="code" href="classwxLuaState.html#ae9d1c33abd2af7e081fa71a42ca28a26">03337</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#ae9d1c33abd2af7e081fa71a42ca28a26">wxLuaState::lua_GetTop</a>()<span class="keyword"> const</span>
  3367. <a name="l03338"></a>03338 <span class="keyword"></span>{
  3368. <a name="l03339"></a>03339 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3369. <a name="l03340"></a>03340 <span class="keywordflow">return</span> lua_gettop(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State);
  3370. <a name="l03341"></a>03341 }
  3371. <a name="l03342"></a><a class="code" href="classwxLuaState.html#ad39adb85b7e7010691f51bd3f6fe3161">03342</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#ad39adb85b7e7010691f51bd3f6fe3161">wxLuaState::lua_SetTop</a>(<span class="keywordtype">int</span> index)
  3372. <a name="l03343"></a>03343 {
  3373. <a name="l03344"></a>03344 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3374. <a name="l03345"></a>03345 lua_settop(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index);
  3375. <a name="l03346"></a>03346 }
  3376. <a name="l03347"></a><a class="code" href="classwxLuaState.html#aeff1ffb143ad768c0c37ff877aacfa62">03347</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#aeff1ffb143ad768c0c37ff877aacfa62">wxLuaState::lua_PushValue</a>(<span class="keywordtype">int</span> index)
  3377. <a name="l03348"></a>03348 {
  3378. <a name="l03349"></a>03349 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3379. <a name="l03350"></a>03350 lua_pushvalue(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index);
  3380. <a name="l03351"></a>03351 }
  3381. <a name="l03352"></a><a class="code" href="classwxLuaState.html#af10c7b8f702b54d607bba79189ec2d59">03352</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#af10c7b8f702b54d607bba79189ec2d59">wxLuaState::lua_Remove</a>(<span class="keywordtype">int</span> index)
  3382. <a name="l03353"></a>03353 {
  3383. <a name="l03354"></a>03354 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3384. <a name="l03355"></a>03355 lua_remove(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index);
  3385. <a name="l03356"></a>03356 }
  3386. <a name="l03357"></a><a class="code" href="classwxLuaState.html#a2efa05a8ce69d8344c5ea14b4fe02bf0">03357</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a2efa05a8ce69d8344c5ea14b4fe02bf0">wxLuaState::lua_Pop</a>(<span class="keywordtype">int</span> count)
  3387. <a name="l03358"></a>03358 {
  3388. <a name="l03359"></a>03359 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3389. <a name="l03360"></a>03360 lua_pop(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, count);
  3390. <a name="l03361"></a>03361 }
  3391. <a name="l03362"></a><a class="code" href="classwxLuaState.html#a378011e915f75d6d4ede9f9743ffa187">03362</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a378011e915f75d6d4ede9f9743ffa187">wxLuaState::lua_Insert</a>(<span class="keywordtype">int</span> index)
  3392. <a name="l03363"></a>03363 {
  3393. <a name="l03364"></a>03364 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3394. <a name="l03365"></a>03365 lua_insert(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index);
  3395. <a name="l03366"></a>03366 }
  3396. <a name="l03367"></a><a class="code" href="classwxLuaState.html#a5449e83c013dcf3cc0ffed5652309805">03367</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a5449e83c013dcf3cc0ffed5652309805">wxLuaState::lua_Replace</a>(<span class="keywordtype">int</span> index)
  3397. <a name="l03368"></a>03368 {
  3398. <a name="l03369"></a>03369 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3399. <a name="l03370"></a>03370 lua_replace(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index);
  3400. <a name="l03371"></a>03371 }
  3401. <a name="l03372"></a><a class="code" href="classwxLuaState.html#a4371f5ded50509ba5b0e089aa2a3c750">03372</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a4371f5ded50509ba5b0e089aa2a3c750">wxLuaState::lua_CheckStack</a>(<span class="keywordtype">int</span> size)
  3402. <a name="l03373"></a>03373 {
  3403. <a name="l03374"></a>03374 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3404. <a name="l03375"></a>03375 <span class="keywordflow">return</span> lua_checkstack(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, size);
  3405. <a name="l03376"></a>03376 }
  3406. <a name="l03377"></a><a class="code" href="classwxLuaState.html#a8a4b7141ccb4893bcb363c8590c9df0d">03377</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a8a4b7141ccb4893bcb363c8590c9df0d">wxLuaState::lua_XMove</a>(<span class="keyword">const</span> <a class="code" href="classwxLuaState.html">wxLuaState</a>&amp; to, <span class="keywordtype">int</span> n)
  3407. <a name="l03378"></a>03378 {
  3408. <a name="l03379"></a>03379 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>() &amp;&amp; to.<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3409. <a name="l03380"></a>03380 lua_xmove(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, to.<a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">GetLuaState</a>(), n);
  3410. <a name="l03381"></a>03381 }
  3411. <a name="l03382"></a>03382
  3412. <a name="l03383"></a>03383 <span class="comment">// ----------------------------------------------------------------------------</span>
  3413. <a name="l03384"></a>03384 <span class="comment">// access functions (stack -&gt; C)</span>
  3414. <a name="l03385"></a>03385
  3415. <a name="l03386"></a><a class="code" href="classwxLuaState.html#aa7df62da69f2f4e80c102baa5931be42">03386</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#aa7df62da69f2f4e80c102baa5931be42">wxLuaState::lua_IsNumber</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3416. <a name="l03387"></a>03387 <span class="keyword"></span>{
  3417. <a name="l03388"></a>03388 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3418. <a name="l03389"></a>03389 <span class="keywordflow">return</span> lua_isnumber(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index) != 0;
  3419. <a name="l03390"></a>03390 }
  3420. <a name="l03391"></a><a class="code" href="classwxLuaState.html#a7e1ee69b6da049029f031f4601f765e9">03391</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a7e1ee69b6da049029f031f4601f765e9">wxLuaState::lua_IsString</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3421. <a name="l03392"></a>03392 <span class="keyword"></span>{
  3422. <a name="l03393"></a>03393 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3423. <a name="l03394"></a>03394 <span class="keywordflow">return</span> lua_isstring(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index) != 0;
  3424. <a name="l03395"></a>03395 }
  3425. <a name="l03396"></a><a class="code" href="classwxLuaState.html#ace737e76858637586d16efba91eac86e">03396</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#ace737e76858637586d16efba91eac86e">wxLuaState::lua_IsCFunction</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3426. <a name="l03397"></a>03397 <span class="keyword"></span>{
  3427. <a name="l03398"></a>03398 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3428. <a name="l03399"></a>03399 <span class="keywordflow">return</span> lua_iscfunction(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index) != 0;
  3429. <a name="l03400"></a>03400 }
  3430. <a name="l03401"></a><a class="code" href="classwxLuaState.html#ad0906e68ec8432ed454a72617a7d8b94">03401</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#ad0906e68ec8432ed454a72617a7d8b94">wxLuaState::lua_IsUserdata</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3431. <a name="l03402"></a>03402 <span class="keyword"></span>{
  3432. <a name="l03403"></a>03403 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3433. <a name="l03404"></a>03404 <span class="keywordflow">return</span> lua_isuserdata(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index) != 0;
  3434. <a name="l03405"></a>03405 }
  3435. <a name="l03406"></a><a class="code" href="classwxLuaState.html#a9e8f09b17f32e667528f2bcb34e8ed13">03406</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a9e8f09b17f32e667528f2bcb34e8ed13">wxLuaState::lua_Type</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3436. <a name="l03407"></a>03407 <span class="keyword"></span>{
  3437. <a name="l03408"></a>03408 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3438. <a name="l03409"></a>03409 <span class="keywordflow">return</span> lua_type(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index);
  3439. <a name="l03410"></a>03410 }
  3440. <a name="l03411"></a><a class="code" href="classwxLuaState.html#abd14785fba24b63b835f0e71a16202a4">03411</a> wxString <a class="code" href="classwxLuaState.html#abd14785fba24b63b835f0e71a16202a4">wxLuaState::lua_TypeName</a>(<span class="keywordtype">int</span> type)<span class="keyword"> const</span>
  3441. <a name="l03412"></a>03412 <span class="keyword"></span>{
  3442. <a name="l03413"></a>03413 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3443. <a name="l03414"></a>03414 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(lua_typename(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, type));
  3444. <a name="l03415"></a>03415 }
  3445. <a name="l03416"></a>03416
  3446. <a name="l03417"></a><a class="code" href="classwxLuaState.html#abd650e7d2267104f2564f9676215b93a">03417</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#abd650e7d2267104f2564f9676215b93a">wxLuaState::lua_Equal</a>(<span class="keywordtype">int</span> index1, <span class="keywordtype">int</span> index2)<span class="keyword"> const</span>
  3447. <a name="l03418"></a>03418 <span class="keyword"></span>{
  3448. <a name="l03419"></a>03419 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3449. <a name="l03420"></a>03420 <span class="keywordflow">return</span> lua_equal(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index1, index2);
  3450. <a name="l03421"></a>03421 }
  3451. <a name="l03422"></a><a class="code" href="classwxLuaState.html#aedaed12eb69f512169e1faec5caaad8a">03422</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#aedaed12eb69f512169e1faec5caaad8a">wxLuaState::lua_RawEqual</a>(<span class="keywordtype">int</span> index1, <span class="keywordtype">int</span> index2)<span class="keyword"> const</span>
  3452. <a name="l03423"></a>03423 <span class="keyword"></span>{
  3453. <a name="l03424"></a>03424 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3454. <a name="l03425"></a>03425 <span class="keywordflow">return</span> lua_rawequal(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index1, index2);
  3455. <a name="l03426"></a>03426 }
  3456. <a name="l03427"></a><a class="code" href="classwxLuaState.html#a0c568b9134a020d2fb8a71bd3a0bec57">03427</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a0c568b9134a020d2fb8a71bd3a0bec57">wxLuaState::lua_LessThan</a>(<span class="keywordtype">int</span> index1, <span class="keywordtype">int</span> index2)<span class="keyword"> const</span>
  3457. <a name="l03428"></a>03428 <span class="keyword"></span>{
  3458. <a name="l03429"></a>03429 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3459. <a name="l03430"></a>03430 <span class="keywordflow">return</span> lua_lessthan(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index1, index2);
  3460. <a name="l03431"></a>03431 }
  3461. <a name="l03432"></a>03432
  3462. <a name="l03433"></a><a class="code" href="classwxLuaState.html#aa75554592cae272aec0d8242a2d0725a">03433</a> <span class="keywordtype">double</span> <a class="code" href="classwxLuaState.html#aa75554592cae272aec0d8242a2d0725a">wxLuaState::lua_ToNumber</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3463. <a name="l03434"></a>03434 <span class="keyword"></span>{
  3464. <a name="l03435"></a>03435 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3465. <a name="l03436"></a>03436 <span class="keywordflow">return</span> lua_tonumber(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index);
  3466. <a name="l03437"></a>03437 }
  3467. <a name="l03438"></a><a class="code" href="classwxLuaState.html#addbf06d782f19d288ce498cfd4635287">03438</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#addbf06d782f19d288ce498cfd4635287">wxLuaState::lua_ToInteger</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3468. <a name="l03439"></a>03439 <span class="keyword"></span>{
  3469. <a name="l03440"></a>03440 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3470. <a name="l03441"></a>03441 <span class="keywordflow">return</span> lua_tointeger(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index);
  3471. <a name="l03442"></a>03442 }
  3472. <a name="l03443"></a><a class="code" href="classwxLuaState.html#a4605560f02821b53977cdb3a43e0ba98">03443</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a4605560f02821b53977cdb3a43e0ba98">wxLuaState::lua_ToBoolean</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3473. <a name="l03444"></a>03444 <span class="keyword"></span>{
  3474. <a name="l03445"></a>03445 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3475. <a name="l03446"></a>03446 <span class="keywordflow">return</span> lua_toboolean(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index);
  3476. <a name="l03447"></a>03447 }
  3477. <a name="l03448"></a><a class="code" href="classwxLuaState.html#aeca8ed49381d1db41467895600bb2715">03448</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classwxLuaState.html#aeca8ed49381d1db41467895600bb2715">wxLuaState::lua_ToString</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3478. <a name="l03449"></a>03449 <span class="keyword"></span>{
  3479. <a name="l03450"></a>03450 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3480. <a name="l03451"></a>03451 <span class="keywordflow">return</span> lua_tostring(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index);
  3481. <a name="l03452"></a>03452 }
  3482. <a name="l03453"></a><a class="code" href="classwxLuaState.html#aa1e2a352d7eea7def33de09573f3f2b5">03453</a> wxString <a class="code" href="classwxLuaState.html#aa1e2a352d7eea7def33de09573f3f2b5">wxLuaState::lua_TowxString</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3483. <a name="l03454"></a>03454 <span class="keyword"></span>{
  3484. <a name="l03455"></a>03455 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3485. <a name="l03456"></a>03456 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(lua_tostring(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index));
  3486. <a name="l03457"></a>03457 }
  3487. <a name="l03458"></a><a class="code" href="classwxLuaState.html#a9d0e3d87206186152675787d77cd32ad">03458</a> <span class="keywordtype">size_t</span> <a class="code" href="classwxLuaState.html#a9d0e3d87206186152675787d77cd32ad">wxLuaState::lua_StrLen</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3488. <a name="l03459"></a>03459 <span class="keyword"></span>{
  3489. <a name="l03460"></a>03460 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3490. <a name="l03461"></a>03461 <span class="keywordflow">return</span> lua_strlen(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index);
  3491. <a name="l03462"></a>03462 }
  3492. <a name="l03463"></a><a class="code" href="classwxLuaState.html#a7d0ed9203ffc6fd4341e676ff52b3860">03463</a> <span class="keywordtype">size_t</span> <a class="code" href="classwxLuaState.html#a7d0ed9203ffc6fd4341e676ff52b3860">wxLuaState::luaL_ObjLen</a>(<span class="keywordtype">int</span> t)<span class="keyword"> const</span>
  3493. <a name="l03464"></a>03464 <span class="keyword"></span>{
  3494. <a name="l03465"></a>03465 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3495. <a name="l03466"></a>03466 <span class="keywordflow">return</span> lua_objlen(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, t);
  3496. <a name="l03467"></a>03467 }
  3497. <a name="l03468"></a><a class="code" href="classwxLuaState.html#a39708fb9e23787555d92566db49e4352">03468</a> lua_CFunction <a class="code" href="classwxLuaState.html#a39708fb9e23787555d92566db49e4352">wxLuaState::lua_ToCFunction</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3498. <a name="l03469"></a>03469 <span class="keyword"></span>{
  3499. <a name="l03470"></a>03470 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3500. <a name="l03471"></a>03471 <span class="keywordflow">return</span> lua_tocfunction(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index);
  3501. <a name="l03472"></a>03472 }
  3502. <a name="l03473"></a><a class="code" href="classwxLuaState.html#aacefd915407e20df12bdb12857fa26d8">03473</a> <span class="keywordtype">void</span> *<a class="code" href="classwxLuaState.html#aacefd915407e20df12bdb12857fa26d8">wxLuaState::lua_ToUserdata</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3503. <a name="l03474"></a>03474 <span class="keyword"></span>{
  3504. <a name="l03475"></a>03475 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3505. <a name="l03476"></a>03476 <span class="keywordflow">return</span> lua_touserdata(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index);
  3506. <a name="l03477"></a>03477 }
  3507. <a name="l03478"></a><a class="code" href="classwxLuaState.html#a64eef6a5d1628088d4e0e031cd763900">03478</a> <a class="code" href="classwxLuaState.html">wxLuaState</a> <a class="code" href="classwxLuaState.html#a64eef6a5d1628088d4e0e031cd763900">wxLuaState::lua_ToThread</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3508. <a name="l03479"></a>03479 <span class="keyword"></span>{
  3509. <a name="l03480"></a>03480 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3510. <a name="l03481"></a>03481 <span class="keywordflow">return</span> <a class="code" href="classwxLuaState.html#a40c4a82d65e02d0f5e05dc197b85b978">wxLuaState</a>(lua_tothread(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index));
  3511. <a name="l03482"></a>03482 }
  3512. <a name="l03483"></a><a class="code" href="classwxLuaState.html#a39bbcb24eaa6a885f15bd6d7cf9722e1">03483</a> <span class="keyword">const</span> <span class="keywordtype">void</span>* <a class="code" href="classwxLuaState.html#a39bbcb24eaa6a885f15bd6d7cf9722e1">wxLuaState::lua_ToPointer</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const</span>
  3513. <a name="l03484"></a>03484 <span class="keyword"></span>{
  3514. <a name="l03485"></a>03485 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3515. <a name="l03486"></a>03486 <span class="keywordflow">return</span> lua_topointer(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, index);
  3516. <a name="l03487"></a>03487 }
  3517. <a name="l03488"></a>03488
  3518. <a name="l03489"></a>03489 <span class="comment">// ----------------------------------------------------------------------------</span>
  3519. <a name="l03490"></a>03490 <span class="comment">// Raw Lua push functions (C -&gt; stack)</span>
  3520. <a name="l03491"></a>03491
  3521. <a name="l03492"></a><a class="code" href="classwxLuaState.html#a56b6f86c8c6f5c56bf90d45397cde17f">03492</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a56b6f86c8c6f5c56bf90d45397cde17f">wxLuaState::lua_PushNil</a>()
  3522. <a name="l03493"></a>03493 {
  3523. <a name="l03494"></a>03494 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3524. <a name="l03495"></a>03495 lua_pushnil(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State);
  3525. <a name="l03496"></a>03496 }
  3526. <a name="l03497"></a><a class="code" href="classwxLuaState.html#a17de2cec3383dbb2b958ccce75b9d6cc">03497</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a17de2cec3383dbb2b958ccce75b9d6cc">wxLuaState::lua_PushNumber</a>(lua_Number n)
  3527. <a name="l03498"></a>03498 {
  3528. <a name="l03499"></a>03499 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3529. <a name="l03500"></a>03500 lua_pushnumber(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, n);
  3530. <a name="l03501"></a>03501 }
  3531. <a name="l03502"></a><a class="code" href="classwxLuaState.html#a696e12210b8db4e3f68b000b8f939b65">03502</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a696e12210b8db4e3f68b000b8f939b65">wxLuaState::lua_PushInteger</a>(lua_Integer n)
  3532. <a name="l03503"></a>03503 {
  3533. <a name="l03504"></a>03504 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3534. <a name="l03505"></a>03505 lua_pushinteger(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, n);
  3535. <a name="l03506"></a>03506 }
  3536. <a name="l03507"></a><a class="code" href="classwxLuaState.html#a5baf62e71ab1656ade0566f5e2e21252">03507</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a5baf62e71ab1656ade0566f5e2e21252">wxLuaState::lua_PushLString</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* s, <span class="keywordtype">size_t</span> len)
  3537. <a name="l03508"></a>03508 {
  3538. <a name="l03509"></a>03509 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3539. <a name="l03510"></a>03510 lua_pushlstring(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, s, len);
  3540. <a name="l03511"></a>03511 }
  3541. <a name="l03512"></a><a class="code" href="classwxLuaState.html#a1b7e4cbbc4cf03c493891a63d1036637">03512</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a1b7e4cbbc4cf03c493891a63d1036637">wxLuaState::lua_PushString</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* s)
  3542. <a name="l03513"></a>03513 {
  3543. <a name="l03514"></a>03514 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3544. <a name="l03515"></a>03515 lua_pushstring(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, s);
  3545. <a name="l03516"></a>03516 }
  3546. <a name="l03517"></a><a class="code" href="classwxLuaState.html#aad677b90f1e031cb7294d9f29fc228d1">03517</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#aad677b90f1e031cb7294d9f29fc228d1">wxLuaState::lua_PushCClosure</a>(lua_CFunction fn, <span class="keywordtype">int</span> n)
  3547. <a name="l03518"></a>03518 {
  3548. <a name="l03519"></a>03519 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3549. <a name="l03520"></a>03520 lua_pushcclosure(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, fn, n);
  3550. <a name="l03521"></a>03521 }
  3551. <a name="l03522"></a><a class="code" href="classwxLuaState.html#a1c72061b031460381d28af236d73fdd9">03522</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a1c72061b031460381d28af236d73fdd9">wxLuaState::lua_PushBoolean</a>(<span class="keywordtype">bool</span> b)
  3552. <a name="l03523"></a>03523 {
  3553. <a name="l03524"></a>03524 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3554. <a name="l03525"></a>03525 lua_pushboolean(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, b ? 1 : 0);
  3555. <a name="l03526"></a>03526 }
  3556. <a name="l03527"></a><a class="code" href="classwxLuaState.html#a47ec838d79914ad57cf889a726f4ba45">03527</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a47ec838d79914ad57cf889a726f4ba45">wxLuaState::lua_PushLightUserdata</a>(<span class="keywordtype">void</span>* p)
  3557. <a name="l03528"></a>03528 {
  3558. <a name="l03529"></a>03529 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3559. <a name="l03530"></a>03530 lua_pushlightuserdata(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, p);
  3560. <a name="l03531"></a>03531 }
  3561. <a name="l03532"></a>03532
  3562. <a name="l03533"></a>03533 <span class="comment">// ----------------------------------------------------------------------------</span>
  3563. <a name="l03534"></a>03534 <span class="comment">// Raw Lua get functions (Lua -&gt; stack)</span>
  3564. <a name="l03535"></a>03535
  3565. <a name="l03536"></a><a class="code" href="classwxLuaState.html#a3f46c4e97ebf59dee509d080bcc05a22">03536</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a3f46c4e97ebf59dee509d080bcc05a22">wxLuaState::lua_GetTable</a>(<span class="keywordtype">int</span> idx)
  3566. <a name="l03537"></a>03537 {
  3567. <a name="l03538"></a>03538 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3568. <a name="l03539"></a>03539 lua_gettable(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3569. <a name="l03540"></a>03540 }
  3570. <a name="l03541"></a><a class="code" href="classwxLuaState.html#a2f323ac4b8787d9b1c3bf579e8e180b5">03541</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a2f323ac4b8787d9b1c3bf579e8e180b5">wxLuaState::lua_GetField</a>(<span class="keywordtype">int</span> idx, <span class="keyword">const</span> <span class="keywordtype">char</span>* k)
  3571. <a name="l03542"></a>03542 {
  3572. <a name="l03543"></a>03543 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3573. <a name="l03544"></a>03544 lua_getfield(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx, k);
  3574. <a name="l03545"></a>03545 }
  3575. <a name="l03546"></a><a class="code" href="classwxLuaState.html#af129d25118da130be2ed38c11493e100">03546</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#af129d25118da130be2ed38c11493e100">wxLuaState::lua_RawGet</a>(<span class="keywordtype">int</span> idx)
  3576. <a name="l03547"></a>03547 {
  3577. <a name="l03548"></a>03548 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3578. <a name="l03549"></a>03549 lua_rawget(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3579. <a name="l03550"></a>03550 }
  3580. <a name="l03551"></a><a class="code" href="classwxLuaState.html#a07eca88dc8961465a44cec04dc148072">03551</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a07eca88dc8961465a44cec04dc148072">wxLuaState::lua_RawGeti</a>(<span class="keywordtype">int</span> idx, <span class="keywordtype">int</span> n)
  3581. <a name="l03552"></a>03552 {
  3582. <a name="l03553"></a>03553 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3583. <a name="l03554"></a>03554 lua_rawgeti(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx, n);
  3584. <a name="l03555"></a>03555 }
  3585. <a name="l03556"></a><a class="code" href="classwxLuaState.html#a3cd3a14ae86885fc283f93cd52f3d4ff">03556</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a3cd3a14ae86885fc283f93cd52f3d4ff">wxLuaState::lua_CreateTable</a>(<span class="keywordtype">int</span> narr, <span class="keywordtype">int</span> nrec)
  3586. <a name="l03557"></a>03557 {
  3587. <a name="l03558"></a>03558 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3588. <a name="l03559"></a>03559 lua_createtable(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, narr, nrec);
  3589. <a name="l03560"></a>03560 }
  3590. <a name="l03561"></a><a class="code" href="classwxLuaState.html#a3d66f862992b961aa8fa786192d95cfc">03561</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a3d66f862992b961aa8fa786192d95cfc">wxLuaState::lua_NewTable</a>()
  3591. <a name="l03562"></a>03562 {
  3592. <a name="l03563"></a>03563 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3593. <a name="l03564"></a>03564 lua_newtable(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State);
  3594. <a name="l03565"></a>03565 }
  3595. <a name="l03566"></a><a class="code" href="classwxLuaState.html#ab3ba306171f48d9f7e49203c895058e0">03566</a> <span class="keywordtype">void</span>* <a class="code" href="classwxLuaState.html#ab3ba306171f48d9f7e49203c895058e0">wxLuaState::lua_NewUserdata</a>(<span class="keywordtype">size_t</span> sz)
  3596. <a name="l03567"></a>03567 {
  3597. <a name="l03568"></a>03568 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3598. <a name="l03569"></a>03569 <span class="keywordflow">return</span> lua_newuserdata(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, sz);
  3599. <a name="l03570"></a>03570 }
  3600. <a name="l03571"></a><a class="code" href="classwxLuaState.html#aa44b979d291075ddd9136505dbac338d">03571</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#aa44b979d291075ddd9136505dbac338d">wxLuaState::lua_GetMetatable</a>(<span class="keywordtype">int</span> objindex)
  3601. <a name="l03572"></a>03572 {
  3602. <a name="l03573"></a>03573 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3603. <a name="l03574"></a>03574 <span class="keywordflow">return</span> lua_getmetatable(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, objindex);
  3604. <a name="l03575"></a>03575 }
  3605. <a name="l03576"></a><a class="code" href="classwxLuaState.html#a0ff4c1b9693301ccce4b05fbd9632697">03576</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a0ff4c1b9693301ccce4b05fbd9632697">wxLuaState::lua_GetFenv</a>(<span class="keywordtype">int</span> idx)
  3606. <a name="l03577"></a>03577 {
  3607. <a name="l03578"></a>03578 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3608. <a name="l03579"></a>03579 lua_getfenv(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3609. <a name="l03580"></a>03580 }
  3610. <a name="l03581"></a>03581
  3611. <a name="l03582"></a>03582 <span class="comment">// -----------------------------------------------------------------------</span>
  3612. <a name="l03583"></a>03583 <span class="comment">// Raw Lua set functions (stack -&gt; Lua)</span>
  3613. <a name="l03584"></a>03584
  3614. <a name="l03585"></a><a class="code" href="classwxLuaState.html#af1741b663aabde9b0645931d152077a4">03585</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#af1741b663aabde9b0645931d152077a4">wxLuaState::lua_SetTable</a>(<span class="keywordtype">int</span> idx)
  3615. <a name="l03586"></a>03586 {
  3616. <a name="l03587"></a>03587 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3617. <a name="l03588"></a>03588 lua_settable(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3618. <a name="l03589"></a>03589 }
  3619. <a name="l03590"></a><a class="code" href="classwxLuaState.html#abdb2eee6a3187b350cd3a8b3f8f7aa47">03590</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#abdb2eee6a3187b350cd3a8b3f8f7aa47">wxLuaState::lua_SetField</a>(<span class="keywordtype">int</span> idx, <span class="keyword">const</span> <span class="keywordtype">char</span>* k)
  3620. <a name="l03591"></a>03591 {
  3621. <a name="l03592"></a>03592 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3622. <a name="l03593"></a>03593 lua_setfield(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx, k);
  3623. <a name="l03594"></a>03594 }
  3624. <a name="l03595"></a><a class="code" href="classwxLuaState.html#a3bd173a9a89485294a51e800b934774f">03595</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a3bd173a9a89485294a51e800b934774f">wxLuaState::lua_RawSet</a>(<span class="keywordtype">int</span> idx)
  3625. <a name="l03596"></a>03596 {
  3626. <a name="l03597"></a>03597 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3627. <a name="l03598"></a>03598 lua_rawset(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3628. <a name="l03599"></a>03599 }
  3629. <a name="l03600"></a><a class="code" href="classwxLuaState.html#a49020320487e5c1b6229d9b8e0a4ae9e">03600</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a49020320487e5c1b6229d9b8e0a4ae9e">wxLuaState::lua_RawSeti</a>(<span class="keywordtype">int</span> idx, <span class="keywordtype">int</span> n)
  3630. <a name="l03601"></a>03601 {
  3631. <a name="l03602"></a>03602 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3632. <a name="l03603"></a>03603 lua_rawseti(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx, n);
  3633. <a name="l03604"></a>03604 }
  3634. <a name="l03605"></a><a class="code" href="classwxLuaState.html#a491fc3dbd0859d6d521c974af6f87cc0">03605</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a491fc3dbd0859d6d521c974af6f87cc0">wxLuaState::lua_SetMetatable</a>(<span class="keywordtype">int</span> objindex)
  3635. <a name="l03606"></a>03606 {
  3636. <a name="l03607"></a>03607 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3637. <a name="l03608"></a>03608 <span class="keywordflow">return</span> lua_setmetatable(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, objindex);
  3638. <a name="l03609"></a>03609 }
  3639. <a name="l03610"></a><a class="code" href="classwxLuaState.html#a452fc13b21c961150fc1ddb9c1102241">03610</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a452fc13b21c961150fc1ddb9c1102241">wxLuaState::lua_SetFenv</a>(<span class="keywordtype">int</span> idx)
  3640. <a name="l03611"></a>03611 {
  3641. <a name="l03612"></a>03612 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3642. <a name="l03613"></a>03613 <span class="keywordflow">return</span> lua_setfenv(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3643. <a name="l03614"></a>03614 }
  3644. <a name="l03615"></a>03615
  3645. <a name="l03616"></a>03616 <span class="comment">// ----------------------------------------------------------------------------</span>
  3646. <a name="l03617"></a>03617 <span class="comment">// Raw Lua `load&#39; and `call&#39; functions (load and run Lua code)</span>
  3647. <a name="l03618"></a>03618
  3648. <a name="l03619"></a><a class="code" href="classwxLuaState.html#ac718b3a147747b696ee202f6bd8b9e73">03619</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#ac718b3a147747b696ee202f6bd8b9e73">wxLuaState::lua_Call</a>(<span class="keywordtype">int</span> nargs, <span class="keywordtype">int</span> nresults)
  3649. <a name="l03620"></a>03620 {
  3650. <a name="l03621"></a>03621 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3651. <a name="l03622"></a>03622 lua_call(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, nargs, nresults);
  3652. <a name="l03623"></a>03623 }
  3653. <a name="l03624"></a><a class="code" href="classwxLuaState.html#a781a41a5024e63693c74e047454148af">03624</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a781a41a5024e63693c74e047454148af">wxLuaState::lua_PCall</a>(<span class="keywordtype">int</span> nargs, <span class="keywordtype">int</span> nresults, <span class="keywordtype">int</span> errfunc)
  3654. <a name="l03625"></a>03625 {
  3655. <a name="l03626"></a>03626 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3656. <a name="l03627"></a>03627 <span class="keywordflow">return</span> lua_pcall(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, nargs, nresults, errfunc);
  3657. <a name="l03628"></a>03628 }
  3658. <a name="l03629"></a><a class="code" href="classwxLuaState.html#a46c3379f216254e9d32bf33812d21f3b">03629</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a46c3379f216254e9d32bf33812d21f3b">wxLuaState::lua_CPCall</a>(lua_CFunction func, <span class="keywordtype">void</span> *ud)
  3659. <a name="l03630"></a>03630 {
  3660. <a name="l03631"></a>03631 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3661. <a name="l03632"></a>03632 <span class="keywordflow">return</span> lua_cpcall(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, func, ud);
  3662. <a name="l03633"></a>03633 }
  3663. <a name="l03634"></a>03634 <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a192de690035cb3be6308f0cbac8da0b8">wxLuaState::lua_Load</a>(lua_Chunkreader reader, <span class="keywordtype">void</span> *dt, <span class="keyword">const</span> <span class="keywordtype">char</span>* chunkname)
  3664. <a name="l03635"></a>03635 {
  3665. <a name="l03636"></a>03636 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3666. <a name="l03637"></a>03637 <span class="keywordflow">return</span> lua_load(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, reader, dt, chunkname);
  3667. <a name="l03638"></a>03638 }
  3668. <a name="l03639"></a><a class="code" href="classwxLuaState.html#a2549a9815de6771b5d5e51148e60da16">03639</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a2549a9815de6771b5d5e51148e60da16">wxLuaState::lua_Dump</a>(lua_Writer writer, <span class="keywordtype">void</span> *data)
  3669. <a name="l03640"></a>03640 {
  3670. <a name="l03641"></a>03641 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3671. <a name="l03642"></a>03642 <span class="keywordflow">return</span> lua_dump(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, writer, data);
  3672. <a name="l03643"></a>03643 }
  3673. <a name="l03644"></a>03644
  3674. <a name="l03645"></a>03645 <span class="comment">// ----------------------------------------------------------------------------</span>
  3675. <a name="l03646"></a>03646 <span class="comment">// Raw Lua coroutine functions</span>
  3676. <a name="l03647"></a>03647
  3677. <a name="l03648"></a><a class="code" href="classwxLuaState.html#ad58ef9e838892c9b816683418abb7e86">03648</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#ad58ef9e838892c9b816683418abb7e86">wxLuaState::lua_Yield</a>(<span class="keywordtype">int</span> nresults)
  3678. <a name="l03649"></a>03649 {
  3679. <a name="l03650"></a>03650 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3680. <a name="l03651"></a>03651 <span class="keywordflow">return</span> lua_yield(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, nresults);
  3681. <a name="l03652"></a>03652 }
  3682. <a name="l03653"></a><a class="code" href="classwxLuaState.html#aab1624c17cef7d060447776cbba8fe2c">03653</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#aab1624c17cef7d060447776cbba8fe2c">wxLuaState::lua_Resume</a>(<span class="keywordtype">int</span> narg)
  3683. <a name="l03654"></a>03654 {
  3684. <a name="l03655"></a>03655 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3685. <a name="l03656"></a>03656 <span class="keywordflow">return</span> lua_resume(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, narg);
  3686. <a name="l03657"></a>03657 }
  3687. <a name="l03658"></a><a class="code" href="classwxLuaState.html#aa6f54828f0da17e14b3628f6ec679c4e">03658</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#aa6f54828f0da17e14b3628f6ec679c4e">wxLuaState::lua_Status</a>()
  3688. <a name="l03659"></a>03659 {
  3689. <a name="l03660"></a>03660 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3690. <a name="l03661"></a>03661 <span class="keywordflow">return</span> lua_status(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State);
  3691. <a name="l03662"></a>03662 }
  3692. <a name="l03663"></a>03663
  3693. <a name="l03664"></a>03664 <span class="comment">// ----------------------------------------------------------------------------</span>
  3694. <a name="l03665"></a>03665 <span class="comment">// Raw Lua garbage-collection functions</span>
  3695. <a name="l03666"></a>03666
  3696. <a name="l03667"></a><a class="code" href="classwxLuaState.html#ac097f85f5ad881ce4862bdc4458626ef">03667</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#ac097f85f5ad881ce4862bdc4458626ef">wxLuaState::lua_GetGCCount</a>()
  3697. <a name="l03668"></a>03668 {
  3698. <a name="l03669"></a>03669 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3699. <a name="l03670"></a>03670 <span class="keywordflow">return</span> lua_getgccount(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State);
  3700. <a name="l03671"></a>03671 }
  3701. <a name="l03672"></a>03672
  3702. <a name="l03673"></a>03673 <span class="comment">// ----------------------------------------------------------------------------</span>
  3703. <a name="l03674"></a>03674 <span class="comment">// Raw Lua miscellaneous functions</span>
  3704. <a name="l03675"></a>03675
  3705. <a name="l03676"></a><a class="code" href="classwxLuaState.html#a499168abf30db694cf2a5414f6257acb">03676</a> wxString <a class="code" href="classwxLuaState.html#a499168abf30db694cf2a5414f6257acb">wxLuaState::lua_Version</a>()<span class="keyword"> const</span>
  3706. <a name="l03677"></a>03677 <span class="keyword"></span>{
  3707. <a name="l03678"></a>03678 <span class="keywordflow">return</span> <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(LUA_VERSION);
  3708. <a name="l03679"></a>03679 }
  3709. <a name="l03680"></a><a class="code" href="classwxLuaState.html#a6404139fa9de942865139446e36a9b72">03680</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a6404139fa9de942865139446e36a9b72">wxLuaState::lua_Error</a>()
  3710. <a name="l03681"></a>03681 {
  3711. <a name="l03682"></a>03682 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3712. <a name="l03683"></a>03683 <span class="keywordflow">return</span> lua_error(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State);
  3713. <a name="l03684"></a>03684 }
  3714. <a name="l03685"></a><a class="code" href="classwxLuaState.html#a128341ace764ee4ff73c201c4c226b86">03685</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a128341ace764ee4ff73c201c4c226b86">wxLuaState::lua_Next</a>(<span class="keywordtype">int</span> idx)
  3715. <a name="l03686"></a>03686 {
  3716. <a name="l03687"></a>03687 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3717. <a name="l03688"></a>03688 <span class="keywordflow">return</span> lua_next(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3718. <a name="l03689"></a>03689 }
  3719. <a name="l03690"></a><a class="code" href="classwxLuaState.html#abedf6fddf400cea16cbf72bbea722581">03690</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#abedf6fddf400cea16cbf72bbea722581">wxLuaState::lua_Concat</a>(<span class="keywordtype">int</span> n)
  3720. <a name="l03691"></a>03691 {
  3721. <a name="l03692"></a>03692 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3722. <a name="l03693"></a>03693 lua_concat(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, n);
  3723. <a name="l03694"></a>03694 }
  3724. <a name="l03695"></a>03695
  3725. <a name="l03696"></a>03696 <span class="comment">// -----------------------------------------------------------------------</span>
  3726. <a name="l03697"></a>03697 <span class="comment">// Raw Lua some useful &quot;macros&quot;, lua.h</span>
  3727. <a name="l03698"></a>03698
  3728. <a name="l03699"></a><a class="code" href="classwxLuaState.html#a41ddece597c77fac7e51905d3dc58381">03699</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a41ddece597c77fac7e51905d3dc58381">wxLuaState::lua_Register</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* funcName, lua_CFunction f)
  3729. <a name="l03700"></a>03700 {
  3730. <a name="l03701"></a>03701 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3731. <a name="l03702"></a>03702 lua_register(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, funcName, f);
  3732. <a name="l03703"></a>03703 }
  3733. <a name="l03704"></a><a class="code" href="classwxLuaState.html#ae892e9b51785a3d96649770a8b73c7a5">03704</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#ae892e9b51785a3d96649770a8b73c7a5">wxLuaState::lua_PushCFunction</a>(lua_CFunction f)
  3734. <a name="l03705"></a>03705 {
  3735. <a name="l03706"></a>03706 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3736. <a name="l03707"></a>03707 lua_pushcfunction(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, f);
  3737. <a name="l03708"></a>03708 }
  3738. <a name="l03709"></a>03709
  3739. <a name="l03710"></a><a class="code" href="classwxLuaState.html#ac34ce5629f48bb30ca62c1b929633df5">03710</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#ac34ce5629f48bb30ca62c1b929633df5">wxLuaState::lua_IsFunction</a>(<span class="keywordtype">int</span> idx)<span class="keyword"> const</span>
  3740. <a name="l03711"></a>03711 <span class="keyword"></span>{
  3741. <a name="l03712"></a>03712 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3742. <a name="l03713"></a>03713 <span class="keywordflow">return</span> lua_isfunction(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3743. <a name="l03714"></a>03714 }
  3744. <a name="l03715"></a><a class="code" href="classwxLuaState.html#af130b3fd0af4619d2c43a33101d024b5">03715</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#af130b3fd0af4619d2c43a33101d024b5">wxLuaState::lua_IsTable</a>(<span class="keywordtype">int</span> idx)<span class="keyword"> const</span>
  3745. <a name="l03716"></a>03716 <span class="keyword"></span>{
  3746. <a name="l03717"></a>03717 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3747. <a name="l03718"></a>03718 <span class="keywordflow">return</span> lua_istable(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3748. <a name="l03719"></a>03719 }
  3749. <a name="l03720"></a><a class="code" href="classwxLuaState.html#af8c4dce84f7d46e01817ce5ca87153f3">03720</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#af8c4dce84f7d46e01817ce5ca87153f3">wxLuaState::lua_IsLightUserdata</a>(<span class="keywordtype">int</span> idx)<span class="keyword"> const</span>
  3750. <a name="l03721"></a>03721 <span class="keyword"></span>{
  3751. <a name="l03722"></a>03722 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3752. <a name="l03723"></a>03723 <span class="keywordflow">return</span> lua_islightuserdata(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3753. <a name="l03724"></a>03724 }
  3754. <a name="l03725"></a><a class="code" href="classwxLuaState.html#abce32b2702801623cc3183087bc318aa">03725</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#abce32b2702801623cc3183087bc318aa">wxLuaState::lua_IsNil</a>(<span class="keywordtype">int</span> idx)<span class="keyword"> const</span>
  3755. <a name="l03726"></a>03726 <span class="keyword"></span>{
  3756. <a name="l03727"></a>03727 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3757. <a name="l03728"></a>03728 <span class="keywordflow">return</span> lua_isnil(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3758. <a name="l03729"></a>03729 }
  3759. <a name="l03730"></a><a class="code" href="classwxLuaState.html#a9555bd208e15bb3a483b08107fa2b81b">03730</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a9555bd208e15bb3a483b08107fa2b81b">wxLuaState::lua_IsBoolean</a>(<span class="keywordtype">int</span> idx)<span class="keyword"> const</span>
  3760. <a name="l03731"></a>03731 <span class="keyword"></span>{
  3761. <a name="l03732"></a>03732 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3762. <a name="l03733"></a>03733 <span class="keywordflow">return</span> lua_isboolean(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3763. <a name="l03734"></a>03734 }
  3764. <a name="l03735"></a><a class="code" href="classwxLuaState.html#af3da454dcbf6f406b26fb0dbf7011458">03735</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#af3da454dcbf6f406b26fb0dbf7011458">wxLuaState::lua_IsThread</a>(<span class="keywordtype">int</span> idx)<span class="keyword"> const</span>
  3765. <a name="l03736"></a>03736 <span class="keyword"></span>{
  3766. <a name="l03737"></a>03737 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3767. <a name="l03738"></a>03738 <span class="keywordflow">return</span> lua_isthread(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3768. <a name="l03739"></a>03739 }
  3769. <a name="l03740"></a><a class="code" href="classwxLuaState.html#ac35276223eaf2095936bbf81759a76ee">03740</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#ac35276223eaf2095936bbf81759a76ee">wxLuaState::lua_IsNone</a>(<span class="keywordtype">int</span> idx)<span class="keyword"> const</span>
  3770. <a name="l03741"></a>03741 <span class="keyword"></span>{
  3771. <a name="l03742"></a>03742 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3772. <a name="l03743"></a>03743 <span class="keywordflow">return</span> lua_isnone(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3773. <a name="l03744"></a>03744 }
  3774. <a name="l03745"></a><a class="code" href="classwxLuaState.html#a89777be73604209624dc2aaaa009bcd0">03745</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaState.html#a89777be73604209624dc2aaaa009bcd0">wxLuaState::lua_IsNoneOrNil</a>(<span class="keywordtype">int</span> idx)<span class="keyword"> const</span>
  3775. <a name="l03746"></a>03746 <span class="keyword"></span>{
  3776. <a name="l03747"></a>03747 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3777. <a name="l03748"></a>03748 <span class="keywordflow">return</span> lua_isnoneornil(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, idx);
  3778. <a name="l03749"></a>03749 }
  3779. <a name="l03750"></a>03750
  3780. <a name="l03751"></a><a class="code" href="classwxLuaState.html#acbec13da5eea296b2a32180e96d27653">03751</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#acbec13da5eea296b2a32180e96d27653">wxLuaState::lua_SetGlobal</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* s)
  3781. <a name="l03752"></a>03752 {
  3782. <a name="l03753"></a>03753 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3783. <a name="l03754"></a>03754 lua_setglobal(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, s);
  3784. <a name="l03755"></a>03755 }
  3785. <a name="l03756"></a><a class="code" href="classwxLuaState.html#a3854acdfe8cf1a0d96e1d82ce9f181d4">03756</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a3854acdfe8cf1a0d96e1d82ce9f181d4">wxLuaState::lua_GetGlobal</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* s)
  3786. <a name="l03757"></a>03757 {
  3787. <a name="l03758"></a>03758 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3788. <a name="l03759"></a>03759 lua_getglobal(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, s);
  3789. <a name="l03760"></a>03760 }
  3790. <a name="l03761"></a>03761
  3791. <a name="l03762"></a>03762 <span class="comment">// ----------------------------------------------------------------------------</span>
  3792. <a name="l03763"></a>03763 <span class="comment">// Raw Lua Debug functions, lua.h</span>
  3793. <a name="l03764"></a>03764
  3794. <a name="l03765"></a><a class="code" href="classwxLuaState.html#a2b9bbc6b26008ca3abb72b066a41acc0">03765</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a2b9bbc6b26008ca3abb72b066a41acc0">wxLuaState::lua_GetStack</a>(<span class="keywordtype">int</span> level, lua_Debug* ar)
  3795. <a name="l03766"></a>03766 {
  3796. <a name="l03767"></a>03767 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3797. <a name="l03768"></a>03768 <span class="keywordflow">return</span> lua_getstack(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, level, ar);
  3798. <a name="l03769"></a>03769 }
  3799. <a name="l03770"></a><a class="code" href="classwxLuaState.html#a8e2c3d55b777a57e3083040fe87cbbb6">03770</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a8e2c3d55b777a57e3083040fe87cbbb6">wxLuaState::lua_GetInfo</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* what, lua_Debug* ar)
  3800. <a name="l03771"></a>03771 {
  3801. <a name="l03772"></a>03772 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3802. <a name="l03773"></a>03773 <span class="keywordflow">return</span> lua_getinfo(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, what, ar);
  3803. <a name="l03774"></a>03774 }
  3804. <a name="l03775"></a><a class="code" href="classwxLuaState.html#abe899715bc534990fa1c3ebca0f321a4">03775</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classwxLuaState.html#abe899715bc534990fa1c3ebca0f321a4">wxLuaState::lua_GetLocal</a>(<span class="keyword">const</span> lua_Debug* ar, <span class="keywordtype">int</span> n)
  3805. <a name="l03776"></a>03776 {
  3806. <a name="l03777"></a>03777 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3807. <a name="l03778"></a>03778 <span class="keywordflow">return</span> lua_getlocal(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, ar, n);
  3808. <a name="l03779"></a>03779 }
  3809. <a name="l03780"></a><a class="code" href="classwxLuaState.html#a30dcd065728833c923c89d3cbfaae1b4">03780</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classwxLuaState.html#a30dcd065728833c923c89d3cbfaae1b4">wxLuaState::lua_SetLocal</a>(<span class="keyword">const</span> lua_Debug* ar, <span class="keywordtype">int</span> n)
  3810. <a name="l03781"></a>03781 {
  3811. <a name="l03782"></a>03782 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3812. <a name="l03783"></a>03783 <span class="keywordflow">return</span> lua_setlocal(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, ar, n);
  3813. <a name="l03784"></a>03784 }
  3814. <a name="l03785"></a><a class="code" href="classwxLuaState.html#adbabef133a49f76870d84a570a6711b1">03785</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classwxLuaState.html#adbabef133a49f76870d84a570a6711b1">wxLuaState::lua_GetUpvalue</a>(<span class="keywordtype">int</span> funcindex, <span class="keywordtype">int</span> n)
  3815. <a name="l03786"></a>03786 {
  3816. <a name="l03787"></a>03787 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3817. <a name="l03788"></a>03788 <span class="keywordflow">return</span> lua_getupvalue(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, funcindex, n);
  3818. <a name="l03789"></a>03789 }
  3819. <a name="l03790"></a><a class="code" href="classwxLuaState.html#ab72f4128d0be510cfff7f99fefc04a8b">03790</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classwxLuaState.html#ab72f4128d0be510cfff7f99fefc04a8b">wxLuaState::lua_SetUpvalue</a>(<span class="keywordtype">int</span> funcindex, <span class="keywordtype">int</span> n)
  3820. <a name="l03791"></a>03791 {
  3821. <a name="l03792"></a>03792 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3822. <a name="l03793"></a>03793 <span class="keywordflow">return</span> lua_setupvalue(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, funcindex, n);
  3823. <a name="l03794"></a>03794 }
  3824. <a name="l03795"></a>03795
  3825. <a name="l03796"></a><a class="code" href="classwxLuaState.html#a92f9cef37273ad660cf23f2142d1a125">03796</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a92f9cef37273ad660cf23f2142d1a125">wxLuaState::lua_SetHook</a>(lua_Hook func, <span class="keywordtype">int</span> mask, <span class="keywordtype">int</span> count)
  3826. <a name="l03797"></a>03797 {
  3827. <a name="l03798"></a>03798 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3828. <a name="l03799"></a>03799 <span class="keywordflow">return</span> lua_sethook(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, func, mask, count);
  3829. <a name="l03800"></a>03800 }
  3830. <a name="l03801"></a><a class="code" href="classwxLuaState.html#a32f81e9a49933dfdafef05d03632ac9a">03801</a> lua_Hook <a class="code" href="classwxLuaState.html#a32f81e9a49933dfdafef05d03632ac9a">wxLuaState::lua_GetHook</a>()
  3831. <a name="l03802"></a>03802 {
  3832. <a name="l03803"></a>03803 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3833. <a name="l03804"></a>03804 <span class="keywordflow">return</span> lua_gethook(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State);
  3834. <a name="l03805"></a>03805 }
  3835. <a name="l03806"></a><a class="code" href="classwxLuaState.html#a62e19da27085e51091b180036be804b0">03806</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a62e19da27085e51091b180036be804b0">wxLuaState::lua_GetHookMask</a>()
  3836. <a name="l03807"></a>03807 {
  3837. <a name="l03808"></a>03808 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3838. <a name="l03809"></a>03809 <span class="keywordflow">return</span> lua_gethookmask(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State);
  3839. <a name="l03810"></a>03810 }
  3840. <a name="l03811"></a><a class="code" href="classwxLuaState.html#a9dc9cee668b422ca08a5613c2e6a426e">03811</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a9dc9cee668b422ca08a5613c2e6a426e">wxLuaState::lua_GetHookCount</a>()
  3841. <a name="l03812"></a>03812 {
  3842. <a name="l03813"></a>03813 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3843. <a name="l03814"></a>03814 <span class="keywordflow">return</span> lua_gethookcount(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State);
  3844. <a name="l03815"></a>03815 }
  3845. <a name="l03816"></a>03816
  3846. <a name="l03817"></a>03817 <span class="comment">// ----------------------------------------------------------------------------</span>
  3847. <a name="l03818"></a>03818 <span class="comment">// Raw Lua auxlib functions, lauxlib.h</span>
  3848. <a name="l03819"></a>03819
  3849. <a name="l03820"></a><a class="code" href="classwxLuaState.html#a54e1206ab1a0c01dea752f12cb1b5c5f">03820</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a54e1206ab1a0c01dea752f12cb1b5c5f">wxLuaState::luaI_OpenLib</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *libname, <span class="keyword">const</span> luaL_reg *l, <span class="keywordtype">int</span> nup)
  3850. <a name="l03821"></a>03821 {
  3851. <a name="l03822"></a>03822 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3852. <a name="l03823"></a>03823 luaI_openlib(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, libname, l, nup);
  3853. <a name="l03824"></a>03824 }
  3854. <a name="l03825"></a><a class="code" href="classwxLuaState.html#ab440fcdefbea894d5d59a0ffde972a73">03825</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#ab440fcdefbea894d5d59a0ffde972a73">wxLuaState::luaL_Register</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *libname, <span class="keyword">const</span> luaL_reg *l)
  3855. <a name="l03826"></a>03826 {
  3856. <a name="l03827"></a>03827 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3857. <a name="l03828"></a>03828 luaL_register(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, libname, l);
  3858. <a name="l03829"></a>03829 }
  3859. <a name="l03830"></a><a class="code" href="classwxLuaState.html#a6c6dbe21956f17527d65e4d527f2d303">03830</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a6c6dbe21956f17527d65e4d527f2d303">wxLuaState::luaL_GetMetafield</a>(<span class="keywordtype">int</span> obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *e)
  3860. <a name="l03831"></a>03831 {
  3861. <a name="l03832"></a>03832 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3862. <a name="l03833"></a>03833 <span class="keywordflow">return</span> luaL_getmetafield(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, obj, e);
  3863. <a name="l03834"></a>03834 }
  3864. <a name="l03835"></a><a class="code" href="classwxLuaState.html#ab0d3ca9d0fe097cae1ebf7eb0330b2bb">03835</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#ab0d3ca9d0fe097cae1ebf7eb0330b2bb">wxLuaState::luaL_CallMeta</a>(<span class="keywordtype">int</span> obj, <span class="keyword">const</span> <span class="keywordtype">char</span> *e)
  3865. <a name="l03836"></a>03836 {
  3866. <a name="l03837"></a>03837 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3867. <a name="l03838"></a>03838 <span class="keywordflow">return</span> luaL_callmeta(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, obj, e);
  3868. <a name="l03839"></a>03839 }
  3869. <a name="l03840"></a><a class="code" href="classwxLuaState.html#a2a7311c9b8777cacae7f53bfdcbe5c2d">03840</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a2a7311c9b8777cacae7f53bfdcbe5c2d">wxLuaState::luaL_TypeError</a>(<span class="keywordtype">int</span> narg, <span class="keyword">const</span> <span class="keywordtype">char</span> *tname)
  3870. <a name="l03841"></a>03841 {
  3871. <a name="l03842"></a>03842 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3872. <a name="l03843"></a>03843 <span class="keywordflow">return</span> luaL_typerror(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, narg, tname);
  3873. <a name="l03844"></a>03844 }
  3874. <a name="l03845"></a><a class="code" href="classwxLuaState.html#adcf44e9f5029e04ed411eed39c99e755">03845</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#adcf44e9f5029e04ed411eed39c99e755">wxLuaState::luaL_ArgError</a>(<span class="keywordtype">int</span> numarg, <span class="keyword">const</span> <span class="keywordtype">char</span> *extramsg)
  3875. <a name="l03846"></a>03846 {
  3876. <a name="l03847"></a>03847 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3877. <a name="l03848"></a>03848 <span class="keywordflow">return</span> luaL_argerror(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, numarg, extramsg);
  3878. <a name="l03849"></a>03849 }
  3879. <a name="l03850"></a><a class="code" href="classwxLuaState.html#a2edde5b8929f9803427b6ca8ba174798">03850</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classwxLuaState.html#a2edde5b8929f9803427b6ca8ba174798">wxLuaState::luaL_CheckLString</a>(<span class="keywordtype">int</span> numArg, <span class="keywordtype">size_t</span> *l)
  3880. <a name="l03851"></a>03851 {
  3881. <a name="l03852"></a>03852 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3882. <a name="l03853"></a>03853 <span class="keywordflow">return</span> luaL_checklstring(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, numArg, l);
  3883. <a name="l03854"></a>03854 }
  3884. <a name="l03855"></a><a class="code" href="classwxLuaState.html#a0b3d4e6d80903100d2cf88f04d9b76c1">03855</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classwxLuaState.html#a0b3d4e6d80903100d2cf88f04d9b76c1">wxLuaState::luaL_OptLString</a>(<span class="keywordtype">int</span> numArg, <span class="keyword">const</span> <span class="keywordtype">char</span> *def, <span class="keywordtype">size_t</span> *l)
  3885. <a name="l03856"></a>03856 {
  3886. <a name="l03857"></a>03857 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3887. <a name="l03858"></a>03858 <span class="keywordflow">return</span> luaL_optlstring(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, numArg, def, l);
  3888. <a name="l03859"></a>03859 }
  3889. <a name="l03860"></a><a class="code" href="classwxLuaState.html#a662d016fde7d6130b456f4ba8748b7c2">03860</a> lua_Number <a class="code" href="classwxLuaState.html#a662d016fde7d6130b456f4ba8748b7c2">wxLuaState::luaL_CheckNumber</a>(<span class="keywordtype">int</span> numArg)
  3890. <a name="l03861"></a>03861 {
  3891. <a name="l03862"></a>03862 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3892. <a name="l03863"></a>03863 <span class="keywordflow">return</span> luaL_checknumber(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, numArg);
  3893. <a name="l03864"></a>03864 }
  3894. <a name="l03865"></a><a class="code" href="classwxLuaState.html#a1f3cb3faf34032d56dc5a17764c52151">03865</a> lua_Number <a class="code" href="classwxLuaState.html#a1f3cb3faf34032d56dc5a17764c52151">wxLuaState::luaL_OptNumber</a>(<span class="keywordtype">int</span> nArg, lua_Number def)
  3895. <a name="l03866"></a>03866 {
  3896. <a name="l03867"></a>03867 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), def, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3897. <a name="l03868"></a>03868 <span class="keywordflow">return</span> luaL_optnumber(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, nArg, def);
  3898. <a name="l03869"></a>03869 }
  3899. <a name="l03870"></a><a class="code" href="classwxLuaState.html#a5ab45c45e5c768c335291869481a6fa2">03870</a> lua_Integer <a class="code" href="classwxLuaState.html#a5ab45c45e5c768c335291869481a6fa2">wxLuaState::luaL_CheckInteger</a>(<span class="keywordtype">int</span> numArg)
  3900. <a name="l03871"></a>03871 {
  3901. <a name="l03872"></a>03872 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3902. <a name="l03873"></a>03873 <span class="keywordflow">return</span> luaL_checkinteger(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, numArg);
  3903. <a name="l03874"></a>03874 }
  3904. <a name="l03875"></a><a class="code" href="classwxLuaState.html#aac75d6ca907f5bb43120830c625519ec">03875</a> lua_Integer <a class="code" href="classwxLuaState.html#aac75d6ca907f5bb43120830c625519ec">wxLuaState::luaL_OptInteger</a>(<span class="keywordtype">int</span> nArg, lua_Integer def)
  3905. <a name="l03876"></a>03876 {
  3906. <a name="l03877"></a>03877 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), def, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3907. <a name="l03878"></a>03878 <span class="keywordflow">return</span> luaL_optinteger(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, nArg, def);
  3908. <a name="l03879"></a>03879 }
  3909. <a name="l03880"></a>03880
  3910. <a name="l03881"></a><a class="code" href="classwxLuaState.html#a2709cd3fb202ba8960cde9c6183bf794">03881</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a2709cd3fb202ba8960cde9c6183bf794">wxLuaState::luaL_CheckStack</a>(<span class="keywordtype">int</span> sz, <span class="keyword">const</span> <span class="keywordtype">char</span> *msg)
  3911. <a name="l03882"></a>03882 {
  3912. <a name="l03883"></a>03883 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3913. <a name="l03884"></a>03884 luaL_checkstack(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, sz, msg);
  3914. <a name="l03885"></a>03885 }
  3915. <a name="l03886"></a><a class="code" href="classwxLuaState.html#ad7a0b24d2bf86c469e3d11bf29e786ba">03886</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#ad7a0b24d2bf86c469e3d11bf29e786ba">wxLuaState::luaL_CheckType</a>(<span class="keywordtype">int</span> narg, <span class="keywordtype">int</span> t)
  3916. <a name="l03887"></a>03887 {
  3917. <a name="l03888"></a>03888 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3918. <a name="l03889"></a>03889 luaL_checktype(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, narg, t);
  3919. <a name="l03890"></a>03890 }
  3920. <a name="l03891"></a><a class="code" href="classwxLuaState.html#a1616b21259181ef346d588eb99b34bda">03891</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a1616b21259181ef346d588eb99b34bda">wxLuaState::luaL_CheckAny</a>(<span class="keywordtype">int</span> narg)
  3921. <a name="l03892"></a>03892 {
  3922. <a name="l03893"></a>03893 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3923. <a name="l03894"></a>03894 luaL_checkany(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, narg);
  3924. <a name="l03895"></a>03895 }
  3925. <a name="l03896"></a>03896
  3926. <a name="l03897"></a><a class="code" href="classwxLuaState.html#a9f6327db75af7fb23923a452fb1b91fa">03897</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a9f6327db75af7fb23923a452fb1b91fa">wxLuaState::luaL_NewMetatable</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *tname)
  3927. <a name="l03898"></a>03898 {
  3928. <a name="l03899"></a>03899 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3929. <a name="l03900"></a>03900 <span class="keywordflow">return</span> luaL_newmetatable(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, tname);
  3930. <a name="l03901"></a>03901 }
  3931. <a name="l03902"></a><a class="code" href="classwxLuaState.html#a65418940c8e0dbae47604cc8dafa3bce">03902</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a65418940c8e0dbae47604cc8dafa3bce">wxLuaState::luaL_GetMetatable</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *tname)
  3932. <a name="l03903"></a>03903 {
  3933. <a name="l03904"></a>03904 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3934. <a name="l03905"></a>03905 luaL_getmetatable(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, tname);
  3935. <a name="l03906"></a>03906 }
  3936. <a name="l03907"></a><a class="code" href="classwxLuaState.html#a760ce18ecc6edcddbb80edcc1d09b21a">03907</a> <span class="keywordtype">void</span>* <a class="code" href="classwxLuaState.html#a760ce18ecc6edcddbb80edcc1d09b21a">wxLuaState::luaL_CheckUdata</a>(<span class="keywordtype">int</span> ud, <span class="keyword">const</span> <span class="keywordtype">char</span> *tname)
  3937. <a name="l03908"></a>03908 {
  3938. <a name="l03909"></a>03909 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3939. <a name="l03910"></a>03910 <span class="keywordflow">return</span> luaL_checkudata(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, ud, tname);
  3940. <a name="l03911"></a>03911 }
  3941. <a name="l03912"></a>03912
  3942. <a name="l03913"></a><a class="code" href="classwxLuaState.html#aaf03a470f877f0f9bdab67630ad1e362">03913</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#aaf03a470f877f0f9bdab67630ad1e362">wxLuaState::luaL_Where</a>(<span class="keywordtype">int</span> lvl)
  3943. <a name="l03914"></a>03914 {
  3944. <a name="l03915"></a>03915 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3945. <a name="l03916"></a>03916 luaL_where(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, lvl);
  3946. <a name="l03917"></a>03917 }
  3947. <a name="l03918"></a><a class="code" href="classwxLuaState.html#abdfa7efee0345742d13545ecddb71512">03918</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#abdfa7efee0345742d13545ecddb71512">wxLuaState::luaL_Error</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fmt, ...)
  3948. <a name="l03919"></a>03919 {
  3949. <a name="l03920"></a>03920 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3950. <a name="l03921"></a>03921 <span class="keywordflow">return</span> luaL_error(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, fmt);
  3951. <a name="l03922"></a>03922 }
  3952. <a name="l03923"></a>03923
  3953. <a name="l03924"></a><a class="code" href="classwxLuaState.html#acb5c92ac8b8644f396f8201011d988c7">03924</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#acb5c92ac8b8644f396f8201011d988c7">wxLuaState::luaL_CheckOption</a>(<span class="keywordtype">int</span> narg, <span class="keyword">const</span> <span class="keywordtype">char</span> *def, <span class="keyword">const</span> <span class="keywordtype">char</span> *<span class="keyword">const</span> lst[])
  3954. <a name="l03925"></a>03925 {
  3955. <a name="l03926"></a>03926 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3956. <a name="l03927"></a>03927 <span class="keywordflow">return</span> luaL_checkoption(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, narg, def, lst);
  3957. <a name="l03928"></a>03928 }
  3958. <a name="l03929"></a>03929
  3959. <a name="l03930"></a><a class="code" href="classwxLuaState.html#acb344a650ab7a2b8a2abdfd7a10bc854">03930</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#acb344a650ab7a2b8a2abdfd7a10bc854">wxLuaState::luaL_Ref</a>(<span class="keywordtype">int</span> t)
  3960. <a name="l03931"></a>03931 {
  3961. <a name="l03932"></a>03932 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3962. <a name="l03933"></a>03933 <span class="keywordflow">return</span> luaL_ref(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, t);
  3963. <a name="l03934"></a>03934 }
  3964. <a name="l03935"></a><a class="code" href="classwxLuaState.html#aadeb3fe4e8d61291ee48e14e61a9a15d">03935</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#aadeb3fe4e8d61291ee48e14e61a9a15d">wxLuaState::luaL_Unref</a>(<span class="keywordtype">int</span> t, <span class="keywordtype">int</span> ref)
  3965. <a name="l03936"></a>03936 {
  3966. <a name="l03937"></a>03937 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3967. <a name="l03938"></a>03938 luaL_unref(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, t, ref);
  3968. <a name="l03939"></a>03939 }
  3969. <a name="l03940"></a>03940
  3970. <a name="l03941"></a><a class="code" href="classwxLuaState.html#a2bb08c8b0bd5ab2640bd6a14d9cb1744">03941</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a2bb08c8b0bd5ab2640bd6a14d9cb1744">wxLuaState::luaL_LoadFile</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *filename)
  3971. <a name="l03942"></a>03942 {
  3972. <a name="l03943"></a>03943 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3973. <a name="l03944"></a>03944 <span class="keywordflow">return</span> luaL_loadfile(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, filename);
  3974. <a name="l03945"></a>03945 }
  3975. <a name="l03946"></a><a class="code" href="classwxLuaState.html#aa6a8a233ffc3bb740456d655b4de9f5c">03946</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#aa6a8a233ffc3bb740456d655b4de9f5c">wxLuaState::luaL_LoadBuffer</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *buff, <span class="keywordtype">size_t</span> sz, <span class="keyword">const</span> <span class="keywordtype">char</span> *name)
  3976. <a name="l03947"></a>03947 {
  3977. <a name="l03948"></a>03948 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3978. <a name="l03949"></a>03949 <span class="keywordflow">return</span> luaL_loadbuffer(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, buff, sz, name);
  3979. <a name="l03950"></a>03950 }
  3980. <a name="l03951"></a><a class="code" href="classwxLuaState.html#a8527fcb3fedd42071e6572e44aa9d821">03951</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a8527fcb3fedd42071e6572e44aa9d821">wxLuaState::luaL_LoadString</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *s)
  3981. <a name="l03952"></a>03952 {
  3982. <a name="l03953"></a>03953 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3983. <a name="l03954"></a>03954 <span class="keywordflow">return</span> luaL_loadstring(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, s);
  3984. <a name="l03955"></a>03955 }
  3985. <a name="l03956"></a>03956
  3986. <a name="l03957"></a><a class="code" href="classwxLuaState.html#a68ba21026b669b6a1e557d3e8dfe6ff7">03957</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a68ba21026b669b6a1e557d3e8dfe6ff7">wxLuaState::luaL_ArgCheck</a>(<span class="keywordtype">bool</span> condition, <span class="keywordtype">int</span> numarg, <span class="keyword">const</span> <span class="keywordtype">char</span>* extramsg)
  3987. <a name="l03958"></a>03958 {
  3988. <a name="l03959"></a>03959 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3989. <a name="l03960"></a>03960 luaL_argcheck(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, condition, numarg, extramsg);
  3990. <a name="l03961"></a>03961 }
  3991. <a name="l03962"></a><a class="code" href="classwxLuaState.html#a3a6cab281ee0f334ed2e39d7f0d8aa2b">03962</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classwxLuaState.html#a3a6cab281ee0f334ed2e39d7f0d8aa2b">wxLuaState::luaL_CheckString</a>(<span class="keywordtype">int</span> numArg)
  3992. <a name="l03963"></a>03963 {
  3993. <a name="l03964"></a>03964 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3994. <a name="l03965"></a>03965 <span class="keywordflow">return</span> luaL_checkstring(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, numArg);
  3995. <a name="l03966"></a>03966 }
  3996. <a name="l03967"></a><a class="code" href="classwxLuaState.html#acf9194fe9a511a5e0a8b4183ca5a650e">03967</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classwxLuaState.html#acf9194fe9a511a5e0a8b4183ca5a650e">wxLuaState::luaL_OptString</a>(<span class="keywordtype">int</span> numArg, <span class="keyword">const</span> <span class="keywordtype">char</span>* def)
  3997. <a name="l03968"></a>03968 {
  3998. <a name="l03969"></a>03969 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  3999. <a name="l03970"></a>03970 <span class="keywordflow">return</span> luaL_optstring(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, numArg, def);
  4000. <a name="l03971"></a>03971 }
  4001. <a name="l03972"></a><a class="code" href="classwxLuaState.html#a90affb184de7cf022e1e56dacde75070">03972</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a90affb184de7cf022e1e56dacde75070">wxLuaState::luaL_CheckInt</a>(<span class="keywordtype">int</span> numArg)
  4002. <a name="l03973"></a>03973 {
  4003. <a name="l03974"></a>03974 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  4004. <a name="l03975"></a>03975 <span class="keywordflow">return</span> (<span class="keywordtype">int</span>)luaL_checkint(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, numArg);
  4005. <a name="l03976"></a>03976 }
  4006. <a name="l03977"></a><a class="code" href="classwxLuaState.html#a66f402fe349e75d6c33b641aec7190a5">03977</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaState.html#a66f402fe349e75d6c33b641aec7190a5">wxLuaState::luaL_OptInt</a>(<span class="keywordtype">int</span> numArg, <span class="keywordtype">int</span> def)
  4007. <a name="l03978"></a>03978 {
  4008. <a name="l03979"></a>03979 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  4009. <a name="l03980"></a>03980 <span class="keywordflow">return</span> (<span class="keywordtype">int</span>)luaL_optint(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, numArg, def);
  4010. <a name="l03981"></a>03981 }
  4011. <a name="l03982"></a><a class="code" href="classwxLuaState.html#ab809df8935f97f9b9b6f8897f941ad23">03982</a> <span class="keywordtype">long</span> <a class="code" href="classwxLuaState.html#ab809df8935f97f9b9b6f8897f941ad23">wxLuaState::luaL_CheckLong</a>(<span class="keywordtype">int</span> numArg)
  4012. <a name="l03983"></a>03983 {
  4013. <a name="l03984"></a>03984 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  4014. <a name="l03985"></a>03985 <span class="keywordflow">return</span> (<span class="keywordtype">long</span>)luaL_checklong(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, numArg);
  4015. <a name="l03986"></a>03986 }
  4016. <a name="l03987"></a><a class="code" href="classwxLuaState.html#adf4a976db8f61da60b356b9fa742d3b2">03987</a> <span class="keywordtype">long</span> <a class="code" href="classwxLuaState.html#adf4a976db8f61da60b356b9fa742d3b2">wxLuaState::luaL_OptLong</a>(<span class="keywordtype">int</span> numArg, <span class="keywordtype">int</span> def)
  4017. <a name="l03988"></a>03988 {
  4018. <a name="l03989"></a>03989 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  4019. <a name="l03990"></a>03990 <span class="keywordflow">return</span> (<span class="keywordtype">long</span>)luaL_optlong(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, numArg, def);
  4020. <a name="l03991"></a>03991 }
  4021. <a name="l03992"></a>03992
  4022. <a name="l03993"></a>03993 <span class="comment">// ----------------------------------------------------------------------------</span>
  4023. <a name="l03994"></a>03994 <span class="comment">// others</span>
  4024. <a name="l03995"></a>03995
  4025. <a name="l03996"></a><a class="code" href="classwxLuaState.html#af310e7133d2398e7c42533da701b89ab">03996</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#af310e7133d2398e7c42533da701b89ab">wxLuaState::GetGlobals</a>()
  4026. <a name="l03997"></a>03997 {
  4027. <a name="l03998"></a>03998 wxCHECK_RET(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  4028. <a name="l03999"></a>03999 lua_pushvalue(<a class="code" href="wxlstate_8cpp.html#ab721906229db5927be08fa63c43cd326">M_WXLSTATEDATA</a>-&gt;m_lua_State, LUA_GLOBALSINDEX);
  4029. <a name="l04000"></a>04000 }
  4030. <a name="l04001"></a>04001
  4031. <a name="l04002"></a><a class="code" href="wxlstate_8cpp.html#aab77fd813aae939f7c76407566489544">04002</a> <span class="preprocessor">#define LUA_PATH &quot;LUA_PATH&quot;</span>
  4032. <a name="l04003"></a>04003 <span class="preprocessor"></span>
  4033. <a name="l04004"></a>04004 <span class="comment">// get LUA_PATH</span>
  4034. <a name="l04005"></a><a class="code" href="classwxLuaState.html#aaffc33ba48925a879073935cbd26b0ed">04005</a> wxString <a class="code" href="classwxLuaState.html#aaffc33ba48925a879073935cbd26b0ed">wxLuaState::GetLuaPath</a>()
  4035. <a name="l04006"></a>04006 {
  4036. <a name="l04007"></a>04007 wxCHECK_MSG(<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  4037. <a name="l04008"></a>04008 <a class="code" href="classwxLuaState.html#a3854acdfe8cf1a0d96e1d82ce9f181d4">lua_GetGlobal</a>(<a class="code" href="wxlstate_8cpp.html#aab77fd813aae939f7c76407566489544">LUA_PATH</a>);
  4038. <a name="l04009"></a>04009 wxString path = <a class="code" href="classwxLuaState.html#aa1e2a352d7eea7def33de09573f3f2b5">lua_TowxString</a>(-1);
  4039. <a name="l04010"></a>04010 <a class="code" href="classwxLuaState.html#a2efa05a8ce69d8344c5ea14b4fe02bf0">lua_Pop</a>(1);
  4040. <a name="l04011"></a>04011
  4041. <a name="l04012"></a>04012 <span class="keywordflow">return</span> path;
  4042. <a name="l04013"></a>04013 }
  4043. <a name="l04014"></a>04014
  4044. <a name="l04015"></a>04015 <span class="comment">// add path list to LUA_PATH</span>
  4045. <a name="l04016"></a><a class="code" href="classwxLuaState.html#a3ce3a4631d2d1c0b47ec0c3089a81b4b">04016</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a3ce3a4631d2d1c0b47ec0c3089a81b4b">wxLuaState::AddLuaPath</a>(<span class="keyword">const</span> wxPathList&amp; pathlist)
  4046. <a name="l04017"></a>04017 {
  4047. <a name="l04018"></a>04018 <span class="keywordtype">size_t</span> i, count = pathlist.GetCount();
  4048. <a name="l04019"></a>04019 <span class="keywordflow">for</span> (i = 0; i &lt; count; ++i)
  4049. <a name="l04020"></a>04020 {
  4050. <a name="l04021"></a>04021 wxFileName fname(pathlist[i]);
  4051. <a name="l04022"></a>04022 <a class="code" href="classwxLuaState.html#a3ce3a4631d2d1c0b47ec0c3089a81b4b">AddLuaPath</a>(fname);
  4052. <a name="l04023"></a>04023 }
  4053. <a name="l04024"></a>04024 }
  4054. <a name="l04025"></a>04025
  4055. <a name="l04026"></a>04026 <span class="comment">// add filename path to LUA_PATH</span>
  4056. <a name="l04027"></a><a class="code" href="classwxLuaState.html#a6c475ec5dd7ca06ef0563008dd9170ac">04027</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaState.html#a3ce3a4631d2d1c0b47ec0c3089a81b4b">wxLuaState::AddLuaPath</a>(<span class="keyword">const</span> wxFileName&amp; filename)
  4057. <a name="l04028"></a>04028 {
  4058. <a name="l04029"></a>04029 wxFileName fname = filename;
  4059. <a name="l04030"></a>04030 fname.SetName(wxT(<span class="stringliteral">&quot;?&quot;</span>));
  4060. <a name="l04031"></a>04031 fname.SetExt(wxT(<span class="stringliteral">&quot;lua&quot;</span>));
  4061. <a name="l04032"></a>04032
  4062. <a name="l04033"></a>04033 wxString path = fname.GetFullPath();
  4063. <a name="l04034"></a>04034 wxString luapath = <a class="code" href="classwxLuaState.html#aaffc33ba48925a879073935cbd26b0ed">GetLuaPath</a>();
  4064. <a name="l04035"></a>04035
  4065. <a name="l04036"></a>04036 <span class="comment">// check if path</span>
  4066. <a name="l04037"></a>04037 wxStringTokenizer tkz(luapath, wxT(<span class="stringliteral">&quot;;&quot;</span>));
  4067. <a name="l04038"></a>04038 <span class="keywordflow">while</span> (tkz.HasMoreTokens())
  4068. <a name="l04039"></a>04039 {
  4069. <a name="l04040"></a>04040 wxString token = tkz.GetNextToken();
  4070. <a name="l04041"></a>04041
  4071. <a name="l04042"></a>04042 <span class="keywordflow">if</span> ((token == path) || (!wxFileName::IsCaseSensitive() &amp;&amp; token.CmpNoCase(path) == 0))
  4072. <a name="l04043"></a>04043 <span class="keywordflow">return</span>;
  4073. <a name="l04044"></a>04044 }
  4074. <a name="l04045"></a>04045
  4075. <a name="l04046"></a>04046 <span class="comment">// append separator</span>
  4076. <a name="l04047"></a>04047 <span class="keywordflow">if</span> (!luapath.IsEmpty() &amp;&amp; (luapath.Last() != wxT(<span class="charliteral">&#39;;&#39;</span>)))
  4077. <a name="l04048"></a>04048 luapath += wxT(<span class="charliteral">&#39;;&#39;</span>);
  4078. <a name="l04049"></a>04049
  4079. <a name="l04050"></a>04050 <span class="comment">// append path</span>
  4080. <a name="l04051"></a>04051 luapath += path + wxT(<span class="charliteral">&#39;;&#39;</span>);
  4081. <a name="l04052"></a>04052
  4082. <a name="l04053"></a>04053 <a class="code" href="classwxLuaState.html#a1b7e4cbbc4cf03c493891a63d1036637">lua_PushString</a>(luapath);
  4083. <a name="l04054"></a>04054 <a class="code" href="classwxLuaState.html#acbec13da5eea296b2a32180e96d27653">lua_SetGlobal</a>(<a class="code" href="wxlstate_8cpp.html#aab77fd813aae939f7c76407566489544">LUA_PATH</a>);
  4084. <a name="l04055"></a>04055 }
  4085. <a name="l04056"></a>04056
  4086. <a name="l04057"></a>04057 <span class="comment">//-----------------------------------------------------------------------------</span>
  4087. <a name="l04058"></a>04058 <span class="comment">// wxLuaEvent</span>
  4088. <a name="l04059"></a>04059 <span class="comment">//-----------------------------------------------------------------------------</span>
  4089. <a name="l04060"></a>04060
  4090. <a name="l04061"></a>04061 DEFINE_LOCAL_EVENT_TYPE(wxEVT_LUA_CREATION)
  4091. <a name="l04062"></a>04062 DEFINE_LOCAL_EVENT_TYPE(wxEVT_LUA_PRINT)
  4092. <a name="l04063"></a>04063 DEFINE_LOCAL_EVENT_TYPE(wxEVT_LUA_ERROR)
  4093. <a name="l04064"></a>04064 DEFINE_LOCAL_EVENT_TYPE(wxEVT_LUA_DEBUG_HOOK)
  4094. <a name="l04065"></a>04065 <span class="comment">//DEFINE_LOCAL_EVENT_TYPE(wxEVT_LUA_INIT)</span>
  4095. <a name="l04066"></a>04066 <span class="comment">//DEFINE_LOCAL_EVENT_TYPE(wxEVT_LUA_DEBUGGERATTACHED)</span>
  4096. <a name="l04067"></a>04067
  4097. <a name="l04068"></a><a class="code" href="classwxLuaEvent.html#a524629e84059e8903216854175b07a42">04068</a> <a class="code" href="classwxLuaEvent.html">wxLuaEvent</a>::<a class="code" href="classwxLuaEvent.html">wxLuaEvent</a>(wxEventType commandType, wxWindowID <span class="keywordtype">id</span>, const <a class="code" href="classwxLuaState.html">wxLuaState</a>&amp; wxlState)
  4098. <a name="l04069"></a>04069 :wxNotifyEvent(commandType, <span class="keywordtype">id</span>), m_wxlState(wxlState),
  4099. <a name="l04070"></a>04070 m_debug_hook_break(false),
  4100. <a name="l04071"></a>04071 m_lua_Debug(NULL)
  4101. <a name="l04072"></a>04072 {
  4102. <a name="l04073"></a>04073 }
  4103. <a name="l04074"></a>04074
  4104. <a name="l04075"></a><a class="code" href="classwxLuaEvent.html#a0d40a00a7bbca6c2712e07d7e63a16a3">04075</a> <a class="code" href="classwxLuaEvent.html#a524629e84059e8903216854175b07a42">wxLuaEvent::wxLuaEvent</a>( <span class="keyword">const</span> <a class="code" href="classwxLuaEvent.html">wxLuaEvent</a> &amp;event )
  4105. <a name="l04076"></a>04076 :wxNotifyEvent(event), m_wxlState(event.m_wxlState),
  4106. <a name="l04077"></a>04077 m_debug_hook_break(event.m_debug_hook_break),
  4107. <a name="l04078"></a>04078 m_lua_Debug(event.m_lua_Debug)
  4108. <a name="l04079"></a>04079 {
  4109. <a name="l04080"></a>04080 }
  4110. <a name="l04081"></a>04081
  4111. <a name="l04082"></a>04082
  4112. <a name="l04083"></a>04083 <span class="comment">//-----------------------------------------------------------------------------</span>
  4113. <a name="l04084"></a>04084 <span class="comment">// bitlib release 25 - Bitwise operations library</span>
  4114. <a name="l04085"></a>04085 <span class="comment">// by Reuben Thomas &lt;rrt@sc3d.org&gt;</span>
  4115. <a name="l04086"></a>04086 <span class="comment">// http://luaforge.net/projects/bitlib</span>
  4116. <a name="l04087"></a>04087 <span class="comment">// copyright Reuben Thomas 2000-2008, and is released under the MIT license</span>
  4117. <a name="l04088"></a>04088 <span class="comment">//-----------------------------------------------------------------------------</span>
  4118. <a name="l04089"></a>04089
  4119. <a name="l04090"></a>04090 <span class="comment">// This is the code copied directly from lbitlib.c and ever so slightly modified</span>
  4120. <a name="l04091"></a>04091 <span class="comment">// to allow it to work here.</span>
  4121. <a name="l04092"></a>04092
  4122. <a name="l04093"></a>04093 <span class="comment">/* Bitwise operations library */</span>
  4123. <a name="l04094"></a>04094 <span class="comment">/* (c) Reuben Thomas 2000-2008 */</span>
  4124. <a name="l04095"></a>04095 <span class="comment">/* See README for license */</span>
  4125. <a name="l04096"></a>04096
  4126. <a name="l04097"></a>04097 <span class="comment">//#include &quot;config.h&quot;</span>
  4127. <a name="l04098"></a>04098
  4128. <a name="l04099"></a>04099 <span class="comment">//#include &lt;lua.h&gt;</span>
  4129. <a name="l04100"></a>04100 <span class="comment">//#include &lt;lauxlib.h&gt;</span>
  4130. <a name="l04101"></a>04101 <span class="preprocessor">#include &lt;limits.h&gt;</span>
  4131. <a name="l04102"></a>04102
  4132. <a name="l04103"></a>04103 <span class="comment">//#include &quot;bit_limits.h&quot;</span>
  4133. <a name="l04104"></a><a class="code" href="wxlstate_8cpp.html#a5730e57fbbc45cda502213067171f1fd">04104</a> <span class="preprocessor">#define BITLIB_FLOAT_BITS 53</span>
  4134. <a name="l04105"></a><a class="code" href="wxlstate_8cpp.html#a7a951f3ad247ed862bc9a7eb46cc0606">04105</a> <span class="preprocessor"></span><span class="preprocessor">#define BITLIB_FLOAT_MAX 0xfffffffffffffL</span>
  4135. <a name="l04106"></a><a class="code" href="wxlstate_8cpp.html#a730b29378c3c8af4fae04831da1fe2e9">04106</a> <span class="preprocessor"></span><span class="preprocessor">#define BITLIB_FLOAT_MIN (-0x10000000000000L)</span>
  4136. <a name="l04107"></a>04107 <span class="preprocessor"></span><span class="preprocessor">#if defined(__VISUALC__)</span>
  4137. <a name="l04108"></a>04108 <span class="preprocessor"></span><span class="preprocessor"> #define BITLIB_FLOAT_UMAX 0x1fffffffffffffUL</span>
  4138. <a name="l04109"></a>04109 <span class="preprocessor"></span><span class="preprocessor">#else</span>
  4139. <a name="l04110"></a><a class="code" href="wxlstate_8cpp.html#a7d1bf2eefdd834253b37d810b2b7b747">04110</a> <span class="preprocessor"></span><span class="preprocessor"> #define BITLIB_FLOAT_UMAX 0x1fffffffffffffULL</span>
  4140. <a name="l04111"></a>04111 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
  4141. <a name="l04112"></a>04112 <span class="preprocessor"></span>
  4142. <a name="l04113"></a>04113 <span class="comment">/* FIXME: Assume lua_Integer is ptrdiff_t */</span>
  4143. <a name="l04114"></a><a class="code" href="wxlstate_8cpp.html#a7e1996ddba6c3c73bf6895458a79bf0b">04114</a> <span class="preprocessor">#define LUA_INTEGER_MAX PTRDIFF_MAX</span>
  4144. <a name="l04115"></a><a class="code" href="wxlstate_8cpp.html#ab68ec4a1166fcb94018e3a300474cde5">04115</a> <span class="preprocessor"></span><span class="preprocessor">#define LUA_INTEGER_MIN PTRDIFF_MIN</span>
  4145. <a name="l04116"></a>04116 <span class="preprocessor"></span>
  4146. <a name="l04117"></a>04117 <span class="preprocessor">#ifndef SIZE_MAX</span>
  4147. <a name="l04118"></a><a class="code" href="wxlstate_8cpp.html#a3c75bb398badb69c7577b21486f9963f">04118</a> <span class="preprocessor"></span><span class="preprocessor">#define SIZE_MAX ((size_t)-1)</span>
  4148. <a name="l04119"></a>04119 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
  4149. <a name="l04120"></a>04120 <span class="preprocessor"></span>
  4150. <a name="l04121"></a>04121 <span class="comment">/* FIXME: Assume size_t is an unsigned lua_Integer */</span>
  4151. <a name="l04122"></a><a class="code" href="wxlstate_8cpp.html#a1fb560fe12f72d80b60ea38abcd801fd">04122</a> <span class="keyword">typedef</span> <span class="keywordtype">size_t</span> <a class="code" href="wxlstate_8cpp.html#a1fb560fe12f72d80b60ea38abcd801fd">lua_UInteger</a>;
  4152. <a name="l04123"></a><a class="code" href="wxlstate_8cpp.html#a1748905c75234ae90a7eb1dc2b3b4c9e">04123</a> <span class="preprocessor">#define LUA_UINTEGER_MAX SIZE_MAX</span>
  4153. <a name="l04124"></a>04124 <span class="preprocessor"></span>
  4154. <a name="l04125"></a>04125
  4155. <a name="l04126"></a>04126 <span class="comment">/* Bit type size and limits */</span>
  4156. <a name="l04127"></a>04127
  4157. <a name="l04128"></a><a class="code" href="wxlstate_8cpp.html#a28b65f13723b9e7a58ecb4a5db958c90">04128</a> <span class="preprocessor">#define BIT_BITS \</span>
  4158. <a name="l04129"></a>04129 <span class="preprocessor"> (CHAR_BIT * sizeof(lua_Integer) &gt; BITLIB_FLOAT_BITS ? \</span>
  4159. <a name="l04130"></a>04130 <span class="preprocessor"> BITLIB_FLOAT_BITS : (CHAR_BIT * sizeof(lua_Integer)))</span>
  4160. <a name="l04131"></a>04131 <span class="preprocessor"></span>
  4161. <a name="l04132"></a>04132 <span class="comment">/* This code may give warnings if BITLIB_FLOAT_* are too big to fit in</span>
  4162. <a name="l04133"></a>04133 <span class="comment"> long, but that doesn&#39;t matter since in that case they won&#39;t be</span>
  4163. <a name="l04134"></a>04134 <span class="comment"> used. */</span>
  4164. <a name="l04135"></a><a class="code" href="wxlstate_8cpp.html#ad0de58215f6d6b460271e0a47ee375a8">04135</a> <span class="preprocessor">#define BIT_MAX \</span>
  4165. <a name="l04136"></a>04136 <span class="preprocessor"> (CHAR_BIT * sizeof(lua_Integer) &gt; BITLIB_FLOAT_BITS ? BITLIB_FLOAT_MAX : LUA_INTEGER_MAX)</span>
  4166. <a name="l04137"></a>04137 <span class="preprocessor"></span>
  4167. <a name="l04138"></a><a class="code" href="wxlstate_8cpp.html#a114ee624b0ba2810251617d531ac4fd6">04138</a> <span class="preprocessor">#define BIT_MIN \</span>
  4168. <a name="l04139"></a>04139 <span class="preprocessor"> (CHAR_BIT * sizeof(lua_Integer) &gt; BITLIB_FLOAT_BITS ? BITLIB_FLOAT_MIN : LUA_INTEGER_MIN)</span>
  4169. <a name="l04140"></a>04140 <span class="preprocessor"></span>
  4170. <a name="l04141"></a><a class="code" href="wxlstate_8cpp.html#af76b16a0b6e4dcd102f5665ee0c950a4">04141</a> <span class="preprocessor">#define BIT_UMAX \</span>
  4171. <a name="l04142"></a>04142 <span class="preprocessor"> (CHAR_BIT * sizeof(lua_Integer) &gt; BITLIB_FLOAT_BITS ? BITLIB_FLOAT_UMAX : LUA_UINTEGER_MAX)</span>
  4172. <a name="l04143"></a>04143 <span class="preprocessor"></span>
  4173. <a name="l04144"></a>04144
  4174. <a name="l04145"></a><a class="code" href="wxlstate_8cpp.html#a57601c96ef87de18e0c9aab425f802f0">04145</a> <span class="preprocessor">#define BUILTIN_CAST</span>
  4175. <a name="l04146"></a>04146 <span class="preprocessor"></span>
  4176. <a name="l04147"></a>04147 <span class="comment">/* Define TOBIT to get a bit value */</span>
  4177. <a name="l04148"></a>04148 <span class="preprocessor">#ifdef BUILTIN_CAST</span>
  4178. <a name="l04149"></a><a class="code" href="wxlstate_8cpp.html#a0d02dfd743245148442b4954d9a66383">04149</a> <span class="preprocessor"></span><span class="preprocessor">#define TOBIT(L, n, res) \</span>
  4179. <a name="l04150"></a>04150 <span class="preprocessor"> ((void)(res), luaL_checkinteger((L), (n)))</span>
  4180. <a name="l04151"></a>04151 <span class="preprocessor"></span><span class="preprocessor">#else</span>
  4181. <a name="l04152"></a>04152 <span class="preprocessor"></span><span class="preprocessor">#include &lt;stdint.h&gt;</span>
  4182. <a name="l04153"></a>04153 <span class="preprocessor">#include &lt;math.h&gt;</span>
  4183. <a name="l04154"></a>04154
  4184. <a name="l04155"></a>04155 <span class="comment">/* FIXME: Assume lua_Number fits in a double (use of fmod). */</span>
  4185. <a name="l04156"></a>04156 <span class="preprocessor">#define TOBIT(L, n, res) \</span>
  4186. <a name="l04157"></a>04157 <span class="preprocessor"> ((lua_Integer)(((res) = fmod(luaL_checknumber(L, (n)), (double)BIT_UMAX + 1.0)), \</span>
  4187. <a name="l04158"></a>04158 <span class="preprocessor"> (res) &gt; BIT_MAX ? ((res) -= (double)BIT_UMAX, (res) -= 1) : \</span>
  4188. <a name="l04159"></a>04159 <span class="preprocessor"> ((res) &lt; BIT_MIN ? ((res) += (double)BIT_UMAX, (res) += 1) : (res))))</span>
  4189. <a name="l04160"></a>04160 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
  4190. <a name="l04161"></a>04161 <span class="preprocessor"></span>
  4191. <a name="l04162"></a>04162
  4192. <a name="l04163"></a><a class="code" href="wxlstate_8cpp.html#a2a078799cbdfaea63e2645f9d6be9636">04163</a> <span class="preprocessor">#define BIT_TRUNCATE(i) \</span>
  4193. <a name="l04164"></a>04164 <span class="preprocessor"> ((i) &amp; BIT_UMAX)</span>
  4194. <a name="l04165"></a>04165 <span class="preprocessor"></span>
  4195. <a name="l04166"></a>04166 <span class="comment">/* Operations</span>
  4196. <a name="l04167"></a>04167 <span class="comment"></span>
  4197. <a name="l04168"></a>04168 <span class="comment"> The macros MONADIC and VARIADIC only deal with bitwise operations.</span>
  4198. <a name="l04169"></a>04169 <span class="comment"></span>
  4199. <a name="l04170"></a>04170 <span class="comment"> LOGICAL_SHIFT truncates its left-hand operand before shifting so</span>
  4200. <a name="l04171"></a>04171 <span class="comment"> that any extra bits at the most-significant end are not shifted</span>
  4201. <a name="l04172"></a>04172 <span class="comment"> into the result.</span>
  4202. <a name="l04173"></a>04173 <span class="comment"></span>
  4203. <a name="l04174"></a>04174 <span class="comment"> ARITHMETIC_SHIFT does not truncate its left-hand operand, so that</span>
  4204. <a name="l04175"></a>04175 <span class="comment"> the sign bits are not removed and right shift work properly.</span>
  4205. <a name="l04176"></a>04176 <span class="comment"> */</span>
  4206. <a name="l04177"></a>04177
  4207. <a name="l04178"></a><a class="code" href="wxlstate_8cpp.html#a62a707b3327b9ba94b526a112b2dcb2d">04178</a> <span class="preprocessor">#define MONADIC(name, op) \</span>
  4208. <a name="l04179"></a>04179 <span class="preprocessor"> static int bit_ ## name(lua_State *L) { \</span>
  4209. <a name="l04180"></a>04180 <span class="preprocessor"> lua_Number f; \</span>
  4210. <a name="l04181"></a>04181 <span class="preprocessor"> lua_pushinteger(L, BIT_TRUNCATE(op TOBIT(L, 1, f))); \</span>
  4211. <a name="l04182"></a>04182 <span class="preprocessor"> return 1; \</span>
  4212. <a name="l04183"></a>04183 <span class="preprocessor"> }</span>
  4213. <a name="l04184"></a>04184 <span class="preprocessor"></span>
  4214. <a name="l04185"></a><a class="code" href="wxlstate_8cpp.html#ac82bd290f3c6b0cbd06e20a6d9291c80">04185</a> <span class="preprocessor">#define VARIADIC(name, op) \</span>
  4215. <a name="l04186"></a>04186 <span class="preprocessor"> static int bit_ ## name(lua_State *L) { \</span>
  4216. <a name="l04187"></a>04187 <span class="preprocessor"> lua_Number f; \</span>
  4217. <a name="l04188"></a>04188 <span class="preprocessor"> int n = lua_gettop(L), i; \</span>
  4218. <a name="l04189"></a>04189 <span class="preprocessor"> lua_Integer w = TOBIT(L, 1, f); \</span>
  4219. <a name="l04190"></a>04190 <span class="preprocessor"> for (i = 2; i &lt;= n; i++) \</span>
  4220. <a name="l04191"></a>04191 <span class="preprocessor"> w op TOBIT(L, i, f); \</span>
  4221. <a name="l04192"></a>04192 <span class="preprocessor"> lua_pushinteger(L, BIT_TRUNCATE(w)); \</span>
  4222. <a name="l04193"></a>04193 <span class="preprocessor"> return 1; \</span>
  4223. <a name="l04194"></a>04194 <span class="preprocessor"> }</span>
  4224. <a name="l04195"></a>04195 <span class="preprocessor"></span>
  4225. <a name="l04196"></a><a class="code" href="wxlstate_8cpp.html#a66ee3344af015fa6f5d7ad30f1dc02ce">04196</a> <span class="preprocessor">#define LOGICAL_SHIFT(name, op) \</span>
  4226. <a name="l04197"></a>04197 <span class="preprocessor"> static int bit_ ## name(lua_State *L) { \</span>
  4227. <a name="l04198"></a>04198 <span class="preprocessor"> lua_Number f; \</span>
  4228. <a name="l04199"></a>04199 <span class="preprocessor"> lua_pushinteger(L, BIT_TRUNCATE(BIT_TRUNCATE((lua_UInteger)TOBIT(L, 1, f)) op \</span>
  4229. <a name="l04200"></a>04200 <span class="preprocessor"> (unsigned)luaL_checknumber(L, 2))); \</span>
  4230. <a name="l04201"></a>04201 <span class="preprocessor"> return 1; \</span>
  4231. <a name="l04202"></a>04202 <span class="preprocessor"> }</span>
  4232. <a name="l04203"></a>04203 <span class="preprocessor"></span>
  4233. <a name="l04204"></a><a class="code" href="wxlstate_8cpp.html#a8883b0c703b9975e42420aa9b56ae15e">04204</a> <span class="preprocessor">#define ARITHMETIC_SHIFT(name, op) \</span>
  4234. <a name="l04205"></a>04205 <span class="preprocessor"> static int bit_ ## name(lua_State *L) { \</span>
  4235. <a name="l04206"></a>04206 <span class="preprocessor"> lua_Number f; \</span>
  4236. <a name="l04207"></a>04207 <span class="preprocessor"> lua_pushinteger(L, BIT_TRUNCATE((lua_Integer)TOBIT(L, 1, f) op \</span>
  4237. <a name="l04208"></a>04208 <span class="preprocessor"> (unsigned)luaL_checknumber(L, 2))); \</span>
  4238. <a name="l04209"></a>04209 <span class="preprocessor"> return 1; \</span>
  4239. <a name="l04210"></a>04210 <span class="preprocessor"> }</span>
  4240. <a name="l04211"></a>04211 <span class="preprocessor"></span>
  4241. <a name="l04212"></a><a class="code" href="wxlstate_8cpp.html#a1f5ed26c3de71289224dd1774278fe4a">04212</a> <a class="code" href="wxlstate_8cpp.html#a62a707b3327b9ba94b526a112b2dcb2d">MONADIC</a>(cast, +)
  4242. <a name="l04213"></a><a class="code" href="wxlstate_8cpp.html#a13441e42b41dba8a11c859547313d78e">04213</a> <a class="code" href="wxlstate_8cpp.html#a62a707b3327b9ba94b526a112b2dcb2d">MONADIC</a>(bnot, ~)
  4243. <a name="l04214"></a><a class="code" href="wxlstate_8cpp.html#a37e060c9c93d3516f0fa8517bf002dec">04214</a> <a class="code" href="wxlstate_8cpp.html#ac82bd290f3c6b0cbd06e20a6d9291c80">VARIADIC</a>(band, &amp;=)
  4244. <a name="l04215"></a><a class="code" href="wxlstate_8cpp.html#a5a775bc9179bd2121acf0237e4f85cdc">04215</a> <a class="code" href="wxlstate_8cpp.html#ac82bd290f3c6b0cbd06e20a6d9291c80">VARIADIC</a>(bor, |=)
  4245. <a name="l04216"></a><a class="code" href="wxlstate_8cpp.html#a83874141a436fe18d6b9ec5e5bdfc4d6">04216</a> <a class="code" href="wxlstate_8cpp.html#ac82bd290f3c6b0cbd06e20a6d9291c80">VARIADIC</a>(bxor, ^=)
  4246. <a name="l04217"></a><a class="code" href="wxlstate_8cpp.html#a4d70882bfa3d561cde0d0cbb160e7154">04217</a> <a class="code" href="wxlstate_8cpp.html#a8883b0c703b9975e42420aa9b56ae15e">ARITHMETIC_SHIFT</a>(lshift, &lt;&lt;)
  4247. <a name="l04218"></a><a class="code" href="wxlstate_8cpp.html#ab47a7fbe006f1d99cbb55ded1d50e789">04218</a> <a class="code" href="wxlstate_8cpp.html#a66ee3344af015fa6f5d7ad30f1dc02ce">LOGICAL_SHIFT</a>(rshift, &gt;&gt;)
  4248. <a name="l04219"></a><a class="code" href="wxlstate_8cpp.html#a77a1ac6718f7f727c0af0fc9c50021bc">04219</a> <a class="code" href="wxlstate_8cpp.html#a8883b0c703b9975e42420aa9b56ae15e">ARITHMETIC_SHIFT</a>(arshift, &gt;&gt;)
  4249. <a name="l04220"></a>04220
  4250. <a name="l04221"></a><a class="code" href="wxlstate_8cpp.html#abf7938c225b05790f66eb92d588f3f3a">04221</a> static const struct luaL_reg <a class="code" href="wxlstate_8cpp.html#abf7938c225b05790f66eb92d588f