luaforwindows/files/docs/wxlua/doxygen/html/wxldebug_8cpp_source.html

905 lines
96 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>wxLua: /mnt/share/devel/lua/wxLua/modules/wxluadebug/src/wxldebug.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="dirs.html"><span>Directories</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
<div class="navpath"><a class="el" href="dir_15d5a205ad383328522db6a6be296af1.html">modules</a>&nbsp;&raquo;&nbsp;<a class="el" href="dir_cf470daeabd5035b695eccd689e0edbd.html">wxluadebug</a>&nbsp;&raquo;&nbsp;<a class="el" href="dir_ad5e19fcea4c8ae5be8211526b26a3a5.html">src</a>
</div>
</div>
<div class="contents">
<h1>wxldebug.cpp</h1><a href="wxldebug_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>
<a name="l00002"></a>00002 <span class="comment"></span><span class="comment">// Name: wxLuaDebug.cpp</span>
<a name="l00003"></a>00003 <span class="comment">// Purpose: Debugging I/O functions for wxLua</span>
<a name="l00004"></a>00004 <span class="comment">// Author: J. Winwood, Ray Gilbert, John Labenski</span>
<a name="l00005"></a>00005 <span class="comment">// Created: May 2002</span>
<a name="l00006"></a>00006 <span class="comment">// Copyright: (c) 2002 Lomtick Software. All rights reserved.</span>
<a name="l00007"></a>00007 <span class="comment">// Licence: wxWidgets licence</span><span class="comment"></span>
<a name="l00008"></a>00008 <span class="comment">/////////////////////////////////////////////////////////////////////////////</span>
<a name="l00009"></a>00009 <span class="comment"></span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &quot;wx/wxprec.h&quot;</span>
<a name="l00011"></a>00011
<a name="l00012"></a>00012 <span class="preprocessor">#ifdef __BORLANDC__</span>
<a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor"> #pragma hdrstop</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00015"></a>00015 <span class="preprocessor"></span>
<a name="l00016"></a>00016 <span class="preprocessor">#ifndef WX_PRECOMP</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span><span class="preprocessor"> #include &quot;wx/wx.h&quot;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#endif</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;<a class="code" href="wxldebug_8h.html">wxluadebug/include/wxldebug.h</a>&quot;</span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &quot;<a class="code" href="wxlcallb_8h.html">wxlua/include/wxlcallb.h</a>&quot;</span>
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <a class="code" href="classwxLuaDebugData.html">wxLuaDebugData</a> <a class="code" href="wxldebug_8cpp.html#a25502c55f5eb032e2ddeec59f550ccd3">wxNullLuaDebugData</a>(<span class="keyword">false</span>);
<a name="l00024"></a>00024
<a name="l00025"></a>00025 <span class="comment">// ----------------------------------------------------------------------------</span>
<a name="l00026"></a>00026 <span class="comment">// wxLuaDebugItem</span>
<a name="l00027"></a>00027 <span class="comment">// ----------------------------------------------------------------------------</span>
<a name="l00028"></a><a class="code" href="classwxLuaDebugItem.html#ae08fb731263bcb04db0fc5f1485b34ae">00028</a> <a class="code" href="classwxLuaDebugItem.html#aec4a1d7f0994cde246a9d012e47b23b9">wxLuaDebugItem::wxLuaDebugItem</a>(<span class="keyword">const</span> wxString &amp;itemKey, <span class="keywordtype">int</span> itemKeyType,
<a name="l00029"></a>00029 <span class="keyword">const</span> wxString &amp;itemValue, <span class="keywordtype">int</span> itemValueType,
<a name="l00030"></a>00030 <span class="keyword">const</span> wxString &amp;itemSource,
<a name="l00031"></a>00031 <span class="keywordtype">int</span> lua_ref, <span class="keywordtype">int</span> idx, <span class="keywordtype">int</span> flag)
<a name="l00032"></a>00032 :m_itemKey(itemKey), m_itemKeyType(itemKeyType),
<a name="l00033"></a>00033 m_itemValue(itemValue), m_itemValueType(itemValueType),
<a name="l00034"></a>00034 m_itemSource(itemSource),
<a name="l00035"></a>00035 m_lua_ref(lua_ref), m_index(idx), m_flag(flag)
<a name="l00036"></a>00036 {
<a name="l00037"></a>00037 }
<a name="l00038"></a>00038
<a name="l00039"></a><a class="code" href="classwxLuaDebugItem.html#aec4a1d7f0994cde246a9d012e47b23b9">00039</a> <a class="code" href="classwxLuaDebugItem.html#aec4a1d7f0994cde246a9d012e47b23b9">wxLuaDebugItem::wxLuaDebugItem</a>(<span class="keyword">const</span> <a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a> &amp;dataItem)
<a name="l00040"></a>00040 :m_itemKey(dataItem.m_itemKey), m_itemKeyType(dataItem.m_itemKeyType),
<a name="l00041"></a>00041 m_itemValue(dataItem.m_itemValue), m_itemValueType(dataItem.m_itemValueType),
<a name="l00042"></a>00042 m_itemSource(dataItem.m_itemSource),
<a name="l00043"></a>00043 m_lua_ref(dataItem.m_lua_ref), m_index(dataItem.m_index),
<a name="l00044"></a>00044 m_flag(dataItem.m_flag)
<a name="l00045"></a>00045 {
<a name="l00046"></a>00046 }
<a name="l00047"></a>00047
<a name="l00048"></a><a class="code" href="classwxLuaDebugItem.html#aa1db0b589e054d180c9563fcde3f4143">00048</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaDebugItem.html#aa1db0b589e054d180c9563fcde3f4143">wxLuaDebugItem::GetRefPtr</a>(<span class="keywordtype">long</span>&amp; ptr)<span class="keyword"> const</span>
<a name="l00049"></a>00049 <span class="keyword"></span>{
<a name="l00050"></a>00050 <span class="keywordtype">bool</span> key_ref = <a class="code" href="classwxLuaDebugItem.html#a5b2be6fc04e248b2f5de4e0c535f8812">GetFlagBit</a>(<a class="code" href="wxldebug_8h.html#aa2fd8aa5a2d95cde0ea0be4691857235af057a953936ac6e00eca4983984a2eab">WXLUA_DEBUGITEM_KEY_REF</a>);
<a name="l00051"></a>00051 <span class="keywordtype">bool</span> val_ref = <a class="code" href="classwxLuaDebugItem.html#a5b2be6fc04e248b2f5de4e0c535f8812">GetFlagBit</a>(<a class="code" href="wxldebug_8h.html#aa2fd8aa5a2d95cde0ea0be4691857235ae399f7991ab5e948074483d0c65cc821">WXLUA_DEBUGITEM_VALUE_REF</a>);
<a name="l00052"></a>00052
<a name="l00053"></a>00053 <span class="comment">// sanity checks</span>
<a name="l00054"></a>00054 wxCHECK_MSG((key_ref || val_ref), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;wxLuaDebugItem has neither key or value reference&quot;</span>));
<a name="l00055"></a>00055 wxCHECK_MSG(!(key_ref &amp;&amp; val_ref), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;wxLuaDebugItem has both key and value reference&quot;</span>));
<a name="l00056"></a>00056
<a name="l00057"></a>00057 <span class="keywordflow">return</span> wxString(key_ref ? <a class="code" href="classwxLuaDebugItem.html#a5b00ecb7e87e690af18d4a57ee1b75b6">m_itemKey</a>: <a class="code" href="classwxLuaDebugItem.html#a6539ecb63415742bef43c23f6794fd36">m_itemValue</a>).BeforeFirst(wxT(<span class="charliteral">&#39; &#39;</span>)).ToLong(&amp;ptr, 16);
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059
<a name="l00060"></a>00060 <span class="comment">// ----------------------------------------------------------------------------</span>
<a name="l00061"></a>00061 <span class="comment">// wxLuaDebugData - Debug Info sent via socket to debugger client</span>
<a name="l00062"></a>00062 <span class="comment">// ----------------------------------------------------------------------------</span>
<a name="l00063"></a>00063
<a name="l00064"></a><a class="code" href="classwxLuaDebugDataRefData.html">00064</a> <span class="keyword">class </span><a class="code" href="classwxLuaDebugDataRefData.html">wxLuaDebugDataRefData</a> : <span class="keyword">public</span> wxObjectRefData
<a name="l00065"></a>00065 {
<a name="l00066"></a>00066 <span class="keyword">public</span>:
<a name="l00067"></a><a class="code" href="classwxLuaDebugDataRefData.html#aebc13738a1ffbb8410dd1c58b268feb4">00067</a> <a class="code" href="classwxLuaDebugDataRefData.html#aebc13738a1ffbb8410dd1c58b268feb4">wxLuaDebugDataRefData</a>() : <a class="code" href="classwxLuaDebugDataRefData.html#ab8502b54a96952c90ce4ec6af2890678">m_dataArray</a>(<a class="code" href="classwxLuaDebugData.html">wxLuaDebugData</a>::SortFunction) {}
<a name="l00068"></a>00068
<a name="l00069"></a><a class="code" href="classwxLuaDebugDataRefData.html#af372b632ff9de257f5a4fb57480ceb34">00069</a> <span class="keyword">virtual</span> <a class="code" href="classwxLuaDebugDataRefData.html#af372b632ff9de257f5a4fb57480ceb34">~wxLuaDebugDataRefData</a>()
<a name="l00070"></a>00070 {
<a name="l00071"></a>00071 <span class="keywordtype">size_t</span> idx, count = <a class="code" href="classwxLuaDebugDataRefData.html#ab8502b54a96952c90ce4ec6af2890678">m_dataArray</a>.GetCount();
<a name="l00072"></a>00072 <span class="keywordflow">for</span> (idx = 0; idx &lt; count; ++idx)
<a name="l00073"></a>00073 {
<a name="l00074"></a>00074 <span class="keyword">const</span> <a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a> *pData = <a class="code" href="classwxLuaDebugDataRefData.html#ab8502b54a96952c90ce4ec6af2890678">m_dataArray</a>.Item(idx);
<a name="l00075"></a>00075 <span class="keyword">delete</span> pData;
<a name="l00076"></a>00076 }
<a name="l00077"></a>00077 }
<a name="l00078"></a>00078
<a name="l00079"></a><a class="code" href="classwxLuaDebugDataRefData.html#ab8502b54a96952c90ce4ec6af2890678">00079</a> wxLuaDebugItemArray <a class="code" href="classwxLuaDebugDataRefData.html#ab8502b54a96952c90ce4ec6af2890678">m_dataArray</a>;
<a name="l00080"></a>00080 };
<a name="l00081"></a>00081
<a name="l00082"></a><a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">00082</a> <span class="preprocessor">#define M_DEBUGREFDATA ((wxLuaDebugDataRefData*)m_refData)</span>
<a name="l00083"></a>00083 <span class="preprocessor"></span>
<a name="l00084"></a><a class="code" href="classwxLuaDebugData.html#a35d4da45d7de90f54212d590c1b4c776">00084</a> <a class="code" href="classwxLuaDebugData.html#a35d4da45d7de90f54212d590c1b4c776">wxLuaDebugData::wxLuaDebugData</a>(<span class="keywordtype">bool</span> create) : wxObject()
<a name="l00085"></a>00085 {
<a name="l00086"></a>00086 <span class="keywordflow">if</span> (create)
<a name="l00087"></a>00087 m_refData = <span class="keyword">new</span> <a class="code" href="classwxLuaDebugDataRefData.html">wxLuaDebugDataRefData</a>;
<a name="l00088"></a>00088 }
<a name="l00089"></a>00089
<a name="l00090"></a><a class="code" href="classwxLuaDebugData.html#ab7fec3794f694eeee76a8daebb86ea3e">00090</a> wxLuaDebugItemArray* <a class="code" href="classwxLuaDebugData.html#ab7fec3794f694eeee76a8daebb86ea3e">wxLuaDebugData::GetArray</a>()
<a name="l00091"></a>00091 {
<a name="l00092"></a>00092 wxCHECK_MSG(<a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a> != NULL, NULL, wxT(<span class="stringliteral">&quot;Invalid ref data&quot;</span>));
<a name="l00093"></a>00093 <span class="keywordflow">return</span> &amp;(<a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a>-&gt;m_dataArray);
<a name="l00094"></a>00094 }
<a name="l00095"></a><a class="code" href="classwxLuaDebugData.html#a5a00b519c8ba56ba1665decc4257f68d">00095</a> <span class="keyword">const</span> wxLuaDebugItemArray* <a class="code" href="classwxLuaDebugData.html#ab7fec3794f694eeee76a8daebb86ea3e">wxLuaDebugData::GetArray</a>()<span class="keyword"> const</span>
<a name="l00096"></a>00096 <span class="keyword"></span>{
<a name="l00097"></a>00097 wxCHECK_MSG(<a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a> != NULL, NULL, wxT(<span class="stringliteral">&quot;Invalid ref data&quot;</span>));
<a name="l00098"></a>00098 <span class="keywordflow">return</span> &amp;(<a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a>-&gt;m_dataArray);
<a name="l00099"></a>00099 }
<a name="l00100"></a>00100
<a name="l00101"></a><a class="code" href="classwxLuaDebugData.html#a46b2623908985a7d526a21c4c8df25f7">00101</a> <span class="keywordtype">size_t</span> <a class="code" href="classwxLuaDebugData.html#a46b2623908985a7d526a21c4c8df25f7">wxLuaDebugData::GetCount</a>()<span class="keyword"> const</span>
<a name="l00102"></a>00102 <span class="keyword"></span>{
<a name="l00103"></a>00103 wxCHECK_MSG(<a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a> != NULL, 0, wxT(<span class="stringliteral">&quot;Invalid ref data&quot;</span>));
<a name="l00104"></a>00104 <span class="keywordflow">return</span> <a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a>-&gt;m_dataArray.GetCount();
<a name="l00105"></a>00105 }
<a name="l00106"></a><a class="code" href="classwxLuaDebugData.html#acaa79bea1552f8ab7aaac401582f8513">00106</a> <a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a>* <a class="code" href="classwxLuaDebugData.html#acaa79bea1552f8ab7aaac401582f8513">wxLuaDebugData::Item</a>(<span class="keywordtype">size_t</span> index)<span class="keyword"> const</span>
<a name="l00107"></a>00107 <span class="keyword"></span>{
<a name="l00108"></a>00108 wxCHECK_MSG(<a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a> != NULL, NULL, wxT(<span class="stringliteral">&quot;Invalid ref data&quot;</span>));
<a name="l00109"></a>00109 <span class="keywordflow">return</span> <a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a>-&gt;m_dataArray.Item(index);
<a name="l00110"></a>00110 }
<a name="l00111"></a><a class="code" href="classwxLuaDebugData.html#a3daa718fdc572d507b084b014f729744">00111</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaDebugData.html#a3daa718fdc572d507b084b014f729744">wxLuaDebugData::Add</a>(<a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a>* item)
<a name="l00112"></a>00112 {
<a name="l00113"></a>00113 wxCHECK_RET(<a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a> != NULL, wxT(<span class="stringliteral">&quot;Invalid ref data&quot;</span>));
<a name="l00114"></a>00114 wxCHECK_RET(item != NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaDebugItem&quot;</span>));
<a name="l00115"></a>00115 <a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a>-&gt;m_dataArray.Add(item);
<a name="l00116"></a>00116 }
<a name="l00117"></a>00117
<a name="l00118"></a><a class="code" href="classwxLuaDebugData.html#a9e990462144c878b02dfd961d4f35269">00118</a> <a class="code" href="classwxLuaDebugData.html">wxLuaDebugData</a> <a class="code" href="classwxLuaDebugData.html#a9e990462144c878b02dfd961d4f35269">wxLuaDebugData::Copy</a>()<span class="keyword"> const</span>
<a name="l00119"></a>00119 <span class="keyword"></span>{
<a name="l00120"></a>00120 wxCHECK_MSG(<a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a> != NULL, <a class="code" href="wxldebug_8cpp.html#a25502c55f5eb032e2ddeec59f550ccd3">wxNullLuaDebugData</a>, wxT(<span class="stringliteral">&quot;Invalid ref data&quot;</span>));
<a name="l00121"></a>00121
<a name="l00122"></a>00122 <a class="code" href="classwxLuaDebugData.html">wxLuaDebugData</a> copyData(<span class="keyword">true</span>);
<a name="l00123"></a>00123
<a name="l00124"></a>00124 <span class="keywordtype">size_t</span> idx, count = <a class="code" href="classwxLuaDebugData.html#a46b2623908985a7d526a21c4c8df25f7">GetCount</a>();
<a name="l00125"></a>00125 <span class="keywordflow">for</span> (idx = 0; idx &lt; count; ++idx)
<a name="l00126"></a>00126 {
<a name="l00127"></a>00127 <span class="keyword">const</span> <a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a> *pOldData = <a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a>-&gt;m_dataArray.Item(idx);
<a name="l00128"></a>00128 <span class="keywordflow">if</span> (pOldData != NULL)
<a name="l00129"></a>00129 copyData.<a class="code" href="classwxLuaDebugData.html#a3daa718fdc572d507b084b014f729744">Add</a>(<span class="keyword">new</span> <a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a>(*pOldData));
<a name="l00130"></a>00130 }
<a name="l00131"></a>00131
<a name="l00132"></a>00132 <span class="keywordflow">return</span> copyData;
<a name="l00133"></a>00133 }
<a name="l00134"></a>00134
<a name="l00135"></a><a class="code" href="classwxLuaDebugData.html#a683df1bdfcf97f804f83822629066882">00135</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaDebugData.html#a683df1bdfcf97f804f83822629066882">wxLuaDebugData::SortFunction</a>(<a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a> *elem1, <a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a> *elem2 )
<a name="l00136"></a>00136 {
<a name="l00137"></a>00137 <span class="keywordtype">int</span> ret = 0;
<a name="l00138"></a>00138
<a name="l00139"></a>00139 <span class="keywordtype">long</span> l1 = 0, l2 = 0;
<a name="l00140"></a>00140
<a name="l00141"></a>00141 <span class="keywordflow">if</span> ((elem1-&gt;<a class="code" href="classwxLuaDebugItem.html#a724720b3a10a534f5ad49227a3e0a2bb">m_itemKeyType</a> == <a class="code" href="wxlbind_8h.html#ab722ed662e4f3b7f2624d9a71f5c5817">WXLUA_TNUMBER</a>) &amp;&amp;
<a name="l00142"></a>00142 (elem2-&gt;<a class="code" href="classwxLuaDebugItem.html#a724720b3a10a534f5ad49227a3e0a2bb">m_itemKeyType</a> == <a class="code" href="wxlbind_8h.html#ab722ed662e4f3b7f2624d9a71f5c5817">WXLUA_TNUMBER</a>) &amp;&amp;
<a name="l00143"></a>00143 elem1-&gt;<a class="code" href="classwxLuaDebugItem.html#a5b00ecb7e87e690af18d4a57ee1b75b6">m_itemKey</a>.BeforeFirst(wxT(<span class="charliteral">&#39; &#39;</span>)).ToLong(&amp;l1) &amp;&amp;
<a name="l00144"></a>00144 elem2-&gt;<a class="code" href="classwxLuaDebugItem.html#a5b00ecb7e87e690af18d4a57ee1b75b6">m_itemKey</a>.BeforeFirst(wxT(<span class="charliteral">&#39; &#39;</span>)).ToLong(&amp;l2))
<a name="l00145"></a>00145 ret = l1 - l2;
<a name="l00146"></a>00146 <span class="keywordflow">else</span>
<a name="l00147"></a>00147 ret = elem1-&gt;<a class="code" href="classwxLuaDebugItem.html#a5b00ecb7e87e690af18d4a57ee1b75b6">m_itemKey</a>.Cmp(elem2-&gt;<a class="code" href="classwxLuaDebugItem.html#a5b00ecb7e87e690af18d4a57ee1b75b6">m_itemKey</a>);
<a name="l00148"></a>00148
<a name="l00149"></a>00149 <span class="keywordflow">if</span> (ret == 0) <span class="comment">// can be true for unnamed &quot;(*temporary)&quot; vars</span>
<a name="l00150"></a>00150 {
<a name="l00151"></a>00151 ret = elem1-&gt;<a class="code" href="classwxLuaDebugItem.html#a724720b3a10a534f5ad49227a3e0a2bb">m_itemKeyType</a> - elem2-&gt;<a class="code" href="classwxLuaDebugItem.html#a724720b3a10a534f5ad49227a3e0a2bb">m_itemKeyType</a>;
<a name="l00152"></a>00152
<a name="l00153"></a>00153 <span class="keywordflow">if</span> (ret == 0)
<a name="l00154"></a>00154 {
<a name="l00155"></a>00155 ret = elem1-&gt;<a class="code" href="classwxLuaDebugItem.html#a3ff51275409202d3f64c37dc4051f866">m_itemValueType</a> - elem2-&gt;<a class="code" href="classwxLuaDebugItem.html#a3ff51275409202d3f64c37dc4051f866">m_itemValueType</a>;
<a name="l00156"></a>00156
<a name="l00157"></a>00157 <span class="keywordflow">if</span> (ret == 0)
<a name="l00158"></a>00158 {
<a name="l00159"></a>00159 ret = elem1-&gt;<a class="code" href="classwxLuaDebugItem.html#a6539ecb63415742bef43c23f6794fd36">m_itemValue</a>.Cmp(elem2-&gt;<a class="code" href="classwxLuaDebugItem.html#a6539ecb63415742bef43c23f6794fd36">m_itemValue</a>);
<a name="l00160"></a>00160
<a name="l00161"></a>00161 <span class="keywordflow">if</span> (ret == 0)
<a name="l00162"></a>00162 ret = int(elem2-&gt;<a class="code" href="classwxLuaDebugItem.html#a5b2be6fc04e248b2f5de4e0c535f8812">GetFlagBit</a>(<a class="code" href="wxldebug_8h.html#aa2fd8aa5a2d95cde0ea0be4691857235af057a953936ac6e00eca4983984a2eab">WXLUA_DEBUGITEM_KEY_REF</a>)) -
<a name="l00163"></a>00163 <span class="keywordtype">int</span>(elem1-&gt;<a class="code" href="classwxLuaDebugItem.html#a5b2be6fc04e248b2f5de4e0c535f8812">GetFlagBit</a>(<a class="code" href="wxldebug_8h.html#aa2fd8aa5a2d95cde0ea0be4691857235af057a953936ac6e00eca4983984a2eab">WXLUA_DEBUGITEM_KEY_REF</a>));
<a name="l00164"></a>00164 }
<a name="l00165"></a>00165 }
<a name="l00166"></a>00166 }
<a name="l00167"></a>00167
<a name="l00168"></a>00168 <span class="keywordflow">return</span> ret;
<a name="l00169"></a>00169 }
<a name="l00170"></a>00170
<a name="l00171"></a><a class="code" href="classwxLuaDebugData.html#a85f3c6f3f415fa3fe693342f7ab92a85">00171</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaDebugData.html#a85f3c6f3f415fa3fe693342f7ab92a85">wxLuaDebugData::EnumerateStack</a>(<span class="keyword">const</span> <a class="code" href="classwxLuaState.html">wxLuaState</a>&amp; wxlState_)
<a name="l00172"></a>00172 {
<a name="l00173"></a>00173 wxCHECK_MSG(wxlState_.<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
<a name="l00174"></a>00174 wxCHECK_MSG(<a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a> != NULL, 0, wxT(<span class="stringliteral">&quot;Invalid ref data&quot;</span>));
<a name="l00175"></a>00175
<a name="l00176"></a>00176 <a class="code" href="classwxLuaState.html">wxLuaState</a> wxlState(wxlState_); <span class="comment">// unconst the state</span>
<a name="l00177"></a>00177 lua_State* L = wxlState.<a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">GetLuaState</a>();
<a name="l00178"></a>00178 lua_Debug luaDebug = <a class="code" href="wxldefs_8h.html#a2fecae24d4d9e2f9551226b5e1389f8f">INIT_LUA_DEBUG</a>;
<a name="l00179"></a>00179 <span class="keywordtype">int</span> stack_frame = 0;
<a name="l00180"></a>00180 <span class="keywordtype">int</span> count = 0;
<a name="l00181"></a>00181
<a name="l00182"></a>00182 <span class="keywordflow">while</span> (lua_getstack(L, stack_frame, &amp;luaDebug) != 0)
<a name="l00183"></a>00183 {
<a name="l00184"></a>00184 <span class="keywordflow">if</span> (lua_getinfo(L, <span class="stringliteral">&quot;Sln&quot;</span>, &amp;luaDebug))
<a name="l00185"></a>00185 {
<a name="l00186"></a>00186 <span class="comment">//wxPrintf(wxString(lua_Debug_to_wxString(luaDebug) + wxT(&quot;\n&quot;)).c_str());</span>
<a name="l00187"></a>00187
<a name="l00188"></a>00188 <span class="comment">// skip stack frames that do not have line number, always add first</span>
<a name="l00189"></a>00189 <span class="keywordtype">int</span> currentLine = luaDebug.currentline;
<a name="l00190"></a>00190 <span class="keywordflow">if</span> ((count == 0) || (currentLine != -1))
<a name="l00191"></a>00191 {
<a name="l00192"></a>00192 wxString name;
<a name="l00193"></a>00193 wxString source(<a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(luaDebug.source));
<a name="l00194"></a>00194
<a name="l00195"></a>00195 <span class="keywordflow">if</span> (currentLine == -1)
<a name="l00196"></a>00196 currentLine = 0;
<a name="l00197"></a>00197
<a name="l00198"></a>00198 <span class="keywordflow">if</span> (luaDebug.name != NULL)
<a name="l00199"></a>00199 name = wxString::Format(_(<span class="stringliteral">&quot;function %s line %d&quot;</span>), <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(luaDebug.name).c_str(), currentLine);
<a name="l00200"></a>00200 <span class="keywordflow">else</span>
<a name="l00201"></a>00201 name = wxString::Format(_(<span class="stringliteral">&quot;line %d&quot;</span>), currentLine);
<a name="l00202"></a>00202
<a name="l00203"></a>00203 <a class="code" href="classwxLuaDebugData.html#a3daa718fdc572d507b084b014f729744">Add</a>(<span class="keyword">new</span> <a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a>(name, <a class="code" href="wxlbind_8h.html#ab1ffe83879cd856390708161cbc49e8d">WXLUA_TNONE</a>, wxT(<span class="stringliteral">&quot;&quot;</span>), <a class="code" href="wxlbind_8h.html#ab1ffe83879cd856390708161cbc49e8d">WXLUA_TNONE</a>, source, LUA_NOREF, stack_frame, <a class="code" href="wxldebug_8h.html#aa2fd8aa5a2d95cde0ea0be4691857235a330ef4e338bb589ad6ff6e0249772afa">WXLUA_DEBUGITEM_LOCALS</a>));
<a name="l00204"></a>00204 ++count;
<a name="l00205"></a>00205 }
<a name="l00206"></a>00206 }
<a name="l00207"></a>00207
<a name="l00208"></a>00208 ++stack_frame;
<a name="l00209"></a>00209 }
<a name="l00210"></a>00210
<a name="l00211"></a>00211 <span class="keywordflow">return</span> count;
<a name="l00212"></a>00212 }
<a name="l00213"></a>00213
<a name="l00214"></a><a class="code" href="classwxLuaDebugData.html#a5983164ca04755d7d6ddd75c34dda075">00214</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaDebugData.html#a5983164ca04755d7d6ddd75c34dda075">wxLuaDebugData::EnumerateStackEntry</a>(<span class="keyword">const</span> <a class="code" href="classwxLuaState.html">wxLuaState</a>&amp; wxlState_, <span class="keywordtype">int</span> stack_frame, wxArrayInt&amp; references)
<a name="l00215"></a>00215 {
<a name="l00216"></a>00216 wxCHECK_MSG(wxlState_.<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
<a name="l00217"></a>00217 wxCHECK_MSG(<a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a> != NULL, 0, wxT(<span class="stringliteral">&quot;Invalid ref data&quot;</span>));
<a name="l00218"></a>00218
<a name="l00219"></a>00219 <a class="code" href="classwxLuaState.html">wxLuaState</a> wxlState(wxlState_); <span class="comment">// unconst the state</span>
<a name="l00220"></a>00220 lua_State* L = wxlState.<a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">GetLuaState</a>();
<a name="l00221"></a>00221 lua_Debug luaDebug = <a class="code" href="wxldefs_8h.html#a2fecae24d4d9e2f9551226b5e1389f8f">INIT_LUA_DEBUG</a>;
<a name="l00222"></a>00222 <span class="keywordtype">int</span> count = 0;
<a name="l00223"></a>00223
<a name="l00224"></a>00224 <span class="keywordflow">if</span> (lua_getstack(L, stack_frame, &amp;luaDebug) != 0)
<a name="l00225"></a>00225 {
<a name="l00226"></a>00226 <span class="keywordtype">int</span> stack_idx = 1;
<a name="l00227"></a>00227 wxString name(<a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(lua_getlocal(L, &amp;luaDebug, stack_idx)));
<a name="l00228"></a>00228 <span class="keywordflow">while</span> (!name.IsEmpty())
<a name="l00229"></a>00229 {
<a name="l00230"></a>00230 <span class="comment">//wxPrintf(wxString(lua_Debug_to_wxString(luaDebug) + wxT(&quot; lua_getlocal :&quot;) + name + wxT(&quot;\n&quot;)).c_str());</span>
<a name="l00231"></a>00231
<a name="l00232"></a>00232 <span class="keywordtype">int</span> wxl_valuetype = <a class="code" href="wxlbind_8h.html#ab1ffe83879cd856390708161cbc49e8d">WXLUA_TNONE</a>;
<a name="l00233"></a>00233 wxString value;
<a name="l00234"></a>00234 wxString source(<a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(luaDebug.source));
<a name="l00235"></a>00235
<a name="l00236"></a>00236 <a class="code" href="classwxLuaDebugData.html#a30df4f18ac75a09adffd515f8d0db3c5">GetTypeValue</a>(wxlState, -1, &amp;wxl_valuetype, value);
<a name="l00237"></a>00237
<a name="l00238"></a>00238 <span class="comment">// FIXME! local tables get the right values for GetTypeValue(...)</span>
<a name="l00239"></a>00239 <span class="comment">// but when you run wxluaR_ref() to store them they disappear</span>
<a name="l00240"></a>00240 <span class="comment">// so that the next time wxluaR_ref() is run it reuses the same</span>
<a name="l00241"></a>00241 <span class="comment">// index as your local table.</span>
<a name="l00242"></a>00242 <span class="comment">// When using the stack dialog the next wxluaR_ref() is the</span>
<a name="l00243"></a>00243 <span class="comment">// global table which is very confusing.</span>
<a name="l00244"></a>00244
<a name="l00245"></a>00245 <span class="keywordtype">int</span> flag_type = 0;
<a name="l00246"></a>00246 <span class="keywordtype">int</span> nRef = LUA_NOREF; <span class="comment">//RefTable(L, -1, &amp;flag_type, references);</span>
<a name="l00247"></a>00247
<a name="l00248"></a>00248 lua_pop(L, 1); <span class="comment">// remove variable value</span>
<a name="l00249"></a>00249
<a name="l00250"></a>00250 <a class="code" href="classwxLuaDebugData.html#a3daa718fdc572d507b084b014f729744">Add</a>(<span class="keyword">new</span> <a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a>(name, <a class="code" href="wxlbind_8h.html#ab1ffe83879cd856390708161cbc49e8d">WXLUA_TNONE</a>, value, wxl_valuetype, source, nRef, 0, flag_type));
<a name="l00251"></a>00251 ++count;
<a name="l00252"></a>00252
<a name="l00253"></a>00253 name = <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(lua_getlocal(L, &amp;luaDebug, ++stack_idx));
<a name="l00254"></a>00254 }
<a name="l00255"></a>00255 }
<a name="l00256"></a>00256
<a name="l00257"></a>00257 <span class="keywordflow">return</span> count;
<a name="l00258"></a>00258 }
<a name="l00259"></a>00259
<a name="l00260"></a><a class="code" href="wxldebug_8cpp.html#ac93374edd0c8b07e2597f4499bf05968">00260</a> wxString <a class="code" href="wxldebug_8cpp.html#ac93374edd0c8b07e2597f4499bf05968">wxLuaBindClassString</a>(<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass)
<a name="l00261"></a>00261 {
<a name="l00262"></a>00262 wxCHECK_MSG(wxlClass, wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid wxLuaBindClass&quot;</span>));
<a name="l00263"></a>00263 wxString baseClasses;
<a name="l00264"></a>00264 <span class="keywordflow">if</span> (wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a22728b03f43176679679849fdb48f55e">baseclassNames</a>)
<a name="l00265"></a>00265 {
<a name="l00266"></a>00266 <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)
<a name="l00267"></a>00267 baseClasses += <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a22728b03f43176679679849fdb48f55e">baseclassNames</a>[i]) + wxT(<span class="stringliteral">&quot;,&quot;</span>);
<a name="l00268"></a>00268 }
<a name="l00269"></a>00269
<a name="l00270"></a>00270 <span class="keywordflow">return</span> wxString::Format(wxT(<span class="stringliteral">&quot; (%s, wxluatype=%d, classinfo=%s, baseclass=%s, methods=%d, enums=%d)&quot;</span>),
<a name="l00271"></a>00271 <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#af89cbb87774c38c593f7ed87a68fffcb">name</a>).c_str(), *wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a487a56c7a763a21041272c4b053e6c99">wxluatype</a>,
<a name="l00272"></a>00272 wxString(wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a248c5858774504530f3873f27421410c">classInfo</a> ? wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a248c5858774504530f3873f27421410c">classInfo</a>-&gt;GetClassName() : wxEmptyString).c_str(),
<a name="l00273"></a>00273 baseClasses.c_str(),
<a name="l00274"></a>00274 wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a5eac6feca088451706f0fde55dd73393">wxluamethods_n</a>, wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#aadcfb36d6f271ada8864f1d88a0ca5fc">enums_n</a>);
<a name="l00275"></a>00275 }
<a name="l00276"></a>00276
<a name="l00277"></a><a class="code" href="classwxLuaDebugData.html#a1fb108b0bdd45ff3989a882bf1e5d045">00277</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaDebugData.html#a1fb108b0bdd45ff3989a882bf1e5d045">wxLuaDebugData::EnumerateTable</a>(<span class="keyword">const</span> <a class="code" href="classwxLuaState.html">wxLuaState</a>&amp; wxlState_, <span class="keywordtype">int</span> tableRef, <span class="keywordtype">int</span> nIndex, wxArrayInt&amp; references)
<a name="l00278"></a>00278 {
<a name="l00279"></a>00279 wxCHECK_MSG(wxlState_.<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
<a name="l00280"></a>00280 wxCHECK_MSG(<a class="code" href="wxldebug_8cpp.html#afbb25521c653f545c37539a3804a7d97">M_DEBUGREFDATA</a> != NULL, 0, wxT(<span class="stringliteral">&quot;Invalid ref data&quot;</span>));
<a name="l00281"></a>00281
<a name="l00282"></a>00282 <a class="code" href="classwxLuaState.html">wxLuaState</a> wxlState(wxlState_); <span class="comment">// unconst the state</span>
<a name="l00283"></a>00283 lua_State* L = wxlState.<a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">GetLuaState</a>();
<a name="l00284"></a>00284 <span class="keywordtype">int</span> count = 0;
<a name="l00285"></a>00285
<a name="l00286"></a>00286 <span class="keywordtype">int</span> wxl_keytype = <a class="code" href="wxlbind_8h.html#ab1ffe83879cd856390708161cbc49e8d">WXLUA_TNONE</a>;
<a name="l00287"></a>00287 <span class="keywordtype">int</span> wxl_valuetype = <a class="code" href="wxlbind_8h.html#ab1ffe83879cd856390708161cbc49e8d">WXLUA_TNONE</a>;
<a name="l00288"></a>00288 wxString value;
<a name="l00289"></a>00289 wxString name;
<a name="l00290"></a>00290
<a name="l00291"></a>00291 <span class="keywordflow">if</span> ((tableRef == -1) || (tableRef == LUA_GLOBALSINDEX))
<a name="l00292"></a>00292 {
<a name="l00293"></a>00293 lua_pushvalue(L, LUA_GLOBALSINDEX);
<a name="l00294"></a>00294 <a class="code" href="classwxLuaDebugData.html#a30df4f18ac75a09adffd515f8d0db3c5">GetTypeValue</a>(wxlState, -1, &amp;wxl_valuetype, value);
<a name="l00295"></a>00295
<a name="l00296"></a>00296 <span class="keywordtype">int</span> flag_type = 0;
<a name="l00297"></a>00297 <span class="keywordtype">int</span> val_ref = <a class="code" href="classwxLuaDebugData.html#a9aae4ae1c23f52643d0dcf26fd772983">RefTable</a>(L, -1, &amp;flag_type, <a class="code" href="wxldebug_8h.html#aa2fd8aa5a2d95cde0ea0be4691857235ae399f7991ab5e948074483d0c65cc821">WXLUA_DEBUGITEM_VALUE_REF</a>, references);
<a name="l00298"></a>00298 lua_pop(L, 1); <span class="comment">// pop globals table</span>
<a name="l00299"></a>00299
<a name="l00300"></a>00300 <a class="code" href="classwxLuaDebugData.html#a3daa718fdc572d507b084b014f729744">Add</a>(<span class="keyword">new</span> <a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a>(wxT(<span class="stringliteral">&quot;Globals&quot;</span>), <a class="code" href="wxlbind_8h.html#ab1ffe83879cd856390708161cbc49e8d">WXLUA_TNONE</a>, value, <a class="code" href="wxlbind_8h.html#ab80aed8ef4eafc8ab9479e39597330ff">WXLUA_TTABLE</a>, wxT(<span class="stringliteral">&quot;&quot;</span>), val_ref, 0, flag_type));
<a name="l00301"></a>00301 }
<a name="l00302"></a>00302 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (tableRef == LUA_REGISTRYINDEX)
<a name="l00303"></a>00303 {
<a name="l00304"></a>00304 lua_pushvalue(L, LUA_REGISTRYINDEX);
<a name="l00305"></a>00305 <a class="code" href="classwxLuaDebugData.html#a30df4f18ac75a09adffd515f8d0db3c5">GetTypeValue</a>(wxlState, -1, &amp;wxl_valuetype, value);
<a name="l00306"></a>00306
<a name="l00307"></a>00307 <span class="keywordtype">int</span> flag_type = 0;
<a name="l00308"></a>00308 <span class="keywordtype">int</span> val_ref = <a class="code" href="classwxLuaDebugData.html#a9aae4ae1c23f52643d0dcf26fd772983">RefTable</a>(L, -1, &amp;flag_type, <a class="code" href="wxldebug_8h.html#aa2fd8aa5a2d95cde0ea0be4691857235ae399f7991ab5e948074483d0c65cc821">WXLUA_DEBUGITEM_VALUE_REF</a>, references);
<a name="l00309"></a>00309 lua_pop(L, 1); <span class="comment">// pop registry table</span>
<a name="l00310"></a>00310
<a name="l00311"></a>00311 <a class="code" href="classwxLuaDebugData.html#a3daa718fdc572d507b084b014f729744">Add</a>(<span class="keyword">new</span> <a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a>(wxT(<span class="stringliteral">&quot;Registry&quot;</span>), <a class="code" href="wxlbind_8h.html#ab1ffe83879cd856390708161cbc49e8d">WXLUA_TNONE</a>, value, <a class="code" href="wxlbind_8h.html#ab80aed8ef4eafc8ab9479e39597330ff">WXLUA_TTABLE</a>, wxT(<span class="stringliteral">&quot;&quot;</span>), val_ref, 0, flag_type));
<a name="l00312"></a>00312 }
<a name="l00313"></a>00313 <span class="keywordflow">else</span>
<a name="l00314"></a>00314 {
<a name="l00315"></a>00315 <span class="comment">// push the table onto the stack to iterate through</span>
<a name="l00316"></a>00316 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#ae7108b396d79179f517a7dc478c2cb43">wxluaR_getref</a>(L, tableRef, &amp;<a class="code" href="wxlstate_8h.html#a30c2d5556a4a278368b48fe0b7bb3fda">wxlua_lreg_debug_refs_key</a>))
<a name="l00317"></a>00317 {
<a name="l00318"></a>00318 <span class="keywordflow">if</span> (lua_isnil(L, -1))
<a name="l00319"></a>00319 {
<a name="l00320"></a>00320 <span class="comment">// assert so we don&#39;t crash mysteriously inside Lua on nil</span>
<a name="l00321"></a>00321 lua_pop(L, 1); <span class="comment">// pop nil</span>
<a name="l00322"></a>00322 wxFAIL_MSG(wxT(<span class="stringliteral">&quot;Invalid wxLua debug reference&quot;</span>));
<a name="l00323"></a>00323 <span class="keywordflow">return</span> count;
<a name="l00324"></a>00324 }
<a name="l00325"></a>00325
<a name="l00326"></a>00326 <span class="comment">// Check to see if this is a wxLua LUA_REGISTRYINDEX table</span>
<a name="l00327"></a>00327 <span class="keywordtype">void</span> *lightuserdata_reg_key = NULL;
<a name="l00328"></a>00328 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#ab84cb2515893ab069d7d165208e68aad">wxlua_lreg_regtable_key</a>); <span class="comment">// push key</span>
<a name="l00329"></a>00329 lua_rawget(L, LUA_REGISTRYINDEX);
<a name="l00330"></a>00330 lua_pushvalue(L, -2); <span class="comment">// push value (table we&#39;re iterating)</span>
<a name="l00331"></a>00331 lua_rawget(L, -2);
<a name="l00332"></a>00332 lightuserdata_reg_key = lua_touserdata(L, -1);
<a name="l00333"></a>00333 lua_pop(L, 2); <span class="comment">// pop wxlua_lreg_regtable_key table and (nil or lightuserdata)</span>
<a name="l00334"></a>00334
<a name="l00335"></a>00335 <span class="comment">// Check if the table/userdata has a metatable</span>
<a name="l00336"></a>00336 <span class="keywordflow">if</span> (lua_getmetatable(L, -1)) <span class="comment">// if no metatable then nothing is pushed</span>
<a name="l00337"></a>00337 {
<a name="l00338"></a>00338 <span class="comment">// get the type and value</span>
<a name="l00339"></a>00339 <a class="code" href="classwxLuaDebugData.html#a30df4f18ac75a09adffd515f8d0db3c5">GetTypeValue</a>(wxlState, -1, &amp;wxl_valuetype, value);
<a name="l00340"></a>00340
<a name="l00341"></a>00341 <span class="keywordtype">int</span> flag_type = 0;
<a name="l00342"></a>00342 <span class="keywordtype">int</span> val_ref = <a class="code" href="classwxLuaDebugData.html#a9aae4ae1c23f52643d0dcf26fd772983">RefTable</a>(L, -1, &amp;flag_type, <a class="code" href="wxldebug_8h.html#aa2fd8aa5a2d95cde0ea0be4691857235ae399f7991ab5e948074483d0c65cc821">WXLUA_DEBUGITEM_VALUE_REF</a>, references);
<a name="l00343"></a>00343
<a name="l00344"></a>00344 <span class="comment">// leading space so it&#39;s first when sorted</span>
<a name="l00345"></a>00345 <a class="code" href="classwxLuaDebugData.html#a3daa718fdc572d507b084b014f729744">Add</a>(<span class="keyword">new</span> <a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a>(wxT(<span class="stringliteral">&quot; __metatable&quot;</span>), <a class="code" href="wxlbind_8h.html#ab80aed8ef4eafc8ab9479e39597330ff">WXLUA_TTABLE</a>, value, wxl_valuetype, wxT(<span class="stringliteral">&quot;&quot;</span>), val_ref, nIndex, flag_type));
<a name="l00346"></a>00346 ++count;
<a name="l00347"></a>00347
<a name="l00348"></a>00348 lua_pop(L, 1); <span class="comment">// pop metatable</span>
<a name="l00349"></a>00349 }
<a name="l00350"></a>00350
<a name="l00351"></a>00351 <span class="comment">// start iterating</span>
<a name="l00352"></a>00352 <span class="keywordflow">if</span> (lua_istable(L, -1))
<a name="l00353"></a>00353 {
<a name="l00354"></a>00354 lua_pushnil(L);
<a name="l00355"></a>00355 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
<a name="l00356"></a>00356 {
<a name="l00357"></a>00357 <span class="comment">// value at -1, key at -2, table at -3</span>
<a name="l00358"></a>00358
<a name="l00359"></a>00359 <span class="comment">// get the key type and value</span>
<a name="l00360"></a>00360 <span class="keywordtype">int</span> lua_key_type = <a class="code" href="classwxLuaDebugData.html#a30df4f18ac75a09adffd515f8d0db3c5">GetTypeValue</a>(wxlState, -2, &amp;wxl_keytype, name);
<a name="l00361"></a>00361 <span class="comment">// get the value type and value</span>
<a name="l00362"></a>00362 <span class="keywordtype">int</span> lua_value_type = <a class="code" href="classwxLuaDebugData.html#a30df4f18ac75a09adffd515f8d0db3c5">GetTypeValue</a>(wxlState, -1, &amp;wxl_valuetype, value);
<a name="l00363"></a>00363
<a name="l00364"></a>00364 <span class="comment">// Handle wxLua LUA_REGISTRYINDEX tables to give more information</span>
<a name="l00365"></a>00365 <span class="keywordflow">if</span> (lightuserdata_reg_key != NULL)
<a name="l00366"></a>00366 {
<a name="l00367"></a>00367 <span class="keywordflow">if</span> (lightuserdata_reg_key == &amp;<a class="code" href="wxlstate_8h.html#a0ef6804bd2cb63f4fa705727f8871cbd">wxlua_lreg_types_key</a>)
<a name="l00368"></a>00368 {
<a name="l00369"></a>00369 value += wxT(<span class="stringliteral">&quot; (&quot;</span>) + <a class="code" href="wxlstate_8h.html#a6621fa5a456448acfd515112aa7b23e1">wxluaT_typename</a>(L, (<span class="keywordtype">int</span>)lua_tonumber(L, -2)) + wxT(<span class="stringliteral">&quot;)&quot;</span>);
<a name="l00370"></a>00370 }
<a name="l00371"></a>00371 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (lightuserdata_reg_key == &amp;<a class="code" href="wxlstate_8h.html#a0bcf696ed6d6e2b4218e9a8852a164ef">wxlua_lreg_classes_key</a>)
<a name="l00372"></a>00372 {
<a name="l00373"></a>00373 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = (<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>*)lua_touserdata(L, -1);
<a name="l00374"></a>00374 value += <a class="code" href="wxldebug_8cpp.html#ac93374edd0c8b07e2597f4499bf05968">wxLuaBindClassString</a>(wxlClass);
<a name="l00375"></a>00375 }
<a name="l00376"></a>00376 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (lightuserdata_reg_key == &amp;<a class="code" href="wxlstate_8h.html#a80a0d4c84529abdcf6b46237431832ce">wxlua_lreg_wxluabindings_key</a>)
<a name="l00377"></a>00377 {
<a name="l00378"></a>00378 <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding = (<a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>*)lua_touserdata(L, -2);
<a name="l00379"></a>00379 name = wxT(<span class="stringliteral">&quot;wxLuaBinding(&quot;</span>)+name+wxT(<span class="stringliteral">&quot;) -&gt; &quot;</span>)+binding-&gt;<a class="code" href="classwxLuaBinding.html#a9878ed9507384f5820f102218c3f82f6">GetBindingName</a>();
<a name="l00380"></a>00380 value += wxT(<span class="stringliteral">&quot; = &quot;</span>) + binding-&gt;<a class="code" href="classwxLuaBinding.html#a511674a9760efa5e05eb6fcaf5c5a969">GetLuaNamespace</a>();
<a name="l00381"></a>00381 }
<a name="l00382"></a>00382 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (lightuserdata_reg_key == &amp;<a class="code" href="wxlstate_8h.html#a034985fb7df51670c3b6a024329496fa">wxlua_lreg_evtcallbacks_key</a>)
<a name="l00383"></a>00383 {
<a name="l00384"></a>00384 <a class="code" href="classwxLuaEventCallback.html">wxLuaEventCallback</a>* wxlCallback = (<a class="code" href="classwxLuaEventCallback.html">wxLuaEventCallback</a>*)lua_touserdata(L, -2);
<a name="l00385"></a>00385 wxCHECK_MSG(wxlCallback, count, wxT(<span class="stringliteral">&quot;Invalid wxLuaEventCallback&quot;</span>));
<a name="l00386"></a>00386
<a name="l00387"></a>00387 wxString s(wxlCallback-&gt;<a class="code" href="classwxLuaEventCallback.html#a7d2dbf42ab8d4ddc22df1bd75ab095b6">GetInfo</a>());
<a name="l00388"></a>00388 name = s.BeforeFirst(wxT(<span class="charliteral">&#39;|&#39;</span>));
<a name="l00389"></a>00389 value = s.AfterFirst(wxT(<span class="charliteral">&#39;|&#39;</span>));
<a name="l00390"></a>00390 }
<a name="l00391"></a>00391 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (lightuserdata_reg_key == &amp;<a class="code" href="wxlstate_8h.html#ae13b14073477671929c41823f198c33d">wxlua_lreg_windestroycallbacks_key</a>)
<a name="l00392"></a>00392 {
<a name="l00393"></a>00393 <span class="comment">// only handle t[wxWindow*] = wxLuaWinDestroyCallback*</span>
<a name="l00394"></a>00394 <a class="code" href="classwxLuaWinDestroyCallback.html">wxLuaWinDestroyCallback</a>* wxlDestroyCallBack = (<a class="code" href="classwxLuaWinDestroyCallback.html">wxLuaWinDestroyCallback</a>*)lua_touserdata(L, -1);
<a name="l00395"></a>00395 wxCHECK_MSG(wxlDestroyCallBack, count, wxT(<span class="stringliteral">&quot;Invalid wxLuaWinDestroyCallback&quot;</span>));
<a name="l00396"></a>00396
<a name="l00397"></a>00397 wxString s(wxlDestroyCallBack-&gt;<a class="code" href="classwxLuaWinDestroyCallback.html#aa1ebb2002abc2ffc7d09c3c33a94e852">GetInfo</a>());
<a name="l00398"></a>00398 name = s.BeforeFirst(wxT(<span class="charliteral">&#39;|&#39;</span>));
<a name="l00399"></a>00399 value = s.AfterFirst(wxT(<span class="charliteral">&#39;|&#39;</span>));
<a name="l00400"></a>00400 }
<a name="l00401"></a>00401 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (lightuserdata_reg_key == &amp;<a class="code" href="wxlstate_8h.html#aab2351a78a8949184e1910cc1f9e7463">wxlua_lreg_topwindows_key</a>)
<a name="l00402"></a>00402 {
<a name="l00403"></a>00403 wxWindow* win = (wxWindow*)lua_touserdata(L, -2);
<a name="l00404"></a>00404 name += wxT(<span class="stringliteral">&quot; &quot;</span>) + wxString(win-&gt;GetClassInfo()-&gt;GetClassName());
<a name="l00405"></a>00405 }
<a name="l00406"></a>00406 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (lightuserdata_reg_key == &amp;<a class="code" href="wxlstate_8h.html#a7ec5afec8a64a29e28fefec4a1105790">wxlua_lreg_gcobjects_key</a>)
<a name="l00407"></a>00407 {
<a name="l00408"></a>00408 wxObject* obj = (wxObject*)lua_touserdata(L, -1);
<a name="l00409"></a>00409 name = wxString(obj-&gt;GetClassInfo()-&gt;GetClassName()) + wxT(<span class="stringliteral">&quot;(&quot;</span>) + name + wxT(<span class="stringliteral">&quot;)&quot;</span>);
<a name="l00410"></a>00410 }
<a name="l00411"></a>00411 }
<a name="l00412"></a>00412
<a name="l00413"></a>00413 <span class="comment">// For these keys we know what is in the value to give more information</span>
<a name="l00414"></a>00414 <span class="keywordflow">if</span> (lua_key_type == LUA_TLIGHTUSERDATA)
<a name="l00415"></a>00415 {
<a name="l00416"></a>00416 <span class="keywordtype">void</span>* key = lua_touserdata(L, -2);
<a name="l00417"></a>00417
<a name="l00418"></a>00418 <span class="keywordflow">if</span> (key == &amp;<a class="code" href="wxlstate_8h.html#a663c0f4ffbb1923edf3055b4c8c81ff9">wxlua_metatable_type_key</a>)
<a name="l00419"></a>00419 {
<a name="l00420"></a>00420 value += wxT(<span class="stringliteral">&quot; (&quot;</span>) + <a class="code" href="wxlstate_8h.html#a6621fa5a456448acfd515112aa7b23e1">wxluaT_typename</a>(L, (<span class="keywordtype">int</span>)lua_tonumber(L, -1)) + wxT(<span class="stringliteral">&quot;)&quot;</span>);
<a name="l00421"></a>00421 }
<a name="l00422"></a>00422 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key == &amp;<a class="code" href="wxlstate_8h.html#a8719cfeea23ebd1cb309de8296777da6">wxlua_metatable_wxluabindclass_key</a>)
<a name="l00423"></a>00423 {
<a name="l00424"></a>00424 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = (<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>*)lua_touserdata(L, -1);
<a name="l00425"></a>00425 value += <a class="code" href="wxldebug_8cpp.html#ac93374edd0c8b07e2597f4499bf05968">wxLuaBindClassString</a>(wxlClass);
<a name="l00426"></a>00426 }
<a name="l00427"></a>00427 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (key == &amp;<a class="code" href="wxlstate_8h.html#a30c2d5556a4a278368b48fe0b7bb3fda">wxlua_lreg_debug_refs_key</a>)
<a name="l00428"></a>00428 {
<a name="l00429"></a>00429 value += wxT(<span class="stringliteral">&quot; Note: You cannot traverse refed tables&quot;</span>);
<a name="l00430"></a>00430 }
<a name="l00431"></a>00431 }
<a name="l00432"></a>00432
<a name="l00433"></a>00433 <span class="comment">// ----------------------------------------------------------</span>
<a name="l00434"></a>00434 <span class="comment">// Handle the key</span>
<a name="l00435"></a>00435
<a name="l00436"></a>00436 <span class="keywordtype">int</span> key_flag_type = 0;
<a name="l00437"></a>00437 <span class="keywordtype">int</span> key_ref = LUA_NOREF;
<a name="l00438"></a>00438
<a name="l00439"></a>00439 <span class="comment">// don&#39;t ref anything in this table since it&#39;s already refed</span>
<a name="l00440"></a>00440 <span class="keywordflow">if</span> ((lua_key_type == LUA_TTABLE) &amp;&amp; (lightuserdata_reg_key != &amp;<a class="code" href="wxlstate_8h.html#a30c2d5556a4a278368b48fe0b7bb3fda">wxlua_lreg_debug_refs_key</a>))
<a name="l00441"></a>00441 key_ref = <a class="code" href="classwxLuaDebugData.html#a9aae4ae1c23f52643d0dcf26fd772983">RefTable</a>(L, -2, &amp;key_flag_type, <a class="code" href="wxldebug_8h.html#aa2fd8aa5a2d95cde0ea0be4691857235af057a953936ac6e00eca4983984a2eab">WXLUA_DEBUGITEM_KEY_REF</a>, references);
<a name="l00442"></a>00442 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (lua_key_type == LUA_TUSERDATA)
<a name="l00443"></a>00443 {
<a name="l00444"></a>00444 <span class="keywordflow">if</span> (lua_getmetatable(L, -2)) <span class="comment">// doesn&#39;t push anything if nil</span>
<a name="l00445"></a>00445 {
<a name="l00446"></a>00446 key_ref = <a class="code" href="classwxLuaDebugData.html#a9aae4ae1c23f52643d0dcf26fd772983">RefTable</a>(L, -2, &amp;key_flag_type, <a class="code" href="wxldebug_8h.html#aa2fd8aa5a2d95cde0ea0be4691857235af057a953936ac6e00eca4983984a2eab">WXLUA_DEBUGITEM_KEY_REF</a>, references);
<a name="l00447"></a>00447 lua_pop(L, 1);
<a name="l00448"></a>00448 }
<a name="l00449"></a>00449 }
<a name="l00450"></a>00450
<a name="l00451"></a>00451 <span class="comment">// only add the key if we refed it so it can be viewed in the stack dialog</span>
<a name="l00452"></a>00452 <span class="keywordflow">if</span> (key_flag_type != 0)
<a name="l00453"></a>00453 {
<a name="l00454"></a>00454 <a class="code" href="classwxLuaDebugData.html#a3daa718fdc572d507b084b014f729744">Add</a>(<span class="keyword">new</span> <a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a>(name, wxl_keytype, value, wxl_valuetype, wxT(<span class="stringliteral">&quot;&quot;</span>), key_ref, nIndex, key_flag_type));
<a name="l00455"></a>00455 ++count;
<a name="l00456"></a>00456 }
<a name="l00457"></a>00457
<a name="l00458"></a>00458 <span class="comment">// ----------------------------------------------------------</span>
<a name="l00459"></a>00459 <span class="comment">// Handle the value</span>
<a name="l00460"></a>00460
<a name="l00461"></a>00461 <span class="keywordtype">int</span> val_flag_type = 0;
<a name="l00462"></a>00462 <span class="keywordtype">int</span> val_ref = LUA_NOREF;
<a name="l00463"></a>00463
<a name="l00464"></a>00464 <span class="comment">// don&#39;t ref anything in this table since it&#39;s already refed</span>
<a name="l00465"></a>00465 <span class="keywordflow">if</span> ((lua_value_type == LUA_TTABLE) &amp;&amp; (lightuserdata_reg_key != &amp;<a class="code" href="wxlstate_8h.html#a30c2d5556a4a278368b48fe0b7bb3fda">wxlua_lreg_debug_refs_key</a>))
<a name="l00466"></a>00466 val_ref = <a class="code" href="classwxLuaDebugData.html#a9aae4ae1c23f52643d0dcf26fd772983">RefTable</a>(L, -1, &amp;val_flag_type, <a class="code" href="wxldebug_8h.html#aa2fd8aa5a2d95cde0ea0be4691857235ae399f7991ab5e948074483d0c65cc821">WXLUA_DEBUGITEM_VALUE_REF</a>, references);
<a name="l00467"></a>00467 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (lua_value_type == LUA_TUSERDATA)
<a name="l00468"></a>00468 {
<a name="l00469"></a>00469 <span class="keywordflow">if</span> (lua_getmetatable(L, -1)) <span class="comment">// doesn&#39;t push anything if nil</span>
<a name="l00470"></a>00470 {
<a name="l00471"></a>00471 val_ref = <a class="code" href="classwxLuaDebugData.html#a9aae4ae1c23f52643d0dcf26fd772983">RefTable</a>(L, -1, &amp;val_flag_type, <a class="code" href="wxldebug_8h.html#aa2fd8aa5a2d95cde0ea0be4691857235ae399f7991ab5e948074483d0c65cc821">WXLUA_DEBUGITEM_VALUE_REF</a>, references);
<a name="l00472"></a>00472 lua_pop(L, 1);
<a name="l00473"></a>00473 }
<a name="l00474"></a>00474 }
<a name="l00475"></a>00475
<a name="l00476"></a>00476 <span class="keywordflow">if</span> ((key_flag_type == 0) || ((key_flag_type != 0) &amp;&amp; (val_flag_type != 0)))
<a name="l00477"></a>00477 {
<a name="l00478"></a>00478 <a class="code" href="classwxLuaDebugData.html#a3daa718fdc572d507b084b014f729744">Add</a>(<span class="keyword">new</span> <a class="code" href="classwxLuaDebugItem.html">wxLuaDebugItem</a>(name, wxl_keytype, value, wxl_valuetype, wxT(<span class="stringliteral">&quot;&quot;</span>), val_ref, nIndex, val_flag_type));
<a name="l00479"></a>00479 ++count;
<a name="l00480"></a>00480 }
<a name="l00481"></a>00481
<a name="l00482"></a>00482 lua_pop(L, 1); <span class="comment">// pop value, leave key</span>
<a name="l00483"></a>00483 }
<a name="l00484"></a>00484 }
<a name="l00485"></a>00485
<a name="l00486"></a>00486 lua_pop(L, 1); <span class="comment">// remove reference</span>
<a name="l00487"></a>00487 }
<a name="l00488"></a>00488 }
<a name="l00489"></a>00489
<a name="l00490"></a>00490 <span class="keywordflow">return</span> count;
<a name="l00491"></a>00491 }
<a name="l00492"></a>00492
<a name="l00493"></a><a class="code" href="classwxLuaDebugData.html#a9aae4ae1c23f52643d0dcf26fd772983">00493</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaDebugData.html#a9aae4ae1c23f52643d0dcf26fd772983">wxLuaDebugData::RefTable</a>(lua_State* L, <span class="keywordtype">int</span> stack_idx, <span class="keywordtype">int</span>* flag_type, <span class="keywordtype">int</span> extra_flag, wxArrayInt&amp; references)
<a name="l00494"></a>00494 {
<a name="l00495"></a>00495 wxCHECK_MSG(L, LUA_NOREF, wxT(<span class="stringliteral">&quot;Invalid lua_State&quot;</span>));
<a name="l00496"></a>00496
<a name="l00497"></a>00497 <span class="keywordtype">int</span> lua_ref = LUA_NOREF;
<a name="l00498"></a>00498 <span class="comment">//if (lua_istable(L, stack_idx))</span>
<a name="l00499"></a>00499 {
<a name="l00500"></a>00500 <span class="comment">//nRef = wxluaR_isrefed(L, stack_idx, &amp;wxlua_lreg_debug_refs_key); // don&#39;t duplicate refs</span>
<a name="l00501"></a>00501
<a name="l00502"></a>00502 <span class="keywordflow">if</span> (lua_ref == LUA_NOREF)
<a name="l00503"></a>00503 {
<a name="l00504"></a>00504 <span class="keywordflow">if</span> (flag_type) *flag_type |= (<a class="code" href="wxldebug_8h.html#aa2fd8aa5a2d95cde0ea0be4691857235ab7413bafa0963e0ab72c04eafad0aa51">WXLUA_DEBUGITEM_IS_REFED</a> | extra_flag);
<a name="l00505"></a>00505 lua_ref = <a class="code" href="wxlstate_8h.html#acbf0a32ad4b828026bd7f643557646d0">wxluaR_ref</a>(L, stack_idx, &amp;<a class="code" href="wxlstate_8h.html#a30c2d5556a4a278368b48fe0b7bb3fda">wxlua_lreg_debug_refs_key</a>);
<a name="l00506"></a>00506 references.Add(lua_ref);
<a name="l00507"></a>00507 }
<a name="l00508"></a>00508 }
<a name="l00509"></a>00509
<a name="l00510"></a>00510 <span class="keywordflow">return</span> lua_ref;
<a name="l00511"></a>00511 }
<a name="l00512"></a>00512
<a name="l00513"></a><a class="code" href="classwxLuaDebugData.html#a30df4f18ac75a09adffd515f8d0db3c5">00513</a> <span class="keywordtype">int</span> <a class="code" href="classwxLuaDebugData.html#a30df4f18ac75a09adffd515f8d0db3c5">wxLuaDebugData::GetTypeValue</a>(<span class="keyword">const</span> <a class="code" href="classwxLuaState.html">wxLuaState</a>&amp; wxlState, <span class="keywordtype">int</span> stack_idx, <span class="keywordtype">int</span>* wxl_type_, wxString&amp; value)
<a name="l00514"></a>00514 {
<a name="l00515"></a>00515 wxCHECK_MSG(wxlState.<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
<a name="l00516"></a>00516
<a name="l00517"></a>00517 lua_State* L = wxlState.<a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">GetLuaState</a>();
<a name="l00518"></a>00518 <span class="keywordtype">int</span> l_type = lua_type(L, stack_idx);
<a name="l00519"></a>00519 <span class="keywordtype">int</span> wxl_type = <a class="code" href="wxlstate_8h.html#a00fa8bc9f668364c6a56b79a3d69738c">wxlua_luatowxluatype</a>(l_type);
<a name="l00520"></a>00520
<a name="l00521"></a>00521 <span class="keywordflow">if</span> (wxl_type_) *wxl_type_ = wxl_type;
<a name="l00522"></a>00522
<a name="l00523"></a>00523 <span class="keywordflow">switch</span> (l_type)
<a name="l00524"></a>00524 {
<a name="l00525"></a>00525 <span class="keywordflow">case</span> LUA_TNONE:
<a name="l00526"></a>00526 {
<a name="l00527"></a>00527 value = wxEmptyString;
<a name="l00528"></a>00528 <span class="keywordflow">break</span>;
<a name="l00529"></a>00529 }
<a name="l00530"></a>00530 <span class="keywordflow">case</span> LUA_TNIL:
<a name="l00531"></a>00531 {
<a name="l00532"></a>00532 value = wxT(<span class="stringliteral">&quot;nil&quot;</span>);
<a name="l00533"></a>00533 <span class="keywordflow">break</span>;
<a name="l00534"></a>00534 }
<a name="l00535"></a>00535 <span class="keywordflow">case</span> LUA_TBOOLEAN:
<a name="l00536"></a>00536 {
<a name="l00537"></a>00537 value = (lua_toboolean(L, stack_idx) != 0) ? wxT(<span class="stringliteral">&quot;true&quot;</span>) : wxT(<span class="stringliteral">&quot;false&quot;</span>);
<a name="l00538"></a>00538 <span class="keywordflow">break</span>;
<a name="l00539"></a>00539 }
<a name="l00540"></a>00540 <span class="keywordflow">case</span> LUA_TLIGHTUSERDATA:
<a name="l00541"></a>00541 {
<a name="l00542"></a>00542 value = <a class="code" href="classwxLuaDebugData.html#a2670b59fa3f280a60d5f686a9b7cead2">GetUserDataInfo</a>(wxlState, stack_idx, <span class="keyword">false</span>);
<a name="l00543"></a>00543 <span class="keywordflow">break</span>;
<a name="l00544"></a>00544 }
<a name="l00545"></a>00545 <span class="keywordflow">case</span> LUA_TNUMBER:
<a name="l00546"></a>00546 {
<a name="l00547"></a>00547 <span class="keywordtype">double</span> num = lua_tonumber(L, stack_idx);
<a name="l00548"></a>00548
<a name="l00549"></a>00549 <span class="keywordflow">if</span> ((<span class="keywordtype">long</span>)num == num)
<a name="l00550"></a>00550 value = wxString::Format(wxT(<span class="stringliteral">&quot;%ld (0x%lx)&quot;</span>), (<span class="keywordtype">long</span>)num, (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>)num);
<a name="l00551"></a>00551 <span class="keywordflow">else</span>
<a name="l00552"></a>00552 value = wxString::Format(wxT(<span class="stringliteral">&quot;%g&quot;</span>), num);
<a name="l00553"></a>00553
<a name="l00554"></a>00554 <span class="keywordflow">break</span>;
<a name="l00555"></a>00555 }
<a name="l00556"></a>00556 <span class="keywordflow">case</span> LUA_TSTRING:
<a name="l00557"></a>00557 {
<a name="l00558"></a>00558 value = <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(lua_tostring(L, stack_idx));
<a name="l00559"></a>00559 <span class="keywordflow">break</span>;
<a name="l00560"></a>00560 }
<a name="l00561"></a>00561 <span class="keywordflow">case</span> LUA_TTABLE:
<a name="l00562"></a>00562 {
<a name="l00563"></a>00563 value = <a class="code" href="classwxLuaDebugData.html#a035bef158f6149daa39ae8c2e50a55f3">GetTableInfo</a>(wxlState, stack_idx);
<a name="l00564"></a>00564 <span class="keywordflow">break</span>;
<a name="l00565"></a>00565 }
<a name="l00566"></a>00566 <span class="keywordflow">case</span> LUA_TFUNCTION:
<a name="l00567"></a>00567 {
<a name="l00568"></a>00568 value.Printf(wxT(<span class="stringliteral">&quot;%p&quot;</span>), lua_topointer(L, stack_idx));
<a name="l00569"></a>00569
<a name="l00570"></a>00570 <span class="keywordflow">if</span> (lua_iscfunction(L, stack_idx))
<a name="l00571"></a>00571 wxl_type = <a class="code" href="wxlbind_8h.html#a53115f4dba53cf577b8fd547b9ac874c">WXLUA_TCFUNCTION</a>;
<a name="l00572"></a>00572
<a name="l00573"></a>00573 <span class="keywordflow">break</span>;
<a name="l00574"></a>00574 }
<a name="l00575"></a>00575 <span class="keywordflow">case</span> LUA_TUSERDATA:
<a name="l00576"></a>00576 {
<a name="l00577"></a>00577 value = <a class="code" href="classwxLuaDebugData.html#a2670b59fa3f280a60d5f686a9b7cead2">GetUserDataInfo</a>(wxlState, stack_idx, <span class="keyword">true</span>);
<a name="l00578"></a>00578 <span class="keywordflow">break</span>;
<a name="l00579"></a>00579 }
<a name="l00580"></a>00580 <span class="keywordflow">case</span> LUA_TTHREAD:
<a name="l00581"></a>00581 {
<a name="l00582"></a>00582 value.Printf(wxT(<span class="stringliteral">&quot;%p&quot;</span>), lua_topointer(L, stack_idx));
<a name="l00583"></a>00583 <span class="keywordflow">break</span>;
<a name="l00584"></a>00584 }
<a name="l00585"></a>00585 <span class="keywordflow">default</span> :
<a name="l00586"></a>00586 {
<a name="l00587"></a>00587 value = wxEmptyString;
<a name="l00588"></a>00588 <span class="keywordflow">break</span>;
<a name="l00589"></a>00589 }
<a name="l00590"></a>00590 }
<a name="l00591"></a>00591
<a name="l00592"></a>00592 <span class="keywordflow">return</span> l_type;
<a name="l00593"></a>00593 }
<a name="l00594"></a>00594
<a name="l00595"></a><a class="code" href="classwxLuaDebugData.html#a035bef158f6149daa39ae8c2e50a55f3">00595</a> wxString <a class="code" href="classwxLuaDebugData.html#a035bef158f6149daa39ae8c2e50a55f3">wxLuaDebugData::GetTableInfo</a>(<span class="keyword">const</span> <a class="code" href="classwxLuaState.html">wxLuaState</a>&amp; wxlState, <span class="keywordtype">int</span> stack_idx)
<a name="l00596"></a>00596 {
<a name="l00597"></a>00597 wxCHECK_MSG(wxlState.<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
<a name="l00598"></a>00598 lua_State* L = wxlState.<a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">GetLuaState</a>();
<a name="l00599"></a>00599
<a name="l00600"></a>00600 <span class="keywordtype">int</span> wxl_type = <a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(L, stack_idx);
<a name="l00601"></a>00601 <span class="keywordtype">int</span> nItems = luaL_getn(L, stack_idx);
<a name="l00602"></a>00602 <span class="keyword">const</span> <span class="keywordtype">void</span> *pItem = lua_topointer(L, stack_idx);
<a name="l00603"></a>00603
<a name="l00604"></a>00604 wxString s(wxString::Format(wxT(<span class="stringliteral">&quot;%p&quot;</span>), pItem));
<a name="l00605"></a>00605
<a name="l00606"></a>00606 <span class="keywordflow">if</span> (nItems &gt; 0)
<a name="l00607"></a>00607 s += wxString::Format(wxT(<span class="stringliteral">&quot; (approx %d items)&quot;</span>), nItems);
<a name="l00608"></a>00608
<a name="l00609"></a>00609 <span class="keywordflow">if</span> (<a class="code" href="wxlbind_8h.html#ab26c2ec570e70f2f2b3ed9fa82afe24a">wxlua_iswxuserdatatype</a>(wxl_type))
<a name="l00610"></a>00610 s += wxString::Format(wxT(<span class="stringliteral">&quot; (wxltype %d)&quot;</span>), wxl_type);
<a name="l00611"></a>00611
<a name="l00612"></a>00612 <span class="keywordflow">return</span> s;
<a name="l00613"></a>00613 }
<a name="l00614"></a>00614
<a name="l00615"></a><a class="code" href="classwxLuaDebugData.html#a2670b59fa3f280a60d5f686a9b7cead2">00615</a> wxString <a class="code" href="classwxLuaDebugData.html#a2670b59fa3f280a60d5f686a9b7cead2">wxLuaDebugData::GetUserDataInfo</a>(<span class="keyword">const</span> <a class="code" href="classwxLuaState.html">wxLuaState</a>&amp; wxlState, <span class="keywordtype">int</span> stack_idx, <span class="keywordtype">bool</span> full_userdata)
<a name="l00616"></a>00616 {
<a name="l00617"></a>00617 wxCHECK_MSG(wxlState.<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
<a name="l00618"></a>00618 lua_State* L = wxlState.<a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">GetLuaState</a>();
<a name="l00619"></a>00619
<a name="l00620"></a>00620 <span class="keywordtype">void</span>* udata = lua_touserdata(L, stack_idx);
<a name="l00621"></a>00621
<a name="l00622"></a>00622 wxString s(wxString::Format(wxT(<span class="stringliteral">&quot;%p&quot;</span>), udata));
<a name="l00623"></a>00623
<a name="l00624"></a>00624 <span class="keywordflow">if</span> (!full_userdata)
<a name="l00625"></a>00625 {
<a name="l00626"></a>00626 <span class="comment">// Convert our known keys to something more readable</span>
<a name="l00627"></a>00627 <span class="keywordflow">if</span> ((udata == &amp;<a class="code" href="wxlstate_8h.html#a0ef6804bd2cb63f4fa705727f8871cbd">wxlua_lreg_types_key</a>) ||
<a name="l00628"></a>00628 (udata == &amp;<a class="code" href="wxlstate_8h.html#ac4ac0a3575fafde31e659ced85f69c4d">wxlua_lreg_refs_key</a>) ||
<a name="l00629"></a>00629 (udata == &amp;<a class="code" href="wxlstate_8h.html#a30c2d5556a4a278368b48fe0b7bb3fda">wxlua_lreg_debug_refs_key</a>) ||
<a name="l00630"></a>00630 (udata == &amp;<a class="code" href="wxlstate_8h.html#a0bcf696ed6d6e2b4218e9a8852a164ef">wxlua_lreg_classes_key</a>) ||
<a name="l00631"></a>00631 (udata == &amp;<a class="code" href="wxlstate_8h.html#a274b8b7aae6f647e3e69d098962b7b1d">wxlua_lreg_derivedmethods_key</a>) ||
<a name="l00632"></a>00632 (udata == &amp;<a class="code" href="wxlstate_8h.html#a921299ed63513972e3bda3678fc835c0">wxlua_lreg_wxluastate_key</a>) ||
<a name="l00633"></a>00633 (udata == &amp;<a class="code" href="wxlstate_8h.html#a80a0d4c84529abdcf6b46237431832ce">wxlua_lreg_wxluabindings_key</a>) ||
<a name="l00634"></a>00634 (udata == &amp;<a class="code" href="wxlstate_8h.html#af255531a04d81a0d82556c0d1fe8e7e7">wxlua_lreg_weakobjects_key</a>) ||
<a name="l00635"></a>00635 (udata == &amp;<a class="code" href="wxlstate_8h.html#a7ec5afec8a64a29e28fefec4a1105790">wxlua_lreg_gcobjects_key</a>) ||
<a name="l00636"></a>00636 (udata == &amp;<a class="code" href="wxlstate_8h.html#a034985fb7df51670c3b6a024329496fa">wxlua_lreg_evtcallbacks_key</a>) ||
<a name="l00637"></a>00637 (udata == &amp;<a class="code" href="wxlstate_8h.html#ae13b14073477671929c41823f198c33d">wxlua_lreg_windestroycallbacks_key</a>) ||
<a name="l00638"></a>00638 (udata == &amp;<a class="code" href="wxlstate_8h.html#a91d0a86787b3a1de5921590ce6a0b3e8">wxlua_lreg_callbaseclassfunc_key</a>) ||
<a name="l00639"></a>00639 (udata == &amp;<a class="code" href="wxlstate_8h.html#af24ccc441c899b3028cfc5d4099c739a">wxlua_lreg_wxeventtype_key</a>) ||
<a name="l00640"></a>00640 (udata == &amp;<a class="code" href="wxlstate_8h.html#aba1ad42faf08e4b50bca48b5ba9d8ece">wxlua_lreg_wxluastatedata_key</a>) ||
<a name="l00641"></a>00641 (udata == &amp;<a class="code" href="wxlstate_8h.html#ab84cb2515893ab069d7d165208e68aad">wxlua_lreg_regtable_key</a>) ||
<a name="l00642"></a>00642
<a name="l00643"></a>00643 (udata == &amp;<a class="code" href="wxlstate_8h.html#a663c0f4ffbb1923edf3055b4c8c81ff9">wxlua_metatable_type_key</a>) ||
<a name="l00644"></a>00644 (udata == &amp;<a class="code" href="wxlstate_8h.html#aab2351a78a8949184e1910cc1f9e7463">wxlua_lreg_topwindows_key</a>) ||
<a name="l00645"></a>00645 (udata == &amp;<a class="code" href="wxlstate_8h.html#a8719cfeea23ebd1cb309de8296777da6">wxlua_metatable_wxluabindclass_key</a>))
<a name="l00646"></a>00646 {
<a name="l00647"></a>00647 <span class="keyword">const</span> <span class="keywordtype">char</span>* ss = *(<span class="keyword">const</span> <span class="keywordtype">char</span>**)udata;
<a name="l00648"></a>00648 s += wxT(<span class="stringliteral">&quot; (&quot;</span>) + <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(ss) + wxT(<span class="stringliteral">&quot;)&quot;</span>);
<a name="l00649"></a>00649 }
<a name="l00650"></a>00650 }
<a name="l00651"></a>00651 <span class="keywordflow">else</span> <span class="comment">// is full userdata</span>
<a name="l00652"></a>00652 {
<a name="l00653"></a>00653 <span class="keywordtype">int</span> wxl_type = <a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(L, stack_idx);
<a name="l00654"></a>00654
<a name="l00655"></a>00655 <span class="keywordflow">if</span> (<a class="code" href="wxlbind_8h.html#ab26c2ec570e70f2f2b3ed9fa82afe24a">wxlua_iswxuserdatatype</a>(wxl_type))
<a name="l00656"></a>00656 {
<a name="l00657"></a>00657 s += wxString::Format(wxT(<span class="stringliteral">&quot; (wxltype %d)&quot;</span>), wxl_type);
<a name="l00658"></a>00658
<a name="l00659"></a>00659 wxString wxltypeName(<a class="code" href="wxlstate_8h.html#a6621fa5a456448acfd515112aa7b23e1">wxluaT_typename</a>(L, wxl_type));
<a name="l00660"></a>00660 <span class="keywordflow">if</span> (!wxltypeName.IsEmpty())
<a name="l00661"></a>00661 s += wxString::Format(wxT(<span class="stringliteral">&quot; &#39;%s&#39;&quot;</span>), wxltypeName.c_str());
<a name="l00662"></a>00662 }
<a name="l00663"></a>00663 }
<a name="l00664"></a>00664
<a name="l00665"></a>00665 <span class="keywordflow">return</span> s;
<a name="l00666"></a>00666 }
<a name="l00667"></a>00667
<a name="l00668"></a>00668 <span class="comment">// ----------------------------------------------------------------------------</span>
<a name="l00669"></a>00669 <span class="comment">// wxLuaCheckStack - dumps the contents of the lua_State</span>
<a name="l00670"></a>00670 <span class="comment">// ----------------------------------------------------------------------------</span>
<a name="l00671"></a>00671
<a name="l00672"></a><a class="code" href="classwxLuaCheckStack.html#a347922319e1ab71ce05b872986bd6abc">00672</a> <a class="code" href="classwxLuaCheckStack.html#a347922319e1ab71ce05b872986bd6abc">wxLuaCheckStack::wxLuaCheckStack</a>(lua_State *L, <span class="keyword">const</span> wxString &amp;msg, <span class="keywordtype">bool</span> print_to_console)
<a name="l00673"></a>00673 {
<a name="l00674"></a>00674 <a class="code" href="classwxLuaCheckStack.html#ab7664101ceb417bc348be64ff4e0f36e">m_luaState</a> = L;
<a name="l00675"></a>00675 <a class="code" href="classwxLuaCheckStack.html#a4df6d7bc293ab54ce349805f5fc6eff2">m_msg</a> = msg;
<a name="l00676"></a>00676 <a class="code" href="classwxLuaCheckStack.html#aba4ac87e55ef4d0897506e190ac1f445">m_top</a> = lua_gettop(<a class="code" href="classwxLuaCheckStack.html#ab7664101ceb417bc348be64ff4e0f36e">m_luaState</a>);
<a name="l00677"></a>00677 <a class="code" href="classwxLuaCheckStack.html#a45ca29a49e79a1b1e4422fa301c61709">m_print_to_console</a> = print_to_console;
<a name="l00678"></a>00678 }
<a name="l00679"></a>00679
<a name="l00680"></a><a class="code" href="classwxLuaCheckStack.html#ac1a97ccc7f89e39114f6bcc5e888e073">00680</a> <a class="code" href="classwxLuaCheckStack.html#ac1a97ccc7f89e39114f6bcc5e888e073">wxLuaCheckStack::~wxLuaCheckStack</a>()
<a name="l00681"></a>00681 {
<a name="l00682"></a>00682 <span class="keywordflow">if</span> (<a class="code" href="classwxLuaCheckStack.html#a45ca29a49e79a1b1e4422fa301c61709">m_print_to_console</a>)
<a name="l00683"></a>00683 <a class="code" href="classwxLuaCheckStack.html#a9a102a900fc54dcdfe8466521bb1b9e1">TestStack</a>(wxT(<span class="stringliteral">&quot;~wxLuaCheckStack&quot;</span>));
<a name="l00684"></a>00684 }
<a name="l00685"></a>00685
<a name="l00686"></a><a class="code" href="classwxLuaCheckStack.html#a9a102a900fc54dcdfe8466521bb1b9e1">00686</a> wxString <a class="code" href="classwxLuaCheckStack.html#a9a102a900fc54dcdfe8466521bb1b9e1">wxLuaCheckStack::TestStack</a>(<span class="keyword">const</span> wxString &amp;msg)
<a name="l00687"></a>00687 {
<a name="l00688"></a>00688 wxString s;
<a name="l00689"></a>00689 s.Printf(wxT(<span class="stringliteral">&quot;wxLuaCheckStack::TestStack(L=%p) &#39;%s&#39;:&#39;%s&#39;: starting top %d ending top %d\n&quot;</span>),
<a name="l00690"></a>00690 <a class="code" href="classwxLuaCheckStack.html#ab7664101ceb417bc348be64ff4e0f36e">m_luaState</a>, <a class="code" href="classwxLuaCheckStack.html#a4df6d7bc293ab54ce349805f5fc6eff2">m_msg</a>.c_str(), msg.c_str(), <a class="code" href="classwxLuaCheckStack.html#aba4ac87e55ef4d0897506e190ac1f445">m_top</a>, lua_gettop(<a class="code" href="classwxLuaCheckStack.html#ab7664101ceb417bc348be64ff4e0f36e">m_luaState</a>));
<a name="l00691"></a>00691
<a name="l00692"></a>00692 <span class="keywordflow">if</span> (<a class="code" href="classwxLuaCheckStack.html#aba4ac87e55ef4d0897506e190ac1f445">m_top</a> != lua_gettop(<a class="code" href="classwxLuaCheckStack.html#ab7664101ceb417bc348be64ff4e0f36e">m_luaState</a>)) s += wxT(<span class="stringliteral">&quot; **********&quot;</span>); <span class="comment">// easy to find</span>
<a name="l00693"></a>00693
<a name="l00694"></a>00694 <a class="code" href="classwxLuaCheckStack.html#a0b18f919a3e8ca44dfa98b5bf9c12d31">OutputMsg</a>(s);
<a name="l00695"></a>00695
<a name="l00696"></a>00696 <span class="keywordflow">return</span> s;
<a name="l00697"></a>00697 }
<a name="l00698"></a>00698
<a name="l00699"></a><a class="code" href="classwxLuaCheckStack.html#a909d40b28074bac4e94f1176052b25d4">00699</a> wxString <a class="code" href="classwxLuaCheckStack.html#a909d40b28074bac4e94f1176052b25d4">wxLuaCheckStack::DumpStack</a>(<span class="keyword">const</span> wxString&amp; msg)
<a name="l00700"></a>00700 {
<a name="l00701"></a>00701 wxCHECK_MSG(<a class="code" href="classwxLuaCheckStack.html#ab7664101ceb417bc348be64ff4e0f36e">m_luaState</a>, wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid lua_State&quot;</span>));
<a name="l00702"></a>00702
<a name="l00703"></a>00703 lua_State* L = <a class="code" href="classwxLuaCheckStack.html#ab7664101ceb417bc348be64ff4e0f36e">m_luaState</a>;
<a name="l00704"></a>00704 <span class="keywordtype">int</span> i, count = lua_gettop(L);
<a name="l00705"></a>00705 wxString str;
<a name="l00706"></a>00706 wxString retStr;
<a name="l00707"></a>00707
<a name="l00708"></a>00708 str.Printf(wxT(<span class="stringliteral">&quot;wxLuaCheckStack::DumpStack(L=%p), &#39;%s&#39;:&#39;%s&#39;, items %d, starting top %d\n&quot;</span>), L, <a class="code" href="classwxLuaCheckStack.html#a4df6d7bc293ab54ce349805f5fc6eff2">m_msg</a>.c_str(), msg.c_str(), count, <a class="code" href="classwxLuaCheckStack.html#aba4ac87e55ef4d0897506e190ac1f445">m_top</a>);
<a name="l00709"></a>00709 retStr += str;
<a name="l00710"></a>00710 <a class="code" href="classwxLuaCheckStack.html#a0b18f919a3e8ca44dfa98b5bf9c12d31">OutputMsg</a>(str);
<a name="l00711"></a>00711
<a name="l00712"></a>00712 <a class="code" href="classwxLuaState.html">wxLuaState</a> wxlState(L);
<a name="l00713"></a>00713
<a name="l00714"></a>00714 <span class="keywordflow">for</span> (i = 1; i &lt;= count; i++)
<a name="l00715"></a>00715 {
<a name="l00716"></a>00716 <span class="keywordtype">int</span> wxl_type = 0;
<a name="l00717"></a>00717 wxString value;
<a name="l00718"></a>00718 <span class="keywordtype">int</span> l_type = <a class="code" href="classwxLuaDebugData.html#a30df4f18ac75a09adffd515f8d0db3c5">wxLuaDebugData::GetTypeValue</a>(wxlState, i, &amp;wxl_type, value);
<a name="l00719"></a>00719
<a name="l00720"></a>00720 str.Printf(wxT(<span class="stringliteral">&quot; idx %d: l_type = %d, wxl_type = %d : &#39;%s&#39;=&#39;%s&#39;\n&quot;</span>),
<a name="l00721"></a>00721 i, l_type, wxl_type, <a class="code" href="wxlstate_8h.html#a6621fa5a456448acfd515112aa7b23e1">wxluaT_typename</a>(L, wxl_type).c_str(), value.c_str());
<a name="l00722"></a>00722 retStr += str;
<a name="l00723"></a>00723 <a class="code" href="classwxLuaCheckStack.html#a0b18f919a3e8ca44dfa98b5bf9c12d31">OutputMsg</a>(str);
<a name="l00724"></a>00724 }
<a name="l00725"></a>00725
<a name="l00726"></a>00726 <span class="keywordflow">return</span> retStr;
<a name="l00727"></a>00727 }
<a name="l00728"></a>00728
<a name="l00729"></a><a class="code" href="classwxLuaCheckStack.html#a3ae9be598a588fe19db2203595ff0aa3">00729</a> wxString <a class="code" href="classwxLuaCheckStack.html#a3ae9be598a588fe19db2203595ff0aa3">wxLuaCheckStack::DumpGlobals</a>(<span class="keyword">const</span> wxString&amp; msg)
<a name="l00730"></a>00730 {
<a name="l00731"></a>00731 wxCHECK_MSG(<a class="code" href="classwxLuaCheckStack.html#ab7664101ceb417bc348be64ff4e0f36e">m_luaState</a>, wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid lua_State&quot;</span>));
<a name="l00732"></a>00732
<a name="l00733"></a>00733 wxSortedArrayString tableArray;
<a name="l00734"></a>00734
<a name="l00735"></a>00735 <span class="keywordflow">return</span> <a class="code" href="classwxLuaCheckStack.html#a87a2b6fe078db3bdacca8164e16bf058">DumpTable</a>(LUA_GLOBALSINDEX, wxT(<span class="stringliteral">&quot;Globals&quot;</span>), msg, tableArray, 0);
<a name="l00736"></a>00736 }
<a name="l00737"></a>00737
<a name="l00738"></a><a class="code" href="classwxLuaCheckStack.html#a87a2b6fe078db3bdacca8164e16bf058">00738</a> wxString <a class="code" href="classwxLuaCheckStack.html#a87a2b6fe078db3bdacca8164e16bf058">wxLuaCheckStack::DumpTable</a>(<span class="keyword">const</span> wxString &amp;tablename, <span class="keyword">const</span> wxString&amp; msg)
<a name="l00739"></a>00739 {
<a name="l00740"></a>00740 wxCHECK_MSG(<a class="code" href="classwxLuaCheckStack.html#ab7664101ceb417bc348be64ff4e0f36e">m_luaState</a>, wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid lua_State&quot;</span>));
<a name="l00741"></a>00741
<a name="l00742"></a>00742 lua_State* L = <a class="code" href="classwxLuaCheckStack.html#ab7664101ceb417bc348be64ff4e0f36e">m_luaState</a>;
<a name="l00743"></a>00743 wxSortedArrayString tableArray;
<a name="l00744"></a>00744 wxString s;
<a name="l00745"></a>00745
<a name="l00746"></a>00746 <span class="comment">// Allow iteration through table1.table2.table3...</span>
<a name="l00747"></a>00747 wxString tname(tablename);
<a name="l00748"></a>00748 lua_pushvalue(L, LUA_GLOBALSINDEX);
<a name="l00749"></a>00749
<a name="l00750"></a>00750 <span class="keywordflow">do</span> {
<a name="l00751"></a>00751 lua_pushstring(L, <a class="code" href="wxlstate_8h.html#a41976a7549ef4bfa7e9a1147dc7b4d55">wx2lua</a>(tname.BeforeFirst(wxT(<span class="charliteral">&#39;.&#39;</span>))));
<a name="l00752"></a>00752 lua_rawget(L, -2);
<a name="l00753"></a>00753
<a name="l00754"></a>00754 <span class="keywordflow">if</span> (lua_isnil(L, -1) || !lua_istable(L, -1))
<a name="l00755"></a>00755 {
<a name="l00756"></a>00756 lua_pop(L, 2); <span class="comment">// remove table and value</span>
<a name="l00757"></a>00757
<a name="l00758"></a>00758 s.Printf(wxT(<span class="stringliteral">&quot;wxLuaCheckStack::DumpTable(L=%p) Table: &#39;%s&#39; cannot be found!\n&quot;</span>), L, tablename.c_str());
<a name="l00759"></a>00759 <a class="code" href="classwxLuaCheckStack.html#a0b18f919a3e8ca44dfa98b5bf9c12d31">OutputMsg</a>(s);
<a name="l00760"></a>00760 <span class="keywordflow">return</span> s;
<a name="l00761"></a>00761 }
<a name="l00762"></a>00762
<a name="l00763"></a>00763 lua_remove(L, -2); <span class="comment">// remove previous table</span>
<a name="l00764"></a>00764 tname = tname.AfterFirst(wxT(<span class="charliteral">&#39;.&#39;</span>));
<a name="l00765"></a>00765 } <span class="keywordflow">while</span> (tname.Len() &gt; 0);
<a name="l00766"></a>00766
<a name="l00767"></a>00767 s = <a class="code" href="classwxLuaCheckStack.html#a87a2b6fe078db3bdacca8164e16bf058">DumpTable</a>(lua_gettop(L), tablename, msg, tableArray, 0);
<a name="l00768"></a>00768 lua_pop(L, 1);
<a name="l00769"></a>00769
<a name="l00770"></a>00770 <span class="keywordflow">return</span> s;
<a name="l00771"></a>00771 }
<a name="l00772"></a>00772
<a name="l00773"></a><a class="code" href="classwxLuaCheckStack.html#a1fc022591277887f69681f721f538a92">00773</a> wxString <a class="code" href="classwxLuaCheckStack.html#a87a2b6fe078db3bdacca8164e16bf058">wxLuaCheckStack::DumpTable</a>(<span class="keywordtype">int</span> stack_idx, <span class="keyword">const</span> wxString&amp; msg)
<a name="l00774"></a>00774 {
<a name="l00775"></a>00775 wxCHECK_MSG(<a class="code" href="classwxLuaCheckStack.html#ab7664101ceb417bc348be64ff4e0f36e">m_luaState</a>, wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid lua_State&quot;</span>));
<a name="l00776"></a>00776
<a name="l00777"></a>00777 wxSortedArrayString tableArray;
<a name="l00778"></a>00778
<a name="l00779"></a>00779 <span class="keywordflow">return</span> <a class="code" href="classwxLuaCheckStack.html#a87a2b6fe078db3bdacca8164e16bf058">DumpTable</a>(stack_idx, wxString::Format(wxT(<span class="stringliteral">&quot;StackIdx=%d&quot;</span>), stack_idx), msg, tableArray, 0);
<a name="l00780"></a>00780 }
<a name="l00781"></a>00781
<a name="l00782"></a><a class="code" href="classwxLuaCheckStack.html#ad3aeccf29295712be56183dfd32edede">00782</a> wxString <a class="code" href="classwxLuaCheckStack.html#a87a2b6fe078db3bdacca8164e16bf058">wxLuaCheckStack::DumpTable</a>(<span class="keywordtype">int</span> stack_idx, <span class="keyword">const</span> wxString&amp; tablename, <span class="keyword">const</span> wxString&amp; msg, wxSortedArrayString&amp; tableArray, <span class="keywordtype">int</span> indent)
<a name="l00783"></a>00783 {
<a name="l00784"></a>00784 wxCHECK_MSG(<a class="code" href="classwxLuaCheckStack.html#ab7664101ceb417bc348be64ff4e0f36e">m_luaState</a>, wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid lua_State&quot;</span>));
<a name="l00785"></a>00785
<a name="l00786"></a>00786 lua_State* L = <a class="code" href="classwxLuaCheckStack.html#ab7664101ceb417bc348be64ff4e0f36e">m_luaState</a>;
<a name="l00787"></a>00787 <a class="code" href="classwxLuaState.html">wxLuaState</a> wxlState(L);
<a name="l00788"></a>00788 wxString indentStr;
<a name="l00789"></a>00789 wxString s;
<a name="l00790"></a>00790
<a name="l00791"></a>00791 <span class="comment">// We only do tables, return error message</span>
<a name="l00792"></a>00792 <span class="keywordflow">if</span> (!lua_istable(L, stack_idx))
<a name="l00793"></a>00793 {
<a name="l00794"></a>00794 s.Printf(wxT(<span class="stringliteral">&quot;wxLuaCheckStack::DumpTable(L=%p) stack idx %d is not a table.\n&quot;</span>), L, stack_idx);
<a name="l00795"></a>00795 <a class="code" href="classwxLuaCheckStack.html#a0b18f919a3e8ca44dfa98b5bf9c12d31">OutputMsg</a>(s);
<a name="l00796"></a>00796 <span class="keywordflow">return</span> s;
<a name="l00797"></a>00797 }
<a name="l00798"></a>00798
<a name="l00799"></a>00799 <span class="keywordflow">if</span> (indent == 0)
<a name="l00800"></a>00800 {
<a name="l00801"></a>00801 <span class="comment">// First time through print header</span>
<a name="l00802"></a>00802 s.Printf(wxT(<span class="stringliteral">&quot;wxLuaCheckStack::DumpTable(L=%p) Table: &#39;%s&#39;\n&quot;</span>), L, tablename.c_str());
<a name="l00803"></a>00803 <a class="code" href="classwxLuaCheckStack.html#a0b18f919a3e8ca44dfa98b5bf9c12d31">OutputMsg</a>(s);
<a name="l00804"></a>00804 }
<a name="l00805"></a>00805 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (indent &gt; 10)
<a name="l00806"></a>00806 {
<a name="l00807"></a>00807 <span class="comment">// Don&#39;t let things get out of hand...</span>
<a name="l00808"></a>00808 s.Printf(wxT(<span class="stringliteral">&quot;wxLuaCheckStack::DumpTable(L=%p) Table depth &gt; 10! Truncating: &#39;%s&#39;\n&quot;</span>), L, tablename.c_str());
<a name="l00809"></a>00809 <a class="code" href="classwxLuaCheckStack.html#a0b18f919a3e8ca44dfa98b5bf9c12d31">OutputMsg</a>(s);
<a name="l00810"></a>00810 <span class="keywordflow">return</span> s;
<a name="l00811"></a>00811 }
<a name="l00812"></a>00812 <span class="keywordflow">else</span>
<a name="l00813"></a>00813 {
<a name="l00814"></a>00814 indentStr = wxString(wxT(<span class="charliteral">&#39; &#39;</span>), indent*2) + wxT(<span class="stringliteral">&quot;&gt;&quot;</span>);
<a name="l00815"></a>00815 }
<a name="l00816"></a>00816
<a name="l00817"></a>00817 wxString title = wxString::Format(wxT(<span class="stringliteral">&quot;%sTable Level %d : name &#39;%s&#39;\n&quot;</span>), indentStr.c_str(), indent, tablename.c_str());
<a name="l00818"></a>00818 s += title;
<a name="l00819"></a>00819 <a class="code" href="classwxLuaCheckStack.html#a0b18f919a3e8ca44dfa98b5bf9c12d31">OutputMsg</a>(title);
<a name="l00820"></a>00820
<a name="l00821"></a>00821 lua_pushvalue(L, stack_idx); <span class="comment">// push the table to read the top of the stack</span>
<a name="l00822"></a>00822
<a name="l00823"></a>00823 lua_pushnil(L);
<a name="l00824"></a>00824 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
<a name="l00825"></a>00825 {
<a name="l00826"></a>00826 <span class="keywordtype">int</span> keyType = 0, valueType = 0;
<a name="l00827"></a>00827 wxString key, value;
<a name="l00828"></a>00828
<a name="l00829"></a>00829 <a class="code" href="classwxLuaDebugData.html#a30df4f18ac75a09adffd515f8d0db3c5">wxLuaDebugData::GetTypeValue</a>(wxlState, -2, &amp;keyType, key);
<a name="l00830"></a>00830 <a class="code" href="classwxLuaDebugData.html#a30df4f18ac75a09adffd515f8d0db3c5">wxLuaDebugData::GetTypeValue</a>(wxlState, -1, &amp;valueType, value);
<a name="l00831"></a>00831
<a name="l00832"></a>00832 wxString info = wxString::Format(wxT(<span class="stringliteral">&quot;%s%-32s\t%-16s\t%-20s\t%-16s\n&quot;</span>),
<a name="l00833"></a>00833 indentStr.c_str(), key.c_str(), <a class="code" href="wxlstate_8h.html#a6621fa5a456448acfd515112aa7b23e1">wxluaT_typename</a>(L, keyType).c_str(), value.c_str(), <a class="code" href="wxlstate_8h.html#a6621fa5a456448acfd515112aa7b23e1">wxluaT_typename</a>(L, valueType).c_str());
<a name="l00834"></a>00834 s += info;
<a name="l00835"></a>00835 <a class="code" href="classwxLuaCheckStack.html#a0b18f919a3e8ca44dfa98b5bf9c12d31">OutputMsg</a>(info);
<a name="l00836"></a>00836
<a name="l00837"></a>00837 <span class="keywordflow">if</span> (tableArray.Index(value) == wxNOT_FOUND)
<a name="l00838"></a>00838 {
<a name="l00839"></a>00839 <span class="keywordflow">if</span> (valueType == <a class="code" href="wxlbind_8h.html#ab80aed8ef4eafc8ab9479e39597330ff">WXLUA_TTABLE</a>)
<a name="l00840"></a>00840 {
<a name="l00841"></a>00841 tableArray.Add(value);
<a name="l00842"></a>00842 s += <a class="code" href="classwxLuaCheckStack.html#a87a2b6fe078db3bdacca8164e16bf058">DumpTable</a>(lua_gettop(L), tablename + wxT(<span class="stringliteral">&quot;.&quot;</span>) + key, msg, tableArray, indent+1);
<a name="l00843"></a>00843 }
<a name="l00844"></a>00844 <span class="keywordflow">else</span>
<a name="l00845"></a>00845 {
<a name="l00846"></a>00846 tableArray.Add(value);
<a name="l00847"></a>00847 }
<a name="l00848"></a>00848 }
<a name="l00849"></a>00849
<a name="l00850"></a>00850 lua_pop(L, 1); <span class="comment">// pop value</span>
<a name="l00851"></a>00851 }
<a name="l00852"></a>00852
<a name="l00853"></a>00853 lua_pop(L, 1); <span class="comment">// pop pushed table</span>
<a name="l00854"></a>00854
<a name="l00855"></a>00855 <span class="keywordflow">return</span> s;
<a name="l00856"></a>00856 }
<a name="l00857"></a>00857
<a name="l00858"></a><a class="code" href="classwxLuaCheckStack.html#a0b18f919a3e8ca44dfa98b5bf9c12d31">00858</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaCheckStack.html#a0b18f919a3e8ca44dfa98b5bf9c12d31">wxLuaCheckStack::OutputMsg</a>(<span class="keyword">const</span> wxString&amp; msg)<span class="keyword"> const</span>
<a name="l00859"></a>00859 <span class="keyword"></span>{
<a name="l00860"></a>00860 <span class="keywordflow">if</span> (<a class="code" href="classwxLuaCheckStack.html#a45ca29a49e79a1b1e4422fa301c61709">m_print_to_console</a>)
<a name="l00861"></a>00861 {
<a name="l00862"></a>00862 <span class="preprocessor">#if defined(__WXMSW__)</span>
<a name="l00863"></a>00863 <span class="preprocessor"></span> <span class="comment">//OutputDebugString(msg.c_str());</span>
<a name="l00864"></a>00864 wxPrintf(wxT(<span class="stringliteral">&quot;%s&quot;</span>), msg.c_str()); fflush(stdout);
<a name="l00865"></a>00865 <span class="preprocessor">#else //if defined(__WXGTK__) || defined(__WXMAC__)</span>
<a name="l00866"></a>00866 <span class="preprocessor"></span> wxPrintf(wxT(<span class="stringliteral">&quot;%s&quot;</span>), msg.c_str());
<a name="l00867"></a>00867 <span class="preprocessor">#endif</span>
<a name="l00868"></a>00868 <span class="preprocessor"></span> }
<a name="l00869"></a>00869 }
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Tue Jul 13 10:30:39 2010 for wxLua by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>