PageRenderTime 83ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/Lua/5.1/docs/wxlua/doxygen/html/wxlbind_8cpp_source.html

https://github.com/SuigetsuSake/Hyperion
HTML | 1743 lines | 1742 code | 0 blank | 1 comment | 0 complexity | ca00bc03f680828c5f33d5c00b72403d MD5 | raw file
Possible License(s): GPL-2.0, CC-BY-SA-3.0, LGPL-3.0, BSD-3-Clause, ISC, LGPL-2.0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <title>wxLua: /mnt/share/devel/lua/wxLua/modules/wxlua/src/wxlbind.cpp Source File</title>
  6. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  7. <link href="doxygen.css" rel="stylesheet" type="text/css"/>
  8. </head>
  9. <body>
  10. <!-- Generated by Doxygen 1.6.3 -->
  11. <div class="navigation" id="top">
  12. <div class="tabs">
  13. <ul>
  14. <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
  15. <li><a href="annotated.html"><span>Classes</span></a></li>
  16. <li class="current"><a href="files.html"><span>Files</span></a></li>
  17. <li><a href="dirs.html"><span>Directories</span></a></li>
  18. </ul>
  19. </div>
  20. <div class="tabs">
  21. <ul>
  22. <li><a href="files.html"><span>File&nbsp;List</span></a></li>
  23. <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
  24. </ul>
  25. </div>
  26. <div class="navpath"><a class="el" href="dir_15d5a205ad383328522db6a6be296af1.html">modules</a>&nbsp;&raquo;&nbsp;<a class="el" href="dir_b59b58daa92d206701e75411b2cef894.html">wxlua</a>&nbsp;&raquo;&nbsp;<a class="el" href="dir_83fe9eb5cda99cf12108735ec0aac68a.html">src</a>
  27. </div>
  28. </div>
  29. <div class="contents">
  30. <h1>wxlbind.cpp</h1><a href="wxlbind_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/////////////////////////////////////////////////////////////////////////////</span>
  31. <a name="l00002"></a>00002 <span class="comment"></span><span class="comment">// Name: wxlbind.cpp</span>
  32. <a name="l00003"></a>00003 <span class="comment">// Purpose: wxLuaBinding</span>
  33. <a name="l00004"></a>00004 <span class="comment">// Author: Ray Gilbert, John Labenski, J Winwood</span>
  34. <a name="l00005"></a>00005 <span class="comment">// Created: 14/11/2001</span>
  35. <a name="l00006"></a>00006 <span class="comment">// Copyright:</span>
  36. <a name="l00007"></a>00007 <span class="comment">// Licence: wxWidgets licence</span><span class="comment"></span>
  37. <a name="l00008"></a>00008 <span class="comment">/////////////////////////////////////////////////////////////////////////////</span>
  38. <a name="l00009"></a>00009 <span class="comment"></span>
  39. <a name="l00010"></a>00010 <span class="preprocessor">#include &quot;wx/wxprec.h&quot;</span>
  40. <a name="l00011"></a>00011
  41. <a name="l00012"></a>00012 <span class="preprocessor">#ifdef __BORLANDC__</span>
  42. <a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor"> #pragma hdrstop</span>
  43. <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
  44. <a name="l00015"></a>00015 <span class="preprocessor"></span>
  45. <a name="l00016"></a>00016 <span class="preprocessor">#ifndef WX_PRECOMP</span>
  46. <a name="l00017"></a>00017 <span class="preprocessor"></span><span class="preprocessor"> #include &quot;wx/wx.h&quot;</span>
  47. <a name="l00018"></a>00018 <span class="preprocessor">#endif</span>
  48. <a name="l00019"></a>00019 <span class="preprocessor"></span>
  49. <a name="l00020"></a>00020 <span class="preprocessor">#include &quot;<a class="code" href="wxlbind_8h.html">wxlua/include/wxlbind.h</a>&quot;</span>
  50. <a name="l00021"></a>00021 <span class="preprocessor">#include &quot;<a class="code" href="wxlstate_8h.html">wxlua/include/wxlstate.h</a>&quot;</span>
  51. <a name="l00022"></a>00022
  52. <a name="l00023"></a>00023 <span class="comment">//#include &quot;wxluadebug/include/wxldebug.h&quot; // for debugging only</span>
  53. <a name="l00024"></a>00024
  54. <a name="l00025"></a>00025 <span class="keyword">const</span> <a class="code" href="classwxLuaSmartwxArrayString.html">wxLuaSmartwxArrayString</a> <a class="code" href="wxlbind_8cpp.html#a4baa5ce581fadd929eb289c7fbd24f60">wxLuaNullSmartwxArrayString</a>(NULL, <span class="keyword">true</span>);
  55. <a name="l00026"></a>00026
  56. <a name="l00027"></a>00027
  57. <a name="l00028"></a>00028 <span class="preprocessor">#include &quot;wx/listimpl.cpp&quot;</span>
  58. <a name="l00029"></a>00029 <a class="code" href="wxlbind_8cpp.html#af9a4bfc065dccc9fd724c54ce387d58a">WX_DEFINE_LIST</a>(wxLuaBindingList);
  59. <a name="l00030"></a>00030
  60. <a name="l00031"></a><a class="code" href="wxlbind_8cpp.html#a58f9a9bbfe42fe5e81fee9f0457979eb">00031</a> <a class="code" href="wxlbind_8h.html#a6628a536d11950b5d99cc6ba3a2e648d">wxLuaArgType</a> <a class="code" href="wxlbind_8cpp.html#a58f9a9bbfe42fe5e81fee9f0457979eb">g_wxluaargtypeArray_None</a>[1] = {0};
  61. <a name="l00032"></a><a class="code" href="wxlbind_8cpp.html#aeedafe804443572a91f5aae7920d104c">00032</a> <a class="code" href="structwxLuaBindNumber.html">wxLuaBindNumber</a> <a class="code" href="wxlbind_8cpp.html#aeedafe804443572a91f5aae7920d104c">g_wxluanumberArray_None</a>[1] = {{0, 0}};
  62. <a name="l00033"></a>00033
  63. <a name="l00034"></a><a class="code" href="wxlbind_8cpp.html#af5f263fe0cee2a78592733f73302fae1">00034</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#af5f263fe0cee2a78592733f73302fae1">wxluatype_TNONE</a> = <a class="code" href="wxlbind_8h.html#ab1ffe83879cd856390708161cbc49e8d">WXLUA_TNONE</a>;
  64. <a name="l00035"></a><a class="code" href="wxlbind_8cpp.html#af0a3e5a0826b83f55975eacc7c80b8ca">00035</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#af0a3e5a0826b83f55975eacc7c80b8ca">wxluatype_TNIL</a> = <a class="code" href="wxlbind_8h.html#a1ab3b990ed46ff3d8986e5b0fb7ab2fb">WXLUA_TNIL</a>;
  65. <a name="l00036"></a><a class="code" href="wxlbind_8cpp.html#af7c54f1e394057d09b7b271636653753">00036</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#af7c54f1e394057d09b7b271636653753">wxluatype_TBOOLEAN</a> = <a class="code" href="wxlbind_8h.html#a458b772ab1522825ff3199d8fba34df7">WXLUA_TBOOLEAN</a>;
  66. <a name="l00037"></a><a class="code" href="wxlbind_8cpp.html#aa158468a14a90d8a6737ca543640ac14">00037</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#aa158468a14a90d8a6737ca543640ac14">wxluatype_TLIGHTUSERDATA</a> = <a class="code" href="wxlbind_8h.html#af997ec3f0137737b21fa6eb91aca9529">WXLUA_TLIGHTUSERDATA</a>; <span class="comment">// raw data</span>
  67. <a name="l00038"></a><a class="code" href="wxlbind_8cpp.html#a81fefe100b8c874aed225be14c2e9417">00038</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#a81fefe100b8c874aed225be14c2e9417">wxluatype_TNUMBER</a> = <a class="code" href="wxlbind_8h.html#ab722ed662e4f3b7f2624d9a71f5c5817">WXLUA_TNUMBER</a>;
  68. <a name="l00039"></a><a class="code" href="wxlbind_8cpp.html#ae60ba1eadfdbaf4619e81584e91e4bf9">00039</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#ae60ba1eadfdbaf4619e81584e91e4bf9">wxluatype_TSTRING</a> = <a class="code" href="wxlbind_8h.html#a2e521227720c7b42b9fe076b1e944405">WXLUA_TSTRING</a>;
  69. <a name="l00040"></a><a class="code" href="wxlbind_8cpp.html#aca7f4ac5f81a3a709b9ff59e6a7fe4f2">00040</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#aca7f4ac5f81a3a709b9ff59e6a7fe4f2">wxluatype_TTABLE</a> = <a class="code" href="wxlbind_8h.html#ab80aed8ef4eafc8ab9479e39597330ff">WXLUA_TTABLE</a>;
  70. <a name="l00041"></a><a class="code" href="wxlbind_8cpp.html#a3f41bf1821df901b75de9a611e3359ff">00041</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#a3f41bf1821df901b75de9a611e3359ff">wxluatype_TFUNCTION</a> = <a class="code" href="wxlbind_8h.html#ad1ad6ff2d60457dfb1251faede683dd7">WXLUA_TFUNCTION</a>;
  71. <a name="l00042"></a><a class="code" href="wxlbind_8cpp.html#aec66ef9de5ef7604a15cdefa946862e2">00042</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#aec66ef9de5ef7604a15cdefa946862e2">wxluatype_TUSERDATA</a> = <a class="code" href="wxlbind_8h.html#af70988ad845289f3b60451dce70d9622">WXLUA_TUSERDATA</a>; <span class="comment">// raw data</span>
  72. <a name="l00043"></a><a class="code" href="wxlbind_8cpp.html#a812d9d9119aafb925e733145bf882083">00043</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#a812d9d9119aafb925e733145bf882083">wxluatype_TTHREAD</a> = <a class="code" href="wxlbind_8h.html#af26c97cbb42bdb22bc85a245bd93c6a4">WXLUA_TTHREAD</a>;
  73. <a name="l00044"></a><a class="code" href="wxlbind_8cpp.html#ad182e2a1f29a3bfaf24f1347255bbab3">00044</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#ad182e2a1f29a3bfaf24f1347255bbab3">wxluatype_TINTEGER</a> = <a class="code" href="wxlbind_8h.html#a58050f86cf4136d7b81371ac367313c0">WXLUA_TINTEGER</a>;
  74. <a name="l00045"></a><a class="code" href="wxlbind_8cpp.html#a340c49e631b9d2b6a0790094c72b5583">00045</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#a340c49e631b9d2b6a0790094c72b5583">wxluatype_TCFUNCTION</a> = <a class="code" href="wxlbind_8h.html#a53115f4dba53cf577b8fd547b9ac874c">WXLUA_TCFUNCTION</a>;
  75. <a name="l00046"></a>00046
  76. <a name="l00047"></a><a class="code" href="wxlbind_8cpp.html#ada2f84390e66116604bfa8d5102c7305">00047</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#ada2f84390e66116604bfa8d5102c7305">wxluatype_NULL</a> = <a class="code" href="wxlbind_8h.html#aabdfd967ae93eab0c0e15363480a47d4">WXLUATYPE_NULL</a>;
  77. <a name="l00048"></a>00048
  78. <a name="l00049"></a><a class="code" href="wxlbind_8cpp.html#a4aa9b7bff8761a6fb183f52ad9d35fdf">00049</a> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> <a class="code" href="wxlbind_8cpp.html#a4aa9b7bff8761a6fb183f52ad9d35fdf">wxLuaBindClass_NULL</a> =
  79. <a name="l00050"></a>00050 { <span class="stringliteral">&quot;NULL&quot;</span>, NULL, 0, NULL, &amp;<a class="code" href="wxlbind_8cpp.html#ada2f84390e66116604bfa8d5102c7305">wxluatype_NULL</a>, NULL, NULL, g_wxluanumberArray_None, 0, };
  80. <a name="l00051"></a>00051
  81. <a name="l00052"></a><a class="code" href="wxlbind_8cpp.html#a9a97abe73c432582f2b448e147114369">00052</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#a9a97abe73c432582f2b448e147114369">wxluatype_dummy</a> = <a class="code" href="wxlbind_8h.html#aeb150b964405f526ef77087288f403b2">WXLUA_TUNKNOWN</a>;
  82. <a name="l00053"></a><a class="code" href="wxlbind_8cpp.html#aea95a7e5610e8d338700175ede7e8b28">00053</a> <span class="keywordtype">int</span>* <a class="code" href="wxlbind_8cpp.html#aea95a7e5610e8d338700175ede7e8b28">p_wxluatype_wxEvent</a> = &amp;<a class="code" href="wxlbind_8cpp.html#a9a97abe73c432582f2b448e147114369">wxluatype_dummy</a>;
  83. <a name="l00054"></a><a class="code" href="wxlbind_8cpp.html#a39c4487f5ea5ac7d668d2f6db931970e">00054</a> <span class="keywordtype">int</span>* <a class="code" href="wxlbind_8cpp.html#a39c4487f5ea5ac7d668d2f6db931970e">p_wxluatype_wxWindow</a> = &amp;<a class="code" href="wxlbind_8cpp.html#a9a97abe73c432582f2b448e147114369">wxluatype_dummy</a>;
  84. <a name="l00055"></a><a class="code" href="wxlbind_8cpp.html#a4d788db68e87954d09dd58ea30df0cd3">00055</a> <span class="keywordtype">int</span>* <a class="code" href="wxlbind_8cpp.html#a4d788db68e87954d09dd58ea30df0cd3">p_wxluatype_wxString</a> = &amp;<a class="code" href="wxlbind_8cpp.html#a9a97abe73c432582f2b448e147114369">wxluatype_dummy</a>;
  85. <a name="l00056"></a><a class="code" href="wxlbind_8cpp.html#a37763c7807d701968783c17c455750e6">00056</a> <span class="keywordtype">int</span>* <a class="code" href="wxlbind_8cpp.html#a37763c7807d701968783c17c455750e6">p_wxluatype_wxArrayString</a> = &amp;<a class="code" href="wxlbind_8cpp.html#a9a97abe73c432582f2b448e147114369">wxluatype_dummy</a>;
  86. <a name="l00057"></a><a class="code" href="wxlbind_8cpp.html#a7e0bab1cb372c8c3e28edff2f7318c11">00057</a> <span class="keywordtype">int</span>* <a class="code" href="wxlbind_8cpp.html#a7e0bab1cb372c8c3e28edff2f7318c11">p_wxluatype_wxSortedArrayString</a> = &amp;<a class="code" href="wxlbind_8cpp.html#a9a97abe73c432582f2b448e147114369">wxluatype_dummy</a>;
  87. <a name="l00058"></a><a class="code" href="wxlbind_8cpp.html#a61aa9300e2dc84511689a6254869b90a">00058</a> <span class="keywordtype">int</span>* <a class="code" href="wxlbind_8cpp.html#a61aa9300e2dc84511689a6254869b90a">p_wxluatype_wxArrayInt</a> = &amp;<a class="code" href="wxlbind_8cpp.html#a9a97abe73c432582f2b448e147114369">wxluatype_dummy</a>;
  88. <a name="l00059"></a>00059
  89. <a name="l00060"></a>00060 <span class="comment">//-----------------------------------------------------------------------------</span>
  90. <a name="l00061"></a>00061 <span class="comment">// wxLuaObject</span>
  91. <a name="l00062"></a>00062 <span class="comment">//-----------------------------------------------------------------------------</span>
  92. <a name="l00063"></a>00063 <a class="code" href="wxlsock_8cpp.html#abdcf9eaaef19410a688aa559de382a29">IMPLEMENT_ABSTRACT_CLASS</a>(<a class="code" href="classwxLuaObject.html">wxLuaObject</a>, wxObject)
  93. <a name="l00064"></a>00064
  94. <a name="l00065"></a><a class="code" href="classwxLuaObject.html#a236992c153ec85c21ff603ee49caa357">00065</a> <a class="code" href="classwxLuaObject.html">wxLuaObject</a>::<a class="code" href="classwxLuaObject.html">wxLuaObject</a>(const <a class="code" href="classwxLuaState.html">wxLuaState</a>&amp; wxlState, <span class="keywordtype">int</span> stack_idx)
  95. <a name="l00066"></a>00066 : m_wxlState(new <a class="code" href="classwxLuaState.html">wxLuaState</a>(wxlState)),
  96. <a name="l00067"></a>00067 m_alloc_flag(<a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfa8f955b2e461c9e96f95d73f0aaec859b">wxLUAOBJECT_NONE</a>),
  97. <a name="l00068"></a>00068 m_int(0) <span class="comment">// GCC only wants one initializer</span>
  98. <a name="l00069"></a>00069
  99. <a name="l00070"></a>00070 {
  100. <a name="l00071"></a>00071 <span class="comment">// set up the reference to the item on the stack</span>
  101. <a name="l00072"></a>00072 m_reference = m_wxlState-&gt;wxluaR_Ref(stack_idx, &amp;<a class="code" href="wxlstate_8h.html#ac4ac0a3575fafde31e659ced85f69c4d">wxlua_lreg_refs_key</a>);
  102. <a name="l00073"></a>00073 }
  103. <a name="l00074"></a>00074
  104. <a name="l00075"></a><a class="code" href="classwxLuaObject.html#af44313c118636e4b865147a67e45ea7c">00075</a> <a class="code" href="classwxLuaObject.html#af44313c118636e4b865147a67e45ea7c">wxLuaObject::~wxLuaObject</a>()
  105. <a name="l00076"></a>00076 {
  106. <a name="l00077"></a>00077 <span class="keywordflow">if</span> (<a class="code" href="classwxLuaObject.html#a064c813719cee2323935b0a5e5b9a79e">m_alloc_flag</a> == <a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfac1db50f4f3602c7ce03b673abe8b7a5b">wxLUAOBJECT_STRING</a>)
  107. <a name="l00078"></a>00078 <span class="keyword">delete</span> <a class="code" href="classwxLuaObject.html#ac6ac832aa0cd2ffd10688b7c434edd65">m_string</a>;
  108. <a name="l00079"></a>00079 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classwxLuaObject.html#a064c813719cee2323935b0a5e5b9a79e">m_alloc_flag</a> == <a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfa4215ed6a9b518a32ca425c67f02e4c89">wxLUAOBJECT_ARRAYINT</a>)
  109. <a name="l00080"></a>00080 <span class="keyword">delete</span> <a class="code" href="classwxLuaObject.html#a77d115bfe6e815d2c32a0ced02caa80d">m_arrayInt</a>;
  110. <a name="l00081"></a>00081
  111. <a name="l00082"></a>00082 <span class="comment">// If a refererence exists, remove it, but don&#39;t bother if Lua is being closed</span>
  112. <a name="l00083"></a>00083 <span class="keywordflow">if</span> ((<a class="code" href="classwxLuaObject.html#ad87ca9b958d11a4104c3b99ae8f40f24">m_reference</a> != LUA_NOREF) &amp;&amp; <a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>() &amp;&amp; !<a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#afa5bd7f676094317e2a0c383344be837">IsClosing</a>())
  113. <a name="l00084"></a>00084 <a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a26d311d6ee816331696ec18b4b1ee1d4">wxluaR_Unref</a>(<a class="code" href="classwxLuaObject.html#ad87ca9b958d11a4104c3b99ae8f40f24">m_reference</a>, &amp;<a class="code" href="wxlstate_8h.html#ac4ac0a3575fafde31e659ced85f69c4d">wxlua_lreg_refs_key</a>);
  114. <a name="l00085"></a>00085
  115. <a name="l00086"></a>00086 <span class="keyword">delete</span> <a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>;
  116. <a name="l00087"></a>00087 }
  117. <a name="l00088"></a>00088
  118. <a name="l00089"></a><a class="code" href="classwxLuaObject.html#af92b783348584e687bfa2be06a562de4">00089</a> <a class="code" href="classwxLuaState.html">wxLuaState</a> <a class="code" href="classwxLuaObject.html#af92b783348584e687bfa2be06a562de4">wxLuaObject::GetwxLuaState</a>()<span class="keyword"> const</span>
  119. <a name="l00090"></a>00090 <span class="keyword"></span>{
  120. <a name="l00091"></a>00091 <span class="keywordflow">return</span> (<a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a> != NULL) ? *<a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a> : <a class="code" href="wxlstate_8h.html#aef06b6591011cd68b9e370d5e702d255">wxNullLuaState</a>;
  121. <a name="l00092"></a>00092 }
  122. <a name="l00093"></a>00093
  123. <a name="l00094"></a><a class="code" href="classwxLuaObject.html#a69d337ef87de7bde2aecb8abda72a627">00094</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaObject.html#a69d337ef87de7bde2aecb8abda72a627">wxLuaObject::GetObject</a>()
  124. <a name="l00095"></a>00095 {
  125. <a name="l00096"></a>00096 wxCHECK_MSG(<a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  126. <a name="l00097"></a>00097 lua_State* L = <a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">GetLuaState</a>();
  127. <a name="l00098"></a>00098
  128. <a name="l00099"></a>00099 <span class="keywordflow">if</span> (<a class="code" href="classwxLuaObject.html#a064c813719cee2323935b0a5e5b9a79e">m_alloc_flag</a> == <a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfadb667a5361aa792e6b837550027b9cb3">wxLUAOBJECT_BOOL</a>)
  129. <a name="l00100"></a>00100 {
  130. <a name="l00101"></a>00101 lua_pushboolean(L, <a class="code" href="classwxLuaObject.html#abf7637c571f1d23141b68e7af49008ef">m_bool</a>);
  131. <a name="l00102"></a>00102 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  132. <a name="l00103"></a>00103 }
  133. <a name="l00104"></a>00104 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classwxLuaObject.html#a064c813719cee2323935b0a5e5b9a79e">m_alloc_flag</a> == <a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfa54f1c3e616d8452eb4ea92a9f0e68381">wxLUAOBJECT_INT</a>)
  134. <a name="l00105"></a>00105 {
  135. <a name="l00106"></a>00106 lua_pushnumber(L, <a class="code" href="classwxLuaObject.html#a1e9cdce919b0bf09c80d13a75fd2f570">m_int</a>);
  136. <a name="l00107"></a>00107 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  137. <a name="l00108"></a>00108 }
  138. <a name="l00109"></a>00109 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classwxLuaObject.html#a064c813719cee2323935b0a5e5b9a79e">m_alloc_flag</a> == <a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfac1db50f4f3602c7ce03b673abe8b7a5b">wxLUAOBJECT_STRING</a>)
  139. <a name="l00110"></a>00110 {
  140. <a name="l00111"></a>00111 lua_pushstring(L, <a class="code" href="wxlstate_8h.html#a41976a7549ef4bfa7e9a1147dc7b4d55">wx2lua</a>(*<a class="code" href="classwxLuaObject.html#ac6ac832aa0cd2ffd10688b7c434edd65">m_string</a>));
  141. <a name="l00112"></a>00112 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  142. <a name="l00113"></a>00113 }
  143. <a name="l00114"></a>00114 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classwxLuaObject.html#a064c813719cee2323935b0a5e5b9a79e">m_alloc_flag</a> == <a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfa4215ed6a9b518a32ca425c67f02e4c89">wxLUAOBJECT_ARRAYINT</a>)
  144. <a name="l00115"></a>00115 {
  145. <a name="l00116"></a>00116 <a class="code" href="wxlstate_8h.html#a75ae92f66c6689bad6470f689a7d190d">wxlua_pushwxArrayInttable</a>(L, *<a class="code" href="classwxLuaObject.html#a77d115bfe6e815d2c32a0ced02caa80d">m_arrayInt</a>);
  146. <a name="l00117"></a>00117 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  147. <a name="l00118"></a>00118 }
  148. <a name="l00119"></a>00119 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#ae7108b396d79179f517a7dc478c2cb43">wxluaR_getref</a>(L, <a class="code" href="classwxLuaObject.html#ad87ca9b958d11a4104c3b99ae8f40f24">m_reference</a>, &amp;<a class="code" href="wxlstate_8h.html#ac4ac0a3575fafde31e659ced85f69c4d">wxlua_lreg_refs_key</a>))
  149. <a name="l00120"></a>00120 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  150. <a name="l00121"></a>00121
  151. <a name="l00122"></a>00122 <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// nothing on the stack</span>
  152. <a name="l00123"></a>00123 }
  153. <a name="l00124"></a>00124
  154. <a name="l00125"></a><a class="code" href="classwxLuaObject.html#aa6d798c4d51d4a8b0385a9d60e0db465">00125</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaObject.html#aa6d798c4d51d4a8b0385a9d60e0db465">wxLuaObject::SetObject</a>(<span class="keywordtype">int</span> stack_idx)
  155. <a name="l00126"></a>00126 {
  156. <a name="l00127"></a>00127 wxCHECK_RET(<a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  157. <a name="l00128"></a>00128
  158. <a name="l00129"></a>00129 <span class="keywordflow">if</span> (<a class="code" href="classwxLuaObject.html#ad87ca9b958d11a4104c3b99ae8f40f24">m_reference</a> != LUA_NOREF) <span class="comment">// FIXME should this error out?</span>
  159. <a name="l00130"></a>00130 <a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a26d311d6ee816331696ec18b4b1ee1d4">wxluaR_Unref</a>(<a class="code" href="classwxLuaObject.html#ad87ca9b958d11a4104c3b99ae8f40f24">m_reference</a>, &amp;<a class="code" href="wxlstate_8h.html#ac4ac0a3575fafde31e659ced85f69c4d">wxlua_lreg_refs_key</a>);
  160. <a name="l00131"></a>00131
  161. <a name="l00132"></a>00132 <a class="code" href="classwxLuaObject.html#ad87ca9b958d11a4104c3b99ae8f40f24">m_reference</a> = <a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a1c041e98055317fdcb53f23e3e2172e2">wxluaR_Ref</a>(stack_idx, &amp;<a class="code" href="wxlstate_8h.html#ac4ac0a3575fafde31e659ced85f69c4d">wxlua_lreg_refs_key</a>);
  162. <a name="l00133"></a>00133 }
  163. <a name="l00134"></a>00134
  164. <a name="l00135"></a><a class="code" href="classwxLuaObject.html#a7ac8e85a0f07e3bd58ebf65a8981f78f">00135</a> <span class="keywordtype">bool</span> *<a class="code" href="classwxLuaObject.html#a7ac8e85a0f07e3bd58ebf65a8981f78f">wxLuaObject::GetBoolPtr</a>()
  165. <a name="l00136"></a>00136 {
  166. <a name="l00137"></a>00137 wxCHECK_MSG(<a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  167. <a name="l00138"></a>00138 wxCHECK_MSG(<a class="code" href="classwxLuaObject.html#a064c813719cee2323935b0a5e5b9a79e">m_alloc_flag</a> == <a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfa8f955b2e461c9e96f95d73f0aaec859b">wxLUAOBJECT_NONE</a>, 0, wxT(<span class="stringliteral">&quot;wxLuaObject already initialized in wxLuaObject::GetBoolPtr&quot;</span>));
  168. <a name="l00139"></a>00139
  169. <a name="l00140"></a>00140 <span class="keywordflow">if</span> ((<a class="code" href="classwxLuaObject.html#ad87ca9b958d11a4104c3b99ae8f40f24">m_reference</a> != LUA_NOREF) &amp;&amp; <a class="code" href="classwxLuaObject.html#a69d337ef87de7bde2aecb8abda72a627">GetObject</a>())
  170. <a name="l00141"></a>00141 {
  171. <a name="l00142"></a>00142 <a class="code" href="classwxLuaObject.html#abf7637c571f1d23141b68e7af49008ef">m_bool</a> = (<a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a4605560f02821b53977cdb3a43e0ba98">lua_ToBoolean</a>(-1) != 0);
  172. <a name="l00143"></a>00143 <a class="code" href="classwxLuaObject.html#a064c813719cee2323935b0a5e5b9a79e">m_alloc_flag</a> = <a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfadb667a5361aa792e6b837550027b9cb3">wxLUAOBJECT_BOOL</a>;
  173. <a name="l00144"></a>00144 <a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a2efa05a8ce69d8344c5ea14b4fe02bf0">lua_Pop</a>(1);
  174. <a name="l00145"></a>00145 }
  175. <a name="l00146"></a>00146 <span class="keywordflow">return</span> &amp;<a class="code" href="classwxLuaObject.html#abf7637c571f1d23141b68e7af49008ef">m_bool</a>;
  176. <a name="l00147"></a>00147 }
  177. <a name="l00148"></a>00148
  178. <a name="l00149"></a><a class="code" href="classwxLuaObject.html#aee91890e4208f13b4cf5e0c47e48f1c5">00149</a> <span class="keywordtype">int</span> *<a class="code" href="classwxLuaObject.html#aee91890e4208f13b4cf5e0c47e48f1c5">wxLuaObject::GetIntPtr</a>()
  179. <a name="l00150"></a>00150 {
  180. <a name="l00151"></a>00151 wxCHECK_MSG(<a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  181. <a name="l00152"></a>00152 wxCHECK_MSG(<a class="code" href="classwxLuaObject.html#a064c813719cee2323935b0a5e5b9a79e">m_alloc_flag</a> == <a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfa8f955b2e461c9e96f95d73f0aaec859b">wxLUAOBJECT_NONE</a>, 0, wxT(<span class="stringliteral">&quot;wxLuaObject already initialized in wxLuaObject::GetIntPtr&quot;</span>));
  182. <a name="l00153"></a>00153
  183. <a name="l00154"></a>00154 <span class="keywordflow">if</span> ((<a class="code" href="classwxLuaObject.html#ad87ca9b958d11a4104c3b99ae8f40f24">m_reference</a> != LUA_NOREF) &amp;&amp; <a class="code" href="classwxLuaObject.html#a69d337ef87de7bde2aecb8abda72a627">GetObject</a>())
  184. <a name="l00155"></a>00155 {
  185. <a name="l00156"></a>00156 <a class="code" href="classwxLuaObject.html#a1e9cdce919b0bf09c80d13a75fd2f570">m_int</a> = (int)<a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#aa75554592cae272aec0d8242a2d0725a">lua_ToNumber</a>(-1);
  186. <a name="l00157"></a>00157 <a class="code" href="classwxLuaObject.html#a064c813719cee2323935b0a5e5b9a79e">m_alloc_flag</a> = <a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfa54f1c3e616d8452eb4ea92a9f0e68381">wxLUAOBJECT_INT</a>;
  187. <a name="l00158"></a>00158 <a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a2efa05a8ce69d8344c5ea14b4fe02bf0">lua_Pop</a>(1);
  188. <a name="l00159"></a>00159 }
  189. <a name="l00160"></a>00160 <span class="keywordflow">return</span> &amp;<a class="code" href="classwxLuaObject.html#a1e9cdce919b0bf09c80d13a75fd2f570">m_int</a>;
  190. <a name="l00161"></a>00161 }
  191. <a name="l00162"></a>00162
  192. <a name="l00163"></a><a class="code" href="classwxLuaObject.html#a29f1ddca87d1fc7b23562baa0ec5f567">00163</a> wxString *<a class="code" href="classwxLuaObject.html#a29f1ddca87d1fc7b23562baa0ec5f567">wxLuaObject::GetStringPtr</a>()
  193. <a name="l00164"></a>00164 {
  194. <a name="l00165"></a>00165 wxCHECK_MSG(<a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  195. <a name="l00166"></a>00166 wxCHECK_MSG(<a class="code" href="classwxLuaObject.html#a064c813719cee2323935b0a5e5b9a79e">m_alloc_flag</a> == <a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfa8f955b2e461c9e96f95d73f0aaec859b">wxLUAOBJECT_NONE</a>, 0, wxT(<span class="stringliteral">&quot;wxLuaObject already initialized in wxLuaObject::GetStringPtr&quot;</span>));
  196. <a name="l00167"></a>00167
  197. <a name="l00168"></a>00168 <a class="code" href="classwxLuaObject.html#ac6ac832aa0cd2ffd10688b7c434edd65">m_string</a> = <span class="keyword">new</span> wxString(); <span class="comment">// create valid string for return</span>
  198. <a name="l00169"></a>00169
  199. <a name="l00170"></a>00170 <span class="keywordflow">if</span> ((<a class="code" href="classwxLuaObject.html#ad87ca9b958d11a4104c3b99ae8f40f24">m_reference</a> != LUA_NOREF) &amp;&amp; <a class="code" href="classwxLuaObject.html#a69d337ef87de7bde2aecb8abda72a627">GetObject</a>())
  200. <a name="l00171"></a>00171 {
  201. <a name="l00172"></a>00172 *<a class="code" href="classwxLuaObject.html#ac6ac832aa0cd2ffd10688b7c434edd65">m_string</a> = <a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#aa1e2a352d7eea7def33de09573f3f2b5">lua_TowxString</a>(-1);
  202. <a name="l00173"></a>00173 <a class="code" href="classwxLuaObject.html#a064c813719cee2323935b0a5e5b9a79e">m_alloc_flag</a> = <a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfac1db50f4f3602c7ce03b673abe8b7a5b">wxLUAOBJECT_STRING</a>;
  203. <a name="l00174"></a>00174 <a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a2efa05a8ce69d8344c5ea14b4fe02bf0">lua_Pop</a>(1);
  204. <a name="l00175"></a>00175 }
  205. <a name="l00176"></a>00176
  206. <a name="l00177"></a>00177 <span class="keywordflow">return</span> <a class="code" href="classwxLuaObject.html#ac6ac832aa0cd2ffd10688b7c434edd65">m_string</a>;
  207. <a name="l00178"></a>00178 }
  208. <a name="l00179"></a>00179
  209. <a name="l00180"></a><a class="code" href="classwxLuaObject.html#a7a4f92a4070a3d4138afded0cb753425">00180</a> wxArrayInt *<a class="code" href="classwxLuaObject.html#a7a4f92a4070a3d4138afded0cb753425">wxLuaObject::GetArrayPtr</a>()
  210. <a name="l00181"></a>00181 {
  211. <a name="l00182"></a>00182 wxCHECK_MSG(<a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  212. <a name="l00183"></a>00183 wxCHECK_MSG(<a class="code" href="classwxLuaObject.html#a064c813719cee2323935b0a5e5b9a79e">m_alloc_flag</a> == <a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfa8f955b2e461c9e96f95d73f0aaec859b">wxLUAOBJECT_NONE</a>, 0, wxT(<span class="stringliteral">&quot;wxLuaObject already initialized in wxLuaObject::GetArrayPtr&quot;</span>));
  213. <a name="l00184"></a>00184
  214. <a name="l00185"></a>00185 <a class="code" href="classwxLuaObject.html#a77d115bfe6e815d2c32a0ced02caa80d">m_arrayInt</a> = <span class="keyword">new</span> wxArrayInt(); <span class="comment">// create valid array for return</span>
  215. <a name="l00186"></a>00186
  216. <a name="l00187"></a>00187 <span class="keywordflow">if</span> ((<a class="code" href="classwxLuaObject.html#ad87ca9b958d11a4104c3b99ae8f40f24">m_reference</a> != LUA_NOREF) &amp;&amp; <a class="code" href="classwxLuaObject.html#a69d337ef87de7bde2aecb8abda72a627">GetObject</a>())
  217. <a name="l00188"></a>00188 {
  218. <a name="l00189"></a>00189 *<a class="code" href="classwxLuaObject.html#a77d115bfe6e815d2c32a0ced02caa80d">m_arrayInt</a> = (wxArrayInt&amp;)<a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a8bdaaaa42d76dfc8b0ea9548b386b892">GetwxArrayInt</a>(-1); <span class="comment">// coerce wxLuaSmartwxArrayInt</span>
  219. <a name="l00190"></a>00190 <a class="code" href="classwxLuaObject.html#a064c813719cee2323935b0a5e5b9a79e">m_alloc_flag</a> = <a class="code" href="wxlbind_8h.html#a2053b3aabbe621ca574012e7d61084dfa4215ed6a9b518a32ca425c67f02e4c89">wxLUAOBJECT_ARRAYINT</a>;
  220. <a name="l00191"></a>00191 <a class="code" href="classwxLuaObject.html#a355594c657ebe65dc62c7195a4c87004">m_wxlState</a>-&gt;<a class="code" href="classwxLuaState.html#a2efa05a8ce69d8344c5ea14b4fe02bf0">lua_Pop</a>(1);
  221. <a name="l00192"></a>00192 }
  222. <a name="l00193"></a>00193 <span class="keywordflow">return</span> <a class="code" href="classwxLuaObject.html#a77d115bfe6e815d2c32a0ced02caa80d">m_arrayInt</a>;
  223. <a name="l00194"></a>00194 }
  224. <a name="l00195"></a>00195
  225. <a name="l00196"></a>00196 <span class="comment">// ----------------------------------------------------------------------------</span>
  226. <a name="l00197"></a>00197 <span class="comment">// wxLuaSmartwxArrayString</span>
  227. <a name="l00198"></a>00198 <span class="comment">// ----------------------------------------------------------------------------</span>
  228. <a name="l00199"></a>00199
  229. <a name="l00200"></a><a class="code" href="classwxLuaSmartwxArrayStringRefData.html">00200</a> <span class="keyword">class </span><a class="code" href="classwxLuaSmartwxArrayStringRefData.html">wxLuaSmartwxArrayStringRefData</a> : <span class="keyword">public</span> wxObjectRefData
  230. <a name="l00201"></a>00201 {
  231. <a name="l00202"></a>00202 <span class="keyword">public</span>:
  232. <a name="l00203"></a><a class="code" href="classwxLuaSmartwxArrayStringRefData.html#a82e823e2589230c383674024f933efc1">00203</a> <a class="code" href="classwxLuaSmartwxArrayStringRefData.html#a82e823e2589230c383674024f933efc1">wxLuaSmartwxArrayStringRefData</a>(wxArrayString* arr, <span class="keywordtype">int</span> del) : <a class="code" href="classwxLuaSmartwxArrayStringRefData.html#af8f8a6be04ffca8da6b8e5dce524a375">m_arr</a>(arr), <a class="code" href="classwxLuaSmartwxArrayStringRefData.html#af03cbcb0edb536fb4588d1a68f5123ff">m_delete</a>(del)
  233. <a name="l00204"></a>00204 {
  234. <a name="l00205"></a>00205 <span class="keywordflow">if</span> (!<a class="code" href="classwxLuaSmartwxArrayStringRefData.html#af8f8a6be04ffca8da6b8e5dce524a375">m_arr</a>) { <a class="code" href="classwxLuaSmartwxArrayStringRefData.html#af8f8a6be04ffca8da6b8e5dce524a375">m_arr</a> = <span class="keyword">new</span> wxArrayString; <a class="code" href="classwxLuaSmartwxArrayStringRefData.html#af03cbcb0edb536fb4588d1a68f5123ff">m_delete</a> = <span class="keyword">true</span>; } <span class="comment">// always exists</span>
  235. <a name="l00206"></a>00206 }
  236. <a name="l00207"></a>00207
  237. <a name="l00208"></a><a class="code" href="classwxLuaSmartwxArrayStringRefData.html#a4c13b637fab902ade42ca8677b01c89f">00208</a> <span class="keyword">virtual</span> <a class="code" href="classwxLuaSmartwxArrayStringRefData.html#a4c13b637fab902ade42ca8677b01c89f">~wxLuaSmartwxArrayStringRefData</a>() { <span class="keywordflow">if</span> (<a class="code" href="classwxLuaSmartwxArrayStringRefData.html#af03cbcb0edb536fb4588d1a68f5123ff">m_delete</a>) <span class="keyword">delete</span> <a class="code" href="classwxLuaSmartwxArrayStringRefData.html#af8f8a6be04ffca8da6b8e5dce524a375">m_arr</a>; }
  238. <a name="l00209"></a>00209
  239. <a name="l00210"></a><a class="code" href="classwxLuaSmartwxArrayStringRefData.html#af8f8a6be04ffca8da6b8e5dce524a375">00210</a> wxArrayString *<a class="code" href="classwxLuaSmartwxArrayStringRefData.html#af8f8a6be04ffca8da6b8e5dce524a375">m_arr</a>;
  240. <a name="l00211"></a><a class="code" href="classwxLuaSmartwxArrayStringRefData.html#af03cbcb0edb536fb4588d1a68f5123ff">00211</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaSmartwxArrayStringRefData.html#af03cbcb0edb536fb4588d1a68f5123ff">m_delete</a>;
  241. <a name="l00212"></a>00212 };
  242. <a name="l00213"></a>00213
  243. <a name="l00214"></a><a class="code" href="classwxLuaSmartwxArrayString.html#a20fd2d8d4f2f8a283de9cf6ecd96653e">00214</a> <a class="code" href="classwxLuaSmartwxArrayString.html#ab5dcf6ee0df0bca0b5ab202a3900d163">wxLuaSmartwxArrayString::wxLuaSmartwxArrayString</a>(wxArrayString *arr, <span class="keywordtype">bool</span> del)
  244. <a name="l00215"></a>00215 {
  245. <a name="l00216"></a>00216 m_refData = <span class="keyword">new</span> <a class="code" href="classwxLuaSmartwxArrayStringRefData.html">wxLuaSmartwxArrayStringRefData</a>(arr, del);
  246. <a name="l00217"></a>00217 }
  247. <a name="l00218"></a><a class="code" href="classwxLuaSmartwxArrayString.html#a4db9ec3e8575b3d47a309ed4b46b7207">00218</a> wxArrayString* <a class="code" href="classwxLuaSmartwxArrayString.html#a4db9ec3e8575b3d47a309ed4b46b7207">wxLuaSmartwxArrayString::GetArray</a>()<span class="keyword"> const</span>
  248. <a name="l00219"></a>00219 <span class="keyword"></span>{
  249. <a name="l00220"></a>00220 <span class="keywordflow">return</span> ((<a class="code" href="classwxLuaSmartwxArrayStringRefData.html">wxLuaSmartwxArrayStringRefData</a>*)m_refData)-&gt;m_arr;
  250. <a name="l00221"></a>00221 }
  251. <a name="l00222"></a>00222
  252. <a name="l00223"></a>00223 <span class="comment">// ----------------------------------------------------------------------------</span>
  253. <a name="l00224"></a>00224 <span class="comment">// wxLuaSmartwxSortedArrayString</span>
  254. <a name="l00225"></a>00225 <span class="comment">// ----------------------------------------------------------------------------</span>
  255. <a name="l00226"></a>00226
  256. <a name="l00227"></a><a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html">00227</a> <span class="keyword">class </span><a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html">wxLuaSmartwxSortedArrayStringRefData</a> : <span class="keyword">public</span> wxObjectRefData
  257. <a name="l00228"></a>00228 {
  258. <a name="l00229"></a>00229 <span class="keyword">public</span>:
  259. <a name="l00230"></a><a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#acc002cedce36ecfd86f6e1dea34166af">00230</a> <a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#acc002cedce36ecfd86f6e1dea34166af">wxLuaSmartwxSortedArrayStringRefData</a>(wxSortedArrayString* arr, <span class="keywordtype">int</span> del) : <a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#ad9837166b03fbd87377a23754b92de15">m_arr</a>(arr), <a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#acc89be4f362a1ab6ff1ea6dfcb0dce28">m_delete</a>(del)
  260. <a name="l00231"></a>00231 {
  261. <a name="l00232"></a>00232 <span class="keywordflow">if</span> (!<a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#ad9837166b03fbd87377a23754b92de15">m_arr</a>) { <a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#ad9837166b03fbd87377a23754b92de15">m_arr</a> = <span class="keyword">new</span> wxSortedArrayString; <a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#acc89be4f362a1ab6ff1ea6dfcb0dce28">m_delete</a> = <span class="keyword">true</span>; } <span class="comment">// always exists</span>
  262. <a name="l00233"></a>00233 }
  263. <a name="l00234"></a>00234
  264. <a name="l00235"></a><a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#aaf4dd5207bb44bd964d793ae739f5602">00235</a> <span class="keyword">virtual</span> <a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#aaf4dd5207bb44bd964d793ae739f5602">~wxLuaSmartwxSortedArrayStringRefData</a>() { <span class="keywordflow">if</span> (<a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#acc89be4f362a1ab6ff1ea6dfcb0dce28">m_delete</a>) <span class="keyword">delete</span> <a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#ad9837166b03fbd87377a23754b92de15">m_arr</a>; }
  265. <a name="l00236"></a>00236
  266. <a name="l00237"></a><a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#ad9837166b03fbd87377a23754b92de15">00237</a> wxSortedArrayString *<a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#ad9837166b03fbd87377a23754b92de15">m_arr</a>;
  267. <a name="l00238"></a><a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#acc89be4f362a1ab6ff1ea6dfcb0dce28">00238</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html#acc89be4f362a1ab6ff1ea6dfcb0dce28">m_delete</a>;
  268. <a name="l00239"></a>00239 };
  269. <a name="l00240"></a>00240
  270. <a name="l00241"></a><a class="code" href="classwxLuaSmartwxSortedArrayString.html#aeca3b907b936de981caf1b4287ea2540">00241</a> <a class="code" href="classwxLuaSmartwxSortedArrayString.html#a185c4cabc2fda60ab6476aa4e5d53230">wxLuaSmartwxSortedArrayString::wxLuaSmartwxSortedArrayString</a>(wxSortedArrayString *arr, <span class="keywordtype">bool</span> del)
  271. <a name="l00242"></a>00242 {
  272. <a name="l00243"></a>00243 m_refData = <span class="keyword">new</span> <a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html">wxLuaSmartwxSortedArrayStringRefData</a>(arr, del);
  273. <a name="l00244"></a>00244 }
  274. <a name="l00245"></a><a class="code" href="classwxLuaSmartwxSortedArrayString.html#a42bd08f146e65fd9a66025c45ef2cfae">00245</a> wxSortedArrayString* <a class="code" href="classwxLuaSmartwxSortedArrayString.html#a42bd08f146e65fd9a66025c45ef2cfae">wxLuaSmartwxSortedArrayString::GetArray</a>()<span class="keyword"> const</span>
  275. <a name="l00246"></a>00246 <span class="keyword"></span>{
  276. <a name="l00247"></a>00247 <span class="keywordflow">return</span> ((<a class="code" href="classwxLuaSmartwxSortedArrayStringRefData.html">wxLuaSmartwxSortedArrayStringRefData</a>*)m_refData)-&gt;m_arr;
  277. <a name="l00248"></a>00248 }
  278. <a name="l00249"></a>00249
  279. <a name="l00250"></a>00250 <span class="comment">// ----------------------------------------------------------------------------</span>
  280. <a name="l00251"></a>00251 <span class="comment">// wxLuaSmartwxArrayInt</span>
  281. <a name="l00252"></a>00252 <span class="comment">// ----------------------------------------------------------------------------</span>
  282. <a name="l00253"></a>00253
  283. <a name="l00254"></a><a class="code" href="classwxLuaSmartwxArrayIntRefData.html">00254</a> <span class="keyword">class </span><a class="code" href="classwxLuaSmartwxArrayIntRefData.html">wxLuaSmartwxArrayIntRefData</a> : <span class="keyword">public</span> wxObjectRefData
  284. <a name="l00255"></a>00255 {
  285. <a name="l00256"></a>00256 <span class="keyword">public</span>:
  286. <a name="l00257"></a><a class="code" href="classwxLuaSmartwxArrayIntRefData.html#a930e5e33ceaa6f57adc477fa01dd5c32">00257</a> <a class="code" href="classwxLuaSmartwxArrayIntRefData.html#a930e5e33ceaa6f57adc477fa01dd5c32">wxLuaSmartwxArrayIntRefData</a>(wxArrayInt* arr, <span class="keywordtype">int</span> del) : <a class="code" href="classwxLuaSmartwxArrayIntRefData.html#ad3ea217d08c3d4a5a07eeb410ed8a457">m_arr</a>(arr), <a class="code" href="classwxLuaSmartwxArrayIntRefData.html#ad3523d2167965f85f69ca52894727db7">m_delete</a>(del)
  287. <a name="l00258"></a>00258 {
  288. <a name="l00259"></a>00259 <span class="keywordflow">if</span> (!<a class="code" href="classwxLuaSmartwxArrayIntRefData.html#ad3ea217d08c3d4a5a07eeb410ed8a457">m_arr</a>) { <a class="code" href="classwxLuaSmartwxArrayIntRefData.html#ad3ea217d08c3d4a5a07eeb410ed8a457">m_arr</a> = <span class="keyword">new</span> wxArrayInt; <a class="code" href="classwxLuaSmartwxArrayIntRefData.html#ad3523d2167965f85f69ca52894727db7">m_delete</a> = <span class="keyword">true</span>; } <span class="comment">// always exists</span>
  289. <a name="l00260"></a>00260 }
  290. <a name="l00261"></a>00261
  291. <a name="l00262"></a><a class="code" href="classwxLuaSmartwxArrayIntRefData.html#ade14c552849cc4a94d026518df7ec4eb">00262</a> <span class="keyword">virtual</span> <a class="code" href="classwxLuaSmartwxArrayIntRefData.html#ade14c552849cc4a94d026518df7ec4eb">~wxLuaSmartwxArrayIntRefData</a>() { <span class="keywordflow">if</span> (<a class="code" href="classwxLuaSmartwxArrayIntRefData.html#ad3523d2167965f85f69ca52894727db7">m_delete</a>) <span class="keyword">delete</span> <a class="code" href="classwxLuaSmartwxArrayIntRefData.html#ad3ea217d08c3d4a5a07eeb410ed8a457">m_arr</a>; }
  292. <a name="l00263"></a>00263
  293. <a name="l00264"></a><a class="code" href="classwxLuaSmartwxArrayIntRefData.html#ad3ea217d08c3d4a5a07eeb410ed8a457">00264</a> wxArrayInt *<a class="code" href="classwxLuaSmartwxArrayIntRefData.html#ad3ea217d08c3d4a5a07eeb410ed8a457">m_arr</a>;
  294. <a name="l00265"></a><a class="code" href="classwxLuaSmartwxArrayIntRefData.html#ad3523d2167965f85f69ca52894727db7">00265</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaSmartwxArrayIntRefData.html#ad3523d2167965f85f69ca52894727db7">m_delete</a>;
  295. <a name="l00266"></a>00266 };
  296. <a name="l00267"></a>00267
  297. <a name="l00268"></a><a class="code" href="classwxLuaSmartwxArrayInt.html#aef7c5471c93a6d85268019bdb5e67a38">00268</a> <a class="code" href="classwxLuaSmartwxArrayInt.html#aa80205c1cea030ecc798916c3c277b8c">wxLuaSmartwxArrayInt::wxLuaSmartwxArrayInt</a>(wxArrayInt *arr, <span class="keywordtype">bool</span> del)
  298. <a name="l00269"></a>00269 {
  299. <a name="l00270"></a>00270 m_refData = <span class="keyword">new</span> <a class="code" href="classwxLuaSmartwxArrayIntRefData.html">wxLuaSmartwxArrayIntRefData</a>(arr, del);
  300. <a name="l00271"></a>00271 }
  301. <a name="l00272"></a>00272
  302. <a name="l00273"></a><a class="code" href="classwxLuaSmartwxArrayInt.html#ad9704f24ebca7e3a6ec5d725112ee643">00273</a> wxArrayInt* <a class="code" href="classwxLuaSmartwxArrayInt.html#ad9704f24ebca7e3a6ec5d725112ee643">wxLuaSmartwxArrayInt::GetArray</a>()<span class="keyword"> const</span>
  303. <a name="l00274"></a>00274 <span class="keyword"></span>{
  304. <a name="l00275"></a>00275 <span class="keywordflow">return</span> ((<a class="code" href="classwxLuaSmartwxArrayIntRefData.html">wxLuaSmartwxArrayIntRefData</a>*)m_refData)-&gt;m_arr;
  305. <a name="l00276"></a>00276 }
  306. <a name="l00277"></a>00277
  307. <a name="l00278"></a>00278 <span class="comment">// ----------------------------------------------------------------------------</span>
  308. <a name="l00279"></a>00279 <span class="comment">// wxlua_tableErrorHandler</span>
  309. <a name="l00280"></a>00280 <span class="comment">// ----------------------------------------------------------------------------</span>
  310. <a name="l00281"></a>00281
  311. <a name="l00282"></a><a class="code" href="wxlbind_8cpp.html#aa68c9563bf3481eeec59206b1084b4b2">00282</a> <span class="keyword">static</span> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlbind_8cpp.html#aa68c9563bf3481eeec59206b1084b4b2">wxlua_tableErrorHandler</a>(lua_State *L)
  312. <a name="l00283"></a>00283 {
  313. <a name="l00284"></a>00284 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, <span class="stringliteral">&quot;Cannot modify read-only wxLua table&quot;</span>);
  314. <a name="l00285"></a>00285 <span class="keywordflow">return</span> 0;
  315. <a name="l00286"></a>00286 }
  316. <a name="l00287"></a>00287
  317. <a name="l00288"></a>00288 <span class="comment">// ----------------------------------------------------------------------------</span>
  318. <a name="l00289"></a>00289 <span class="comment">// Generic delete function for bindings</span>
  319. <a name="l00290"></a>00290 <span class="comment">// ----------------------------------------------------------------------------</span>
  320. <a name="l00291"></a>00291
  321. <a name="l00292"></a><a class="code" href="wxlbind_8cpp.html#a6cab1ab205cb86c92a41c8ec54443596">00292</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlbind_8h.html#a6b29e46e8605c326133bbf713643a2cf">wxlua_userdata_delete</a>(lua_State *L)
  322. <a name="l00293"></a>00293 {
  323. <a name="l00294"></a>00294 <span class="keywordtype">void</span>* udata = lua_touserdata(L, 1);
  324. <a name="l00295"></a>00295 <span class="keywordtype">void</span>* obj_ptr = <a class="code" href="wxlstate_8h.html#ac5a0a65665274df59adbed667480e93e">wxlua_touserdata</a>(L, 1, <span class="keyword">false</span>);
  325. <a name="l00296"></a>00296
  326. <a name="l00297"></a>00297 <span class="comment">// if removed from tracked mem list, remove the metatable so that __gc is not called on this object.</span>
  327. <a name="l00298"></a>00298 <span class="keywordflow">if</span> ((obj_ptr != NULL) &amp;&amp; <a class="code" href="wxlstate_8h.html#aba83aa14c215deca6e72da965f29c4a4">wxluaO_deletegcobject</a>(L, udata, obj_ptr, <a class="code" href="wxlstate_8h.html#a29f0120153918cc4e7b7b91913b0bef1ade247b3e5ef9e545a9512ebaefa1bab8">WXLUA_DELETE_OBJECT_ALL</a>))
  328. <a name="l00299"></a>00299 {
  329. <a name="l00300"></a>00300 lua_pushnil(L);
  330. <a name="l00301"></a>00301 lua_setmetatable(L, -2);
  331. <a name="l00302"></a>00302 }
  332. <a name="l00303"></a>00303 <span class="keywordflow">else</span>
  333. <a name="l00304"></a>00304 {
  334. <a name="l00305"></a>00305 wxString msg;
  335. <a name="l00306"></a>00306 msg.Printf(wxT(<span class="stringliteral">&quot;wxLua: Unable to call wxuserdata:delete() on object %p, someone else owns it.&quot;</span>), obj_ptr);
  336. <a name="l00307"></a>00307
  337. <a name="l00308"></a>00308 <span class="comment">// leave this printf since we really want to know if this happens</span>
  338. <a name="l00309"></a>00309 wxPrintf(wxString(msg + wxT(<span class="stringliteral">&quot;\n&quot;</span>)).c_str());
  339. <a name="l00310"></a>00310 <a class="code" href="wxlstate_8h.html#a34376827e7b3466173127fba976217d0">wxlua_argerrormsg</a>(L, msg);
  340. <a name="l00311"></a>00311 }
  341. <a name="l00312"></a>00312
  342. <a name="l00313"></a>00313 <span class="keywordflow">return</span> 0;
  343. <a name="l00314"></a>00314 }
  344. <a name="l00315"></a>00315
  345. <a name="l00316"></a>00316 <span class="comment">// ----------------------------------------------------------------------------</span>
  346. <a name="l00317"></a>00317 <span class="comment">// If the class defines a gc function, then call it.</span>
  347. <a name="l00318"></a>00318 <span class="comment">// ----------------------------------------------------------------------------</span>
  348. <a name="l00319"></a>00319
  349. <a name="l00320"></a><a class="code" href="wxlbind_8cpp.html#a20d3c64b928dd9beacc075b345f242d1">00320</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlbind_8h.html#afaa936338003a8c855b37aca0e2371b3">wxlua_wxLuaBindClass__gc</a>(lua_State *L)
  350. <a name="l00321"></a>00321 {
  351. <a name="l00322"></a>00322 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *wxlClass = (<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *)lua_touserdata(L, lua_upvalueindex(1));
  352. <a name="l00323"></a>00323
  353. <a name="l00324"></a>00324 <span class="keywordflow">if</span> ((wxlClass != NULL) &amp;&amp; <a class="code" href="wxlstate_8h.html#a00a4b27cd869a94a2edb49866accd10a">wxlua_iswxuserdata</a>(L, 1) &amp;&amp; (<a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(L, 1) == *wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a487a56c7a763a21041272c4b053e6c99">wxluatype</a>))
  354. <a name="l00325"></a>00325 {
  355. <a name="l00326"></a>00326 <span class="keywordtype">void</span>* udata = lua_touserdata(L, 1);
  356. <a name="l00327"></a>00327 <span class="keywordtype">void</span>* obj_ptr = <a class="code" href="wxlstate_8h.html#ac5a0a65665274df59adbed667480e93e">wxlua_touserdata</a>(L, 1, <span class="keyword">true</span>); <span class="comment">// clear lua userdata&#39;s ptr</span>
  357. <a name="l00328"></a>00328
  358. <a name="l00329"></a>00329 <span class="comment">// clean up the rest of this, this won&#39;t error if the key doesn&#39;t exist</span>
  359. <a name="l00330"></a>00330 <a class="code" href="wxlstate_8h.html#aba83aa14c215deca6e72da965f29c4a4">wxluaO_deletegcobject</a>(L, udata, obj_ptr, <a class="code" href="wxlstate_8h.html#a29f0120153918cc4e7b7b91913b0bef1a955e0cb5738d3e7a9c7ce61a30169b02">WXLUA_DELETE_OBJECT_LAST</a>);
  360. <a name="l00331"></a>00331 }
  361. <a name="l00332"></a>00332
  362. <a name="l00333"></a>00333 <span class="keywordflow">return</span> 0;
  363. <a name="l00334"></a>00334 }
  364. <a name="l00335"></a>00335
  365. <a name="l00336"></a>00336 <span class="comment">// ----------------------------------------------------------------------------</span>
  366. <a name="l00337"></a>00337 <span class="comment">// Called by LUA to find the method that corresponds to a __index method name.</span>
  367. <a name="l00338"></a>00338 <span class="comment">// ----------------------------------------------------------------------------</span>
  368. <a name="l00339"></a>00339
  369. <a name="l00340"></a><a class="code" href="wxlbind_8cpp.html#af45d12b0e4bcca133647704e09c0a8b0">00340</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlbind_8h.html#afee853d06607bbf64e889fbb248b7b72">wxlua_wxLuaBindClass__index</a>(lua_State *L)
  370. <a name="l00341"></a>00341 {
  371. <a name="l00342"></a>00342 <span class="comment">// This function is called for the __index metable of the wxLua userdata</span>
  372. <a name="l00343"></a>00343 <span class="comment">// for class instances.</span>
  373. <a name="l00344"></a>00344
  374. <a name="l00345"></a>00345 <span class="comment">// Lua stack : 1 = userdata, 2 = key; userdata:key()</span>
  375. <a name="l00346"></a>00346 <span class="comment">// You cannot seem to get the calling convention (. or :) or if it was</span>
  376. <a name="l00347"></a>00347 <span class="comment">// called as a function() or a .member?</span>
  377. <a name="l00348"></a>00348
  378. <a name="l00349"></a>00349 <span class="comment">// See below, if _XXX is called then we set this flag so that</span>
  379. <a name="l00350"></a>00350 <span class="comment">// the called function knows to call the base class instead of recalling</span>
  380. <a name="l00351"></a>00351 <span class="comment">// the Lua function and recursing.</span>
  381. <a name="l00352"></a>00352 <a class="code" href="wxlstate_8h.html#a9d1c33c0999cd1ea92d9dafb83196fa8">wxlua_setcallbaseclassfunction</a>(L, <span class="keyword">false</span>);
  382. <a name="l00353"></a>00353
  383. <a name="l00354"></a>00354 <span class="keywordtype">bool</span> found = <span class="keyword">false</span>;
  384. <a name="l00355"></a>00355 <span class="keywordtype">int</span> result = 0;
  385. <a name="l00356"></a>00356 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *wxlClass = (<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *)lua_touserdata(L, lua_upvalueindex(1));
  386. <a name="l00357"></a>00357 wxCHECK_MSG(wxlClass, 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaBindClass&quot;</span>)); <span class="comment">// fail hard</span>
  387. <a name="l00358"></a>00358
  388. <a name="l00359"></a>00359 <span class="keywordtype">void</span> *obj_ptr = <a class="code" href="wxlstate_8h.html#ac5a0a65665274df59adbed667480e93e">wxlua_touserdata</a>(L, 1, <span class="keyword">false</span>);
  389. <a name="l00360"></a>00360 <span class="keyword">const</span> <span class="keywordtype">char</span> *name = lua_tostring(L, 2); <span class="comment">// name of the __index method called in Lua</span>
  390. <a name="l00361"></a>00361
  391. <a name="l00362"></a>00362 <span class="keywordflow">if</span> (!name)
  392. <a name="l00363"></a>00363 {
  393. <a name="l00364"></a>00364 <span class="comment">// name is NULL if it&#39;s not a string</span>
  394. <a name="l00365"></a>00365 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, wxString::Format(_(<span class="stringliteral">&quot;wxLua: Attempt to call a class method using &#39;%s&#39; on a &#39;%s&#39; wxLua type.&quot;</span>),
  395. <a name="l00366"></a>00366 <a class="code" href="wxlstate_8h.html#acf6d708626f3c7194d1f2aebb7a73b6e">wxlua_luaL_typename</a>(L, 2).c_str(), <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#af89cbb87774c38c593f7ed87a68fffcb">name</a>).c_str()));
  396. <a name="l00367"></a>00367 }
  397. <a name="l00368"></a>00368 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(L, 1) == *wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a487a56c7a763a21041272c4b053e6c99">wxluatype</a>)
  398. <a name="l00369"></a>00369 {
  399. <a name="l00370"></a>00370 <span class="comment">// check if we&#39;re to call the baseclass function or if it&#39;s a Lua derived function</span>
  400. <a name="l00371"></a>00371 <span class="keywordtype">bool</span> callbase = (name[0] == <span class="charliteral">&#39;_&#39;</span>);
  401. <a name="l00372"></a>00372
  402. <a name="l00373"></a>00373 <span class="keywordflow">if</span> (callbase)
  403. <a name="l00374"></a>00374 name++; <span class="comment">// skip past &quot;_&quot;[FunctionName]</span>
  404. <a name="l00375"></a>00375 <span class="keywordflow">else</span>
  405. <a name="l00376"></a>00376 {
  406. <a name="l00377"></a>00377 <span class="comment">// if there&#39;s a derived method, push it onto the stack to be run</span>
  407. <a name="l00378"></a>00378 <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a602bc60e4737a25c6202d86c7c2f6c2b">wxlua_hasderivedmethod</a>(L, obj_ptr, name, <span class="keyword">true</span>))
  408. <a name="l00379"></a>00379 {
  409. <a name="l00380"></a>00380 found = <span class="keyword">true</span>;
  410. <a name="l00381"></a>00381 result = 1; <span class="comment">// the function for Lua to call is on the stack</span>
  411. <a name="l00382"></a>00382 }
  412. <a name="l00383"></a>00383 }
  413. <a name="l00384"></a>00384
  414. <a name="l00385"></a>00385 <span class="comment">// Search through the bindings for the function to call</span>
  415. <a name="l00386"></a>00386 <span class="keywordflow">if</span> (!found)
  416. <a name="l00387"></a>00387 {
  417. <a name="l00388"></a>00388 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod = <a class="code" href="classwxLuaBinding.html#abb8ab3912057a7268eaa4b1ec900b629">wxLuaBinding::GetClassMethod</a>(wxlClass, name, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa60723ea1159aae6845b01c660afd54f2">WXLUAMETHOD_METHOD</a>|<a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa6fae1df03c5887c4848e5bc5e2998257">WXLUAMETHOD_GETPROP</a>, <span class="keyword">true</span>);
  418. <a name="l00389"></a>00389
  419. <a name="l00390"></a>00390 <span class="keywordflow">if</span> (wxlMethod != NULL)
  420. <a name="l00391"></a>00391 {
  421. <a name="l00392"></a>00392 <span class="keywordflow">if</span> (<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a>, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa6fae1df03c5887c4848e5bc5e2998257">WXLUAMETHOD_GETPROP</a>))
  422. <a name="l00393"></a>00393 {
  423. <a name="l00394"></a>00394 found = <span class="keyword">true</span>;
  424. <a name="l00395"></a>00395 <span class="keywordflow">if</span> (<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a>, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fad2e593a9652e9ce570c780473db925a1">WXLUAMETHOD_STATIC</a>))
  425. <a name="l00396"></a>00396 lua_pop(L, 2); <span class="comment">// remove the userdata and func name</span>
  426. <a name="l00397"></a>00397 <span class="keywordflow">else</span>
  427. <a name="l00398"></a>00398 lua_pop(L, 1); <span class="comment">// remove the name of the function</span>
  428. <a name="l00399"></a>00399
  429. <a name="l00400"></a>00400 result = (*wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#abcc43fb837b299e7fc088fb787ad3aca">wxluacfuncs</a>[0].<a class="code" href="structwxLuaBindCFunc.html#a6184d5deed3363ec14f67ecf5f63c84f">lua_cfunc</a>)(L);
  430. <a name="l00401"></a>00401 }
  431. <a name="l00402"></a>00402 <span class="keywordflow">else</span>
  432. <a name="l00403"></a>00403 {
  433. <a name="l00404"></a>00404 found = <span class="keyword">true</span>;
  434. <a name="l00405"></a>00405 result = 1;
  435. <a name="l00406"></a>00406
  436. <a name="l00407"></a>00407 lua_pushlightuserdata(L, wxlMethod);
  437. <a name="l00408"></a>00408
  438. <a name="l00409"></a>00409 <span class="keywordflow">if</span> ((wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#a36285f0c5431ed28e8951b26706ee3c5">wxluacfuncs_n</a> &gt; 1) || (wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#a61bd0c007d8c7064a473d19eac6dd2a6">basemethod</a>))
  439. <a name="l00410"></a>00410 lua_pushcclosure(L, <a class="code" href="wxlbind_8h.html#ae8b8fad8188c49f55361c6686266c570">wxlua_callOverloadedFunction</a>, 1);
  440. <a name="l00411"></a>00411 <span class="keywordflow">else</span>
  441. <a name="l00412"></a>00412 lua_pushcclosure(L, wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#abcc43fb837b299e7fc088fb787ad3aca">wxluacfuncs</a>[0].<a class="code" href="structwxLuaBindCFunc.html#a6184d5deed3363ec14f67ecf5f63c84f">lua_cfunc</a>, 1);
  442. <a name="l00413"></a>00413 }
  443. <a name="l00414"></a>00414 }
  444. <a name="l00415"></a>00415
  445. <a name="l00416"></a>00416 <span class="comment">// Maybe this is an undeclared property? Prepend &#39;Get&#39; and try again.</span>
  446. <a name="l00417"></a>00417 <span class="keywordflow">if</span> (!found)
  447. <a name="l00418"></a>00418 {
  448. <a name="l00419"></a>00419 <span class="keywordtype">int</span> len = strlen(name);
  449. <a name="l00420"></a>00420 wxCharBuffer buf(len + 4);
  450. <a name="l00421"></a>00421 <span class="keywordtype">char</span>* str = buf.data();
  451. <a name="l00422"></a>00422 str[0] = <span class="charliteral">&#39;G&#39;</span>; str[1] = <span class="charliteral">&#39;e&#39;</span>; str[2] = <span class="charliteral">&#39;t&#39;</span>;
  452. <a name="l00423"></a>00423 memcpy(str+3, name, len+1); <span class="comment">// include terminating NULL</span>
  453. <a name="l00424"></a>00424
  454. <a name="l00425"></a>00425 wxlMethod = <a class="code" href="classwxLuaBinding.html#abb8ab3912057a7268eaa4b1ec900b629">wxLuaBinding::GetClassMethod</a>(wxlClass, str, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa60723ea1159aae6845b01c660afd54f2">WXLUAMETHOD_METHOD</a>, <span class="keyword">true</span>);
  455. <a name="l00426"></a>00426
  456. <a name="l00427"></a>00427 <span class="keywordflow">if</span> ((wxlMethod != NULL) &amp;&amp; <a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a>, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa60723ea1159aae6845b01c660afd54f2">WXLUAMETHOD_METHOD</a>))
  457. <a name="l00428"></a>00428 <span class="comment">//wxlMethod-&gt;funcs &amp;&amp; (wxlMethod-&gt;funcs-&gt;minargs == 0) &amp;&amp; // let it error out</span>
  458. <a name="l00429"></a>00429 <span class="comment">//(wxlMethod-&gt;funcs-&gt;maxargs == 0))</span>
  459. <a name="l00430"></a>00430 {
  460. <a name="l00431"></a>00431 found = <span class="keyword">true</span>;
  461. <a name="l00432"></a>00432 <span class="keywordflow">if</span> (<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a>, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fad2e593a9652e9ce570c780473db925a1">WXLUAMETHOD_STATIC</a>))
  462. <a name="l00433"></a>00433 lua_pop(L, 2); <span class="comment">// remove the userdata and func name</span>
  463. <a name="l00434"></a>00434 <span class="keywordflow">else</span>
  464. <a name="l00435"></a>00435 lua_pop(L, 1); <span class="comment">// remove the name of the function</span>
  465. <a name="l00436"></a>00436
  466. <a name="l00437"></a>00437 result = (*wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#abcc43fb837b299e7fc088fb787ad3aca">wxluacfuncs</a>[0].<a class="code" href="structwxLuaBindCFunc.html#a6184d5deed3363ec14f67ecf5f63c84f">lua_cfunc</a>)(L);
  467. <a name="l00438"></a>00438 }
  468. <a name="l00439"></a>00439 }
  469. <a name="l00440"></a>00440
  470. <a name="l00441"></a>00441 <span class="comment">// This MUST be reset to false in the base class function</span>
  471. <a name="l00442"></a>00442 <span class="keywordflow">if</span> (found &amp;&amp; callbase) <a class="code" href="wxlstate_8h.html#a9d1c33c0999cd1ea92d9dafb83196fa8">wxlua_setcallbaseclassfunction</a>(L, <span class="keyword">true</span>);
  472. <a name="l00443"></a>00443 }
  473. <a name="l00444"></a>00444 }
  474. <a name="l00445"></a>00445
  475. <a name="l00446"></a>00446 <span class="keywordflow">if</span> (!found)
  476. <a name="l00447"></a>00447 {
  477. <a name="l00448"></a>00448 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, wxString::Format(_(<span class="stringliteral">&quot;wxLua: Unable to call an unknown method &#39;%s&#39; on a &#39;%s&#39; type.&quot;</span>),
  478. <a name="l00449"></a>00449 <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(name).c_str(), <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(wxlClass ? wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#af89cbb87774c38c593f7ed87a68fffcb">name</a> : <span class="stringliteral">&quot;&quot;</span>).c_str()));
  479. <a name="l00450"></a>00450 }
  480. <a name="l00451"></a>00451
  481. <a name="l00452"></a>00452 <span class="keywordflow">return</span> result;
  482. <a name="l00453"></a>00453 }
  483. <a name="l00454"></a>00454
  484. <a name="l00455"></a>00455 <span class="comment">// ----------------------------------------------------------------------------</span>
  485. <a name="l00456"></a>00456 <span class="comment">// Called by LUA to find the method that corresponds to a __newindex method name.</span>
  486. <a name="l00457"></a>00457 <span class="comment">// ----------------------------------------------------------------------------</span>
  487. <a name="l00458"></a>00458
  488. <a name="l00459"></a><a class="code" href="wxlbind_8cpp.html#ab4168148e391549cf06edbb1d165acc4">00459</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlbind_8h.html#a95e9940883230f3fb35390c89de03200">wxlua_wxLuaBindClass__newindex</a>(lua_State *L)
  489. <a name="l00460"></a>00460 {
  490. <a name="l00461"></a>00461 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *wxlClass = (<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *)lua_touserdata(L, lua_upvalueindex(1));
  491. <a name="l00462"></a>00462 wxCHECK_MSG(wxlClass, 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaBindClass&quot;</span>)); <span class="comment">// fail hard</span>
  492. <a name="l00463"></a>00463
  493. <a name="l00464"></a>00464 <span class="comment">// Lua Stack: 1 = userdata, 2 = key, 3 = value; userdata.key = value</span>
  494. <a name="l00465"></a>00465
  495. <a name="l00466"></a>00466 <span class="keyword">const</span> <span class="keywordtype">char</span> *name = lua_tostring(L, 2);
  496. <a name="l00467"></a>00467 <span class="keywordtype">bool</span> found = <span class="keyword">false</span>;
  497. <a name="l00468"></a>00468
  498. <a name="l00469"></a>00469 <span class="keywordflow">if</span> (!name)
  499. <a name="l00470"></a>00470 {
  500. <a name="l00471"></a>00471 <span class="comment">// name is NULL if it&#39;s not a string</span>
  501. <a name="l00472"></a>00472 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, wxString::Format(_(<span class="stringliteral">&quot;wxLua: Attempt to call or add a class method using &#39;%s&#39; on a &#39;%s&#39; type.&quot;</span>),
  502. <a name="l00473"></a>00473 <a class="code" href="wxlstate_8h.html#acf6d708626f3c7194d1f2aebb7a73b6e">wxlua_luaL_typename</a>(L, 2).c_str(), <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#af89cbb87774c38c593f7ed87a68fffcb">name</a>).c_str()));
  503. <a name="l00474"></a>00474 }
  504. <a name="l00475"></a>00475 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(L, 1) == *wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a487a56c7a763a21041272c4b053e6c99">wxluatype</a>)
  505. <a name="l00476"></a>00476 {
  506. <a name="l00477"></a>00477 <span class="comment">// See if there is a WXLUAMETHOD_SETPROP in the wxLuaBindClass&#39;s wxLuaBindMethods</span>
  507. <a name="l00478"></a>00478 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a> *wxlMethod = <a class="code" href="classwxLuaBinding.html#abb8ab3912057a7268eaa4b1ec900b629">wxLuaBinding::GetClassMethod</a>(wxlClass, name, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa868d721a899ba8061183e08bc84c0d64">WXLUAMETHOD_SETPROP</a>, <span class="keyword">true</span>);
  508. <a name="l00479"></a>00479
  509. <a name="l00480"></a>00480 <span class="keywordflow">if</span> (wxlMethod != NULL)
  510. <a name="l00481"></a>00481 {
  511. <a name="l00482"></a>00482 found = <span class="keyword">true</span>;
  512. <a name="l00483"></a>00483 lua_remove(L, 2); <span class="comment">// remove the function name</span>
  513. <a name="l00484"></a>00484 <span class="keywordflow">if</span> (<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a>, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fad2e593a9652e9ce570c780473db925a1">WXLUAMETHOD_STATIC</a>))
  514. <a name="l00485"></a>00485 lua_remove(L, 1); <span class="comment">// remove the userdata too, leaving the value</span>
  515. <a name="l00486"></a>00486
  516. <a name="l00487"></a>00487 (*wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#abcc43fb837b299e7fc088fb787ad3aca">wxluacfuncs</a>[0].<a class="code" href="structwxLuaBindCFunc.html#a6184d5deed3363ec14f67ecf5f63c84f">lua_cfunc</a>)(L);
  517. <a name="l00488"></a>00488 }
  518. <a name="l00489"></a>00489
  519. <a name="l00490"></a>00490 <span class="comment">// Maybe this is an undeclared property? Prepend &#39;Set&#39; and try again.</span>
  520. <a name="l00491"></a>00491 <span class="keywordflow">if</span> (!found)
  521. <a name="l00492"></a>00492 {
  522. <a name="l00493"></a>00493 <span class="keywordtype">int</span> len = strlen(name);
  523. <a name="l00494"></a>00494 wxCharBuffer buf(len + 4);
  524. <a name="l00495"></a>00495 <span class="keywordtype">char</span>* str = buf.data();
  525. <a name="l00496"></a>00496 str[0] = <span class="charliteral">&#39;S&#39;</span>; str[1] = <span class="charliteral">&#39;e&#39;</span>; str[2] = <span class="charliteral">&#39;t&#39;</span>;
  526. <a name="l00497"></a>00497 memcpy(str+3, name, len+1); <span class="comment">// include terminating NULL</span>
  527. <a name="l00498"></a>00498
  528. <a name="l00499"></a>00499 wxlMethod = <a class="code" href="classwxLuaBinding.html#abb8ab3912057a7268eaa4b1ec900b629">wxLuaBinding::GetClassMethod</a>(wxlClass, str, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa60723ea1159aae6845b01c660afd54f2">WXLUAMETHOD_METHOD</a>, <span class="keyword">true</span>);
  529. <a name="l00500"></a>00500 <span class="keywordflow">if</span> ((wxlMethod != NULL) &amp;&amp; <a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a>, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa60723ea1159aae6845b01c660afd54f2">WXLUAMETHOD_METHOD</a>))
  530. <a name="l00501"></a>00501 {
  531. <a name="l00502"></a>00502 found = <span class="keyword">true</span>;
  532. <a name="l00503"></a>00503 lua_remove(L, 2); <span class="comment">// remove the function name</span>
  533. <a name="l00504"></a>00504 <span class="keywordflow">if</span> (<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a>, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fad2e593a9652e9ce570c780473db925a1">WXLUAMETHOD_STATIC</a>))
  534. <a name="l00505"></a>00505 lua_remove(L, 1); <span class="comment">// remove the userdata too, leaving the value</span>
  535. <a name="l00506"></a>00506
  536. <a name="l00507"></a>00507 (*wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#abcc43fb837b299e7fc088fb787ad3aca">wxluacfuncs</a>[0].<a class="code" href="structwxLuaBindCFunc.html#a6184d5deed3363ec14f67ecf5f63c84f">lua_cfunc</a>)(L);
  537. <a name="l00508"></a>00508 }
  538. <a name="l00509"></a>00509 }
  539. <a name="l00510"></a>00510
  540. <a name="l00511"></a>00511 <span class="comment">// They want to add this to the class so store it in the derived method table</span>
  541. <a name="l00512"></a>00512 <span class="keywordflow">if</span> (!found)
  542. <a name="l00513"></a>00513 {
  543. <a name="l00514"></a>00514 found = <span class="keyword">true</span>;
  544. <a name="l00515"></a>00515 <a class="code" href="classwxLuaState.html">wxLuaState</a> wxlState(L);
  545. <a name="l00516"></a>00516 wxCHECK_MSG(wxlState.<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  546. <a name="l00517"></a>00517
  547. <a name="l00518"></a>00518 <span class="keywordtype">void</span> *obj_ptr = <a class="code" href="wxlstate_8h.html#ac5a0a65665274df59adbed667480e93e">wxlua_touserdata</a>(L, 1, <span class="keyword">false</span>);
  548. <a name="l00519"></a>00519 <a class="code" href="classwxLuaObject.html">wxLuaObject</a>* wxlObj = <span class="keyword">new</span> <a class="code" href="classwxLuaObject.html">wxLuaObject</a>(wxlState, 3);
  549. <a name="l00520"></a>00520 <a class="code" href="wxlstate_8h.html#a1110e8f522280bc418efc5ec47ef585c">wxlua_setderivedmethod</a>(L, obj_ptr, name, wxlObj);
  550. <a name="l00521"></a>00521 }
  551. <a name="l00522"></a>00522 }
  552. <a name="l00523"></a>00523
  553. <a name="l00524"></a>00524 <span class="keywordflow">if</span> (!found)
  554. <a name="l00525"></a>00525 {
  555. <a name="l00526"></a>00526 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, wxString::Format(_(<span class="stringliteral">&quot;wxLua: Unable to call or add an unknown method &#39;%s&#39; on a &#39;%s&#39; type.&quot;</span>),
  556. <a name="l00527"></a>00527 <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(name).c_str(), <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(wxlClass ? wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#af89cbb87774c38c593f7ed87a68fffcb">name</a> : <span class="stringliteral">&quot;&quot;</span>).c_str()));
  557. <a name="l00528"></a>00528 }
  558. <a name="l00529"></a>00529
  559. <a name="l00530"></a>00530 <span class="keywordflow">return</span> 0;
  560. <a name="l00531"></a>00531 }
  561. <a name="l00532"></a>00532
  562. <a name="l00533"></a>00533 <span class="comment">// ----------------------------------------------------------------------------</span>
  563. <a name="l00534"></a>00534 <span class="comment">// wxlua_wxLuaBindClass__tostring</span>
  564. <a name="l00535"></a>00535 <span class="comment">// ----------------------------------------------------------------------------</span>
  565. <a name="l00536"></a>00536
  566. <a name="l00537"></a><a class="code" href="wxlbind_8cpp.html#ac7d4a6f23ba1cbf46a1499dd1f89eda6">00537</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlbind_8h.html#a8443ccec54d9e1ef4b4a6c3e15ba6282">wxlua_wxLuaBindClass__tostring</a>(lua_State *L)
  567. <a name="l00538"></a>00538 {
  568. <a name="l00539"></a>00539 <span class="comment">// this should be identical to Lua&#39;s tostring for a userdata</span>
  569. <a name="l00540"></a>00540 wxString str = wxString::Format(wxT(<span class="stringliteral">&quot;userdata: %p&quot;</span>), lua_touserdata(L, 1));
  570. <a name="l00541"></a>00541
  571. <a name="l00542"></a>00542 <span class="keywordtype">int</span> wxl_type = <a class="code" href="wxlstate_8h.html#a212261fffa8066de870a4cdb969d5180">wxluaT_type</a>(L, 1);
  572. <a name="l00543"></a>00543 <span class="keywordflow">if</span> (<a class="code" href="wxlbind_8h.html#ab26c2ec570e70f2f2b3ed9fa82afe24a">wxlua_iswxuserdatatype</a>(wxl_type))
  573. <a name="l00544"></a>00544 {
  574. <a name="l00545"></a>00545 wxString name = <a class="code" href="wxlstate_8h.html#a6621fa5a456448acfd515112aa7b23e1">wxluaT_typename</a>(L, wxl_type);
  575. <a name="l00546"></a>00546 <span class="keywordflow">if</span> (!name.IsEmpty())
  576. <a name="l00547"></a>00547 {
  577. <a name="l00548"></a>00548 <span class="comment">// GCC prints &#39;(&#39; for NULL %p for some reason.</span>
  578. <a name="l00549"></a>00549 <span class="keywordtype">void</span>* p = <a class="code" href="wxlstate_8h.html#ac5a0a65665274df59adbed667480e93e">wxlua_touserdata</a>(L, 1, <span class="keyword">false</span>);
  579. <a name="l00550"></a>00550 <span class="keywordflow">if</span> (p)
  580. <a name="l00551"></a>00551 str += wxString::Format(wxT(<span class="stringliteral">&quot; [%s(%p, %d)]&quot;</span>), name.c_str(), p, wxl_type);
  581. <a name="l00552"></a>00552 <span class="keywordflow">else</span>
  582. <a name="l00553"></a>00553 str += wxString::Format(wxT(<span class="stringliteral">&quot; [%s(0x0, %d)]&quot;</span>), name.c_str(), wxl_type);
  583. <a name="l00554"></a>00554 }
  584. <a name="l00555"></a>00555 }
  585. <a name="l00556"></a>00556 <span class="keywordflow">else</span>
  586. <a name="l00557"></a>00557 str += wxT(<span class="stringliteral">&quot; [??? Unknown wxLua class type!]&quot;</span>); <span class="comment">// get people&#39;s attention</span>
  587. <a name="l00558"></a>00558
  588. <a name="l00559"></a>00559 lua_pushstring(L, <a class="code" href="wxlstate_8h.html#a41976a7549ef4bfa7e9a1147dc7b4d55">wx2lua</a>(str));
  589. <a name="l00560"></a>00560 <span class="keywordflow">return</span> 1;
  590. <a name="l00561"></a>00561 }
  591. <a name="l00562"></a>00562
  592. <a name="l00563"></a>00563 <span class="comment">// ----------------------------------------------------------------------------</span>
  593. <a name="l00564"></a>00564 <span class="comment">// The __call metatable function to allow the class tables to be called as functions</span>
  594. <a name="l00565"></a>00565 <span class="comment">// ----------------------------------------------------------------------------</span>
  595. <a name="l00566"></a>00566
  596. <a name="l00567"></a><a class="code" href="wxlbind_8cpp.html#a144b8c459569dbdac97cfcc1c4467a10">00567</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlbind_8cpp.html#a144b8c459569dbdac97cfcc1c4467a10">wxlua_wxLuaBindMethod_table__call</a>(lua_State *L)
  597. <a name="l00568"></a>00568 {
  598. <a name="l00569"></a>00569 lua_remove(L, 1); <span class="comment">// remove the table</span>
  599. <a name="l00570"></a>00570
  600. <a name="l00571"></a>00571 <span class="keywordflow">return</span> <a class="code" href="wxlbind_8h.html#ae8b8fad8188c49f55361c6686266c570">wxlua_callOverloadedFunction</a>(L);
  601. <a name="l00572"></a>00572 }
  602. <a name="l00573"></a>00573
  603. <a name="l00574"></a><a class="code" href="wxlbind_8cpp.html#a97e12402435dfa7a8a857cb0f39a98f3">00574</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlbind_8cpp.html#a97e12402435dfa7a8a857cb0f39a98f3">wxlua_wxLuaBindMethod_table__index</a>(lua_State *L)
  604. <a name="l00575"></a>00575 {
  605. <a name="l00576"></a>00576 <span class="comment">// Lua stack: 1 = table, 2 = key</span>
  606. <a name="l00577"></a>00577
  607. <a name="l00578"></a>00578 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *wxlClass = (<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *)lua_touserdata(L, lua_upvalueindex(1));
  608. <a name="l00579"></a>00579 wxCHECK_MSG(wxlClass, 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaBindClass&quot;</span>)); <span class="comment">// fail hard</span>
  609. <a name="l00580"></a>00580
  610. <a name="l00581"></a>00581 <span class="keywordtype">int</span> result = 0;
  611. <a name="l00582"></a>00582
  612. <a name="l00583"></a>00583 <span class="keyword">const</span> <span class="keywordtype">char</span>* name = lua_tostring(L, 2);
  613. <a name="l00584"></a>00584 <span class="keywordflow">if</span> (!name)
  614. <a name="l00585"></a>00585 {
  615. <a name="l00586"></a>00586 <span class="comment">// name is NULL if it&#39;s not a string</span>
  616. <a name="l00587"></a>00587 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, wxString::Format(_(<span class="stringliteral">&quot;wxLua: Attempt to call a static class method using &#39;%s&#39; on a &#39;%s&#39; type.&quot;</span>),
  617. <a name="l00588"></a>00588 <a class="code" href="wxlstate_8h.html#acf6d708626f3c7194d1f2aebb7a73b6e">wxlua_luaL_typename</a>(L, 2).c_str(), <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#af89cbb87774c38c593f7ed87a68fffcb">name</a>).c_str()));
  618. <a name="l00589"></a>00589 <span class="keywordflow">return</span> 0;
  619. <a name="l00590"></a>00590 }
  620. <a name="l00591"></a>00591
  621. <a name="l00592"></a>00592 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod = <a class="code" href="classwxLuaBinding.html#abb8ab3912057a7268eaa4b1ec900b629">wxLuaBinding::GetClassMethod</a>(wxlClass, name, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa6fae1df03c5887c4848e5bc5e2998257">WXLUAMETHOD_GETPROP</a>, <span class="keyword">true</span>);
  622. <a name="l00593"></a>00593
  623. <a name="l00594"></a>00594 <span class="keywordflow">if</span> (wxlMethod &amp;&amp; <a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a>, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fad2e593a9652e9ce570c780473db925a1">WXLUAMETHOD_STATIC</a>))
  624. <a name="l00595"></a>00595 {
  625. <a name="l00596"></a>00596 lua_pop(L, 2); <span class="comment">// remove the table and the name of the function</span>
  626. <a name="l00597"></a>00597 result = (*wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#abcc43fb837b299e7fc088fb787ad3aca">wxluacfuncs</a>[0].<a class="code" href="structwxLuaBindCFunc.html#a6184d5deed3363ec14f67ecf5f63c84f">lua_cfunc</a>)(L);
  627. <a name="l00598"></a>00598 }
  628. <a name="l00599"></a>00599 <span class="keywordflow">else</span>
  629. <a name="l00600"></a>00600 {
  630. <a name="l00601"></a>00601 lua_pushvalue(L, -1); <span class="comment">// copy key</span>
  631. <a name="l00602"></a>00602 lua_rawget(L, -3); <span class="comment">// get t[key] = value, pops key pushes value</span>
  632. <a name="l00603"></a>00603 result = 1; <span class="comment">// ok if nil</span>
  633. <a name="l00604"></a>00604 }
  634. <a name="l00605"></a>00605
  635. <a name="l00606"></a>00606 <span class="keywordflow">return</span> result;
  636. <a name="l00607"></a>00607 }
  637. <a name="l00608"></a>00608
  638. <a name="l00609"></a><a class="code" href="wxlbind_8cpp.html#a6234dfc83aabc51327e45846fe9b07a4">00609</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlbind_8cpp.html#a6234dfc83aabc51327e45846fe9b07a4">wxlua_wxLuaBindMethod_table__newindex</a>(lua_State *L)
  639. <a name="l00610"></a>00610 {
  640. <a name="l00611"></a>00611 <span class="comment">// 1 = table, 2 = key, 3 = value</span>
  641. <a name="l00612"></a>00612
  642. <a name="l00613"></a>00613 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *wxlClass = (<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *)lua_touserdata(L, lua_upvalueindex(1));
  643. <a name="l00614"></a>00614 wxCHECK_MSG(wxlClass, 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaBindClass&quot;</span>));
  644. <a name="l00615"></a>00615
  645. <a name="l00616"></a>00616 <span class="keyword">const</span> <span class="keywordtype">char</span>* name = lua_tostring(L, 2);
  646. <a name="l00617"></a>00617 <span class="keywordflow">if</span> (!name)
  647. <a name="l00618"></a>00618 {
  648. <a name="l00619"></a>00619 <span class="comment">// name is NULL if it&#39;s not a string</span>
  649. <a name="l00620"></a>00620 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, wxString::Format(_(<span class="stringliteral">&quot;wxLua: Attempt to call a static class method using &#39;%s&#39; on a &#39;%s&#39; type.&quot;</span>),
  650. <a name="l00621"></a>00621 <a class="code" href="wxlstate_8h.html#acf6d708626f3c7194d1f2aebb7a73b6e">wxlua_luaL_typename</a>(L, 2).c_str(), <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#af89cbb87774c38c593f7ed87a68fffcb">name</a>).c_str()));
  651. <a name="l00622"></a>00622 <span class="keywordflow">return</span> 0;
  652. <a name="l00623"></a>00623 }
  653. <a name="l00624"></a>00624
  654. <a name="l00625"></a>00625 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod = <a class="code" href="classwxLuaBinding.html#abb8ab3912057a7268eaa4b1ec900b629">wxLuaBinding::GetClassMethod</a>(wxlClass, name, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa868d721a899ba8061183e08bc84c0d64">WXLUAMETHOD_SETPROP</a>, <span class="keyword">true</span>);
  655. <a name="l00626"></a>00626
  656. <a name="l00627"></a>00627 <span class="keywordflow">if</span> (wxlMethod &amp;&amp; <a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a>, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fad2e593a9652e9ce570c780473db925a1">WXLUAMETHOD_STATIC</a>))
  657. <a name="l00628"></a>00628 {
  658. <a name="l00629"></a>00629 lua_remove(L, 2); <span class="comment">// remove the key</span>
  659. <a name="l00630"></a>00630 lua_remove(L, 1); <span class="comment">// remove the table</span>
  660. <a name="l00631"></a>00631 (*wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#abcc43fb837b299e7fc088fb787ad3aca">wxluacfuncs</a>[0].<a class="code" href="structwxLuaBindCFunc.html#a6184d5deed3363ec14f67ecf5f63c84f">lua_cfunc</a>)(L);
  661. <a name="l00632"></a>00632 }
  662. <a name="l00633"></a>00633 <span class="keywordflow">else</span>
  663. <a name="l00634"></a>00634 {
  664. <a name="l00635"></a>00635 lua_pushvalue(L, -2); <span class="comment">// copy key</span>
  665. <a name="l00636"></a>00636 lua_pushvalue(L, -2); <span class="comment">// copy value</span>
  666. <a name="l00637"></a>00637 lua_rawset(L, -5); <span class="comment">// set t[key] = value, pops key and value</span>
  667. <a name="l00638"></a>00638 }
  668. <a name="l00639"></a>00639
  669. <a name="l00640"></a>00640 <span class="keywordflow">return</span> 0;
  670. <a name="l00641"></a>00641 }
  671. <a name="l00642"></a>00642
  672. <a name="l00643"></a>00643 <span class="comment">// ----------------------------------------------------------------------------</span>
  673. <a name="l00644"></a>00644 <span class="comment">// Central function to call for overloaded functions</span>
  674. <a name="l00645"></a>00645 <span class="comment">// ----------------------------------------------------------------------------</span>
  675. <a name="l00646"></a>00646
  676. <a name="l00647"></a><a class="code" href="wxlbind_8cpp.html#ae8b8fad8188c49f55361c6686266c570">00647</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlbind_8h.html#ae8b8fad8188c49f55361c6686266c570">wxlua_callOverloadedFunction</a>(lua_State* L)
  677. <a name="l00648"></a>00648 {
  678. <a name="l00649"></a>00649 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod = (<a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a> *)lua_touserdata(L, lua_upvalueindex(1)); <span class="comment">// lightuserdata</span>
  679. <a name="l00650"></a>00650 wxCHECK_MSG(wxlMethod, 0, wxT(<span class="stringliteral">&quot;Invalid wxLuaBindMethod&quot;</span>));
  680. <a name="l00651"></a>00651
  681. <a name="l00652"></a>00652 <span class="keywordflow">if</span> ((wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#a36285f0c5431ed28e8951b26706ee3c5">wxluacfuncs_n</a> &gt; 1) || (wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#a61bd0c007d8c7064a473d19eac6dd2a6">basemethod</a>))
  682. <a name="l00653"></a>00653 <span class="keywordflow">return</span> <a class="code" href="wxlbind_8h.html#ae8b8fad8188c49f55361c6686266c570">wxlua_callOverloadedFunction</a>(L, wxlMethod);
  683. <a name="l00654"></a>00654 <span class="keywordflow">else</span>
  684. <a name="l00655"></a>00655 <span class="keywordflow">return</span> (*wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#abcc43fb837b299e7fc088fb787ad3aca">wxluacfuncs</a>[0].<a class="code" href="structwxLuaBindCFunc.html#a6184d5deed3363ec14f67ecf5f63c84f">lua_cfunc</a>)(L);
  685. <a name="l00656"></a>00656 }
  686. <a name="l00657"></a>00657
  687. <a name="l00658"></a><a class="code" href="wxlbind_8cpp.html#a0f1fbf23be97685205f83458ff9b516a">00658</a> <span class="keywordtype">int</span> LUACALL <a class="code" href="wxlbind_8h.html#ae8b8fad8188c49f55361c6686266c570">wxlua_callOverloadedFunction</a>(lua_State* L, <span class="keyword">struct</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod)
  688. <a name="l00659"></a>00659 {
  689. <a name="l00660"></a>00660 <span class="comment">// get number of arguments called from Lua</span>
  690. <a name="l00661"></a>00661 <span class="keywordtype">int</span> i, arg, arg_lua_count = lua_gettop(L);
  691. <a name="l00662"></a>00662
  692. <a name="l00663"></a>00663 <span class="comment">// only look at the methods that could possibly work and traverse base classes</span>
  693. <a name="l00664"></a>00664 wxArrayPtrVoid cfuncArray;
  694. <a name="l00665"></a>00665 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* method = wxlMethod;
  695. <a name="l00666"></a>00666 <span class="keywordflow">while</span> (method)
  696. <a name="l00667"></a>00667 {
  697. <a name="l00668"></a>00668 <a class="code" href="structwxLuaBindCFunc.html">wxLuaBindCFunc</a>* wxlCFunc = method-&gt;<a class="code" href="structwxLuaBindMethod.html#abcc43fb837b299e7fc088fb787ad3aca">wxluacfuncs</a>;
  698. <a name="l00669"></a>00669
  699. <a name="l00670"></a>00670 <span class="keywordflow">for</span> (i = 0; i &lt; method-&gt;<a class="code" href="structwxLuaBindMethod.html#a36285f0c5431ed28e8951b26706ee3c5">wxluacfuncs_n</a>; ++i, ++wxlCFunc)
  700. <a name="l00671"></a>00671 {
  701. <a name="l00672"></a>00672 <span class="keywordflow">if</span> ((arg_lua_count &gt;= wxlCFunc-&gt;<a class="code" href="structwxLuaBindCFunc.html#ab76dacd34dc14e51d580d353aad17017">minargs</a>) &amp;&amp;
  702. <a name="l00673"></a>00673 (arg_lua_count &lt;= wxlCFunc-&gt;maxargs))
  703. <a name="l00674"></a>00674 {
  704. <a name="l00675"></a>00675 cfuncArray.Add(wxlCFunc);
  705. <a name="l00676"></a>00676 }
  706. <a name="l00677"></a>00677 }
  707. <a name="l00678"></a>00678
  708. <a name="l00679"></a>00679 method = method-&gt;<a class="code" href="structwxLuaBindMethod.html#a61bd0c007d8c7064a473d19eac6dd2a6">basemethod</a>;
  709. <a name="l00680"></a>00680 }
  710. <a name="l00681"></a>00681
  711. <a name="l00682"></a>00682 <a class="code" href="structwxLuaBindCFunc.html">wxLuaBindCFunc</a>* bestCFunc = NULL; <span class="comment">// stores the last function that worked.</span>
  712. <a name="l00683"></a>00683 <span class="keywordtype">int</span> invalid_lua_arg = 1; <span class="comment">// arg that failed</span>
  713. <a name="l00684"></a>00684 <span class="keywordtype">int</span> cfunc_count = cfuncArray.GetCount();
  714. <a name="l00685"></a>00685
  715. <a name="l00686"></a>00686 <span class="comment">// Look at the available functions in parallel, per arg</span>
  716. <a name="l00687"></a>00687 <span class="keywordflow">for</span> (arg = 0; (arg &lt; arg_lua_count) &amp;&amp; (cfunc_count != 0); ++arg)
  717. <a name="l00688"></a>00688 {
  718. <a name="l00689"></a>00689 <span class="keywordtype">int</span> arg_lua = arg+1; <span class="comment">// arg N on the Lua stack</span>
  719. <a name="l00690"></a>00690 <span class="keywordtype">int</span> ltype = lua_type(L, arg_lua);
  720. <a name="l00691"></a>00691
  721. <a name="l00692"></a>00692 <span class="keywordflow">for</span> (i = 0; i &lt; cfunc_count; ++i)
  722. <a name="l00693"></a>00693 {
  723. <a name="l00694"></a>00694 <a class="code" href="structwxLuaBindCFunc.html">wxLuaBindCFunc</a>* wxlCFunc = (<a class="code" href="structwxLuaBindCFunc.html">wxLuaBindCFunc</a>*)cfuncArray[i];
  724. <a name="l00695"></a>00695 bestCFunc = wxlCFunc;
  725. <a name="l00696"></a>00696 invalid_lua_arg = arg_lua;
  726. <a name="l00697"></a>00697
  727. <a name="l00698"></a>00698 <span class="comment">// does this method have any more arguments?</span>
  728. <a name="l00699"></a>00699 <span class="keywordflow">if</span> (!wxlCFunc-&gt;<a class="code" href="structwxLuaBindCFunc.html#aefe2c60616304f09c47eade1163a4b27">argtypes</a>[arg])
  729. <a name="l00700"></a>00700 {
  730. <a name="l00701"></a>00701 cfuncArray.RemoveAt(i);
  731. <a name="l00702"></a>00702 cfunc_count--;
  732. <a name="l00703"></a>00703 i--;
  733. <a name="l00704"></a>00704 <span class="keywordflow">continue</span>;
  734. <a name="l00705"></a>00705 }
  735. <a name="l00706"></a>00706
  736. <a name="l00707"></a>00707 <span class="comment">// get argument wxLua type</span>
  737. <a name="l00708"></a>00708 <span class="keywordtype">int</span> wxl_type = (int)*(wxlCFunc-&gt;<a class="code" href="structwxLuaBindCFunc.html#aefe2c60616304f09c47eade1163a4b27">argtypes</a>[arg]);
  738. <a name="l00709"></a>00709
  739. <a name="l00710"></a>00710 <span class="comment">// Does the Lua type match the wxLua type</span>
  740. <a name="l00711"></a>00711 <span class="keywordtype">int</span> is_ok = <a class="code" href="wxlstate_8h.html#a47f2034cabf94ca87dde758af863f4e2">wxlua_iswxluatype</a>(ltype, wxl_type, L);
  741. <a name="l00712"></a>00712
  742. <a name="l00713"></a>00713 <span class="comment">// unknown/invalid standard wxLua type, check binding wxLua type</span>
  743. <a name="l00714"></a>00714 <span class="keywordflow">if</span> ((is_ok == -1) || ((is_ok == 0) &amp;&amp; (wxl_type == <a class="code" href="wxlbind_8h.html#a2e521227720c7b42b9fe076b1e944405">WXLUA_TSTRING</a>)))
  744. <a name="l00715"></a>00715 {
  745. <a name="l00716"></a>00716 is_ok = (<a class="code" href="wxlstate_8h.html#a1602757335e28069aa1d9416a5c53ac2">wxluaT_isuserdatatype</a>(L, arg_lua, wxl_type) ||
  746. <a name="l00717"></a>00717 (wxl_type == <a class="code" href="wxlbind_8cpp.html#ada2f84390e66116604bfa8d5102c7305">wxluatype_NULL</a>)) ? 1 : 0;
  747. <a name="l00718"></a>00718 }
  748. <a name="l00719"></a>00719
  749. <a name="l00720"></a>00720 <span class="comment">// this arg is not a match, remove this function as a possibility</span>
  750. <a name="l00721"></a>00721 <span class="keywordflow">if</span> (is_ok == 0)
  751. <a name="l00722"></a>00722 {
  752. <a name="l00723"></a>00723 cfuncArray.RemoveAt(i);
  753. <a name="l00724"></a>00724 cfunc_count--;
  754. <a name="l00725"></a>00725 i--;
  755. <a name="l00726"></a>00726 <span class="keywordflow">continue</span>;
  756. <a name="l00727"></a>00727 }
  757. <a name="l00728"></a>00728 }
  758. <a name="l00729"></a>00729 }
  759. <a name="l00730"></a>00730
  760. <a name="l00731"></a>00731 <span class="comment">// Note that the top function is the one that is highest in the</span>
  761. <a name="l00732"></a>00732 <span class="comment">// derived functions from any baseclasses and should be the best choice.</span>
  762. <a name="l00733"></a>00733 <span class="comment">// Example is wxBookCtrlBaseEvent::GetSelection() and wxCommandEvent::GetSelection()</span>
  763. <a name="l00734"></a>00734 <span class="keywordflow">if</span> (cfunc_count &gt; 0)
  764. <a name="l00735"></a>00735 {
  765. <a name="l00736"></a>00736 lua_CFunction lua_cfunc = ((<a class="code" href="structwxLuaBindCFunc.html">wxLuaBindCFunc</a>*)cfuncArray[0])-&gt;lua_cfunc;
  766. <a name="l00737"></a>00737
  767. <a name="l00738"></a>00738 <span class="comment">// successfully found overloaded function to handle wxLua call</span>
  768. <a name="l00739"></a>00739 <span class="keywordflow">return</span> (*lua_cfunc)(L);
  769. <a name="l00740"></a>00740 }
  770. <a name="l00741"></a>00741
  771. <a name="l00742"></a>00742 <span class="comment">// ----------------------------------------------------------------------</span>
  772. <a name="l00743"></a>00743 <span class="comment">// Did not find a suitable function to call, post error</span>
  773. <a name="l00744"></a>00744
  774. <a name="l00745"></a>00745 wxString fnCall = <a class="code" href="wxlbind_8h.html#a15f78fa970b76c7963c3e11f90d988ca">wxlua_getLuaArgsMsg</a>(L, 1, arg_lua_count);
  775. <a name="l00746"></a>00746
  776. <a name="l00747"></a>00747 wxString fnOverloadList = wxString::Format(wxT(<span class="stringliteral">&quot;Function called: &#39;%s&#39;\n&quot;</span>), fnCall.c_str());
  777. <a name="l00748"></a>00748 fnOverloadList += <a class="code" href="wxlbind_8h.html#a0cf1f6600d0f80e2135c6788a4afc39f">wxlua_getBindMethodArgsMsg</a>(L, wxlMethod);
  778. <a name="l00749"></a>00749
  779. <a name="l00750"></a>00750 wxString errmsg;
  780. <a name="l00751"></a>00751
  781. <a name="l00752"></a>00752 <span class="keywordflow">if</span> (cfunc_count &gt; 1) <span class="comment">// Note: we actually allow this.. for now</span>
  782. <a name="l00753"></a>00753 {
  783. <a name="l00754"></a>00754 errmsg = wxT(<span class="stringliteral">&quot;wxLua: Function call is ambiguous.\nTry coercing values to proper types using tostring/number as appropriate.\n&quot;</span>);
  784. <a name="l00755"></a>00755 }
  785. <a name="l00756"></a>00756
  786. <a name="l00757"></a>00757 <span class="keywordflow">if</span> (bestCFunc == NULL)
  787. <a name="l00758"></a>00758 errmsg += wxT(<span class="stringliteral">&quot;wxLua: Function call has invalid arguments.&quot;</span>);
  788. <a name="l00759"></a>00759 <span class="keywordflow">else</span>
  789. <a name="l00760"></a>00760 {
  790. <a name="l00761"></a>00761 <span class="comment">// We have to count the methods that are displayed to find the one that failed</span>
  791. <a name="l00762"></a>00762 <span class="comment">// since we&#39;ve skipped the ones with wrong number of args.</span>
  792. <a name="l00763"></a>00763 method = wxlMethod;
  793. <a name="l00764"></a>00764 <span class="keywordtype">int</span> i_cfunc = 0;
  794. <a name="l00765"></a>00765 <span class="keywordtype">bool</span> found = <span class="keyword">false</span>;
  795. <a name="l00766"></a>00766 <span class="keywordflow">while</span> (method &amp;&amp; !found)
  796. <a name="l00767"></a>00767 {
  797. <a name="l00768"></a>00768 <span class="keywordflow">for</span> (i = 0; i &lt; method-&gt;<a class="code" href="structwxLuaBindMethod.html#a36285f0c5431ed28e8951b26706ee3c5">wxluacfuncs_n</a>; ++i)
  798. <a name="l00769"></a>00769 {
  799. <a name="l00770"></a>00770 i_cfunc++;
  800. <a name="l00771"></a>00771 <span class="keywordflow">if</span> (&amp;method-&gt;<a class="code" href="structwxLuaBindMethod.html#abcc43fb837b299e7fc088fb787ad3aca">wxluacfuncs</a>[i] == bestCFunc)
  801. <a name="l00772"></a>00772 {
  802. <a name="l00773"></a>00773 found = <span class="keyword">true</span>;
  803. <a name="l00774"></a>00774 <span class="keywordflow">break</span>;
  804. <a name="l00775"></a>00775 }
  805. <a name="l00776"></a>00776 }
  806. <a name="l00777"></a>00777
  807. <a name="l00778"></a>00778 method = method-&gt;<a class="code" href="structwxLuaBindMethod.html#a61bd0c007d8c7064a473d19eac6dd2a6">basemethod</a>;
  808. <a name="l00779"></a>00779 }
  809. <a name="l00780"></a>00780
  810. <a name="l00781"></a>00781 errmsg += wxString::Format(wxT(<span class="stringliteral">&quot;wxLua: Function call has invalid argument %d on method %02d.\n&quot;</span>), invalid_lua_arg, i_cfunc);
  811. <a name="l00782"></a>00782 }
  812. <a name="l00783"></a>00783
  813. <a name="l00784"></a>00784 errmsg += wxT(<span class="stringliteral">&quot;\n&quot;</span>) + fnOverloadList;
  814. <a name="l00785"></a>00785
  815. <a name="l00786"></a>00786 <a class="code" href="wxlstate_8h.html#a1abe07e896f1e813fc28da0e0d92961a">wxlua_error</a>(L, errmsg);
  816. <a name="l00787"></a>00787
  817. <a name="l00788"></a>00788 <span class="keywordflow">return</span> 0;
  818. <a name="l00789"></a>00789 }
  819. <a name="l00790"></a>00790
  820. <a name="l00791"></a><a class="code" href="wxlbind_8cpp.html#abed92a2250b699850cd5bd490c23bab1">00791</a> wxString <a class="code" href="wxlbind_8h.html#a15f78fa970b76c7963c3e11f90d988ca">wxlua_getLuaArgsMsg</a>(lua_State* L, <span class="keywordtype">int</span> start_stack_idx, <span class="keywordtype">int</span> end_stack_idx)
  821. <a name="l00792"></a>00792 {
  822. <a name="l00793"></a>00793 lua_Debug ar = {0};
  823. <a name="l00794"></a>00794
  824. <a name="l00795"></a>00795 <span class="comment">// NOTE: We&#39;d like to be able to give some info, however if we are not</span>
  825. <a name="l00796"></a>00796 <span class="comment">// running a Lua function the lua_Debug is empty and lua_getinfo() will panic.</span>
  826. <a name="l00797"></a>00797 <span class="keywordflow">if</span> (lua_getstack(L, 0, &amp;ar) == 0) <span class="comment">// returns 0 when called on a level greater than stack depth</span>
  827. <a name="l00798"></a>00798 <span class="keywordflow">return</span> wxT(<span class="stringliteral">&quot;?&quot;</span>);
  828. <a name="l00799"></a>00799
  829. <a name="l00800"></a>00800 lua_getinfo(L, <span class="stringliteral">&quot;n&quot;</span>, &amp;ar);
  830. <a name="l00801"></a>00801 wxString funcName = <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(ar.name);
  831. <a name="l00802"></a>00802
  832. <a name="l00803"></a>00803 wxString funcCall = funcName + wxT(<span class="stringliteral">&quot;(&quot;</span>);
  833. <a name="l00804"></a>00804
  834. <a name="l00805"></a>00805 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> arg = start_stack_idx; arg &lt;= end_stack_idx; ++arg)
  835. <a name="l00806"></a>00806 {
  836. <a name="l00807"></a>00807 <span class="keywordflow">if</span> (arg &gt; start_stack_idx) funcCall += wxT(<span class="stringliteral">&quot;, &quot;</span>);
  837. <a name="l00808"></a>00808
  838. <a name="l00809"></a>00809 funcCall += <a class="code" href="wxlstate_8h.html#a3d22f924c535006b6202120af11939ae">wxluaT_gettypename</a>(L, arg);
  839. <a name="l00810"></a>00810 }
  840. <a name="l00811"></a>00811 funcCall += wxT(<span class="stringliteral">&quot;)&quot;</span>);
  841. <a name="l00812"></a>00812
  842. <a name="l00813"></a>00813 <span class="keywordflow">return</span> funcCall;
  843. <a name="l00814"></a>00814 }
  844. <a name="l00815"></a>00815
  845. <a name="l00816"></a><a class="code" href="wxlbind_8cpp.html#ad564ea8b07ae4820e9c5916a66f6890a">00816</a> wxString <a class="code" href="wxlbind_8h.html#a0cf1f6600d0f80e2135c6788a4afc39f">wxlua_getBindMethodArgsMsg</a>(lua_State* L, <span class="keyword">struct</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod)
  846. <a name="l00817"></a>00817 {
  847. <a name="l00818"></a>00818 wxCHECK_MSG(wxlMethod, wxEmptyString, wxT(<span class="stringliteral">&quot;Invalid method table&quot;</span>));
  848. <a name="l00819"></a>00819
  849. <a name="l00820"></a>00820 wxString overloadMethods;
  850. <a name="l00821"></a>00821
  851. <a name="l00822"></a>00822 <span class="keywordtype">int</span> i_cfunc = 0; <span class="comment">// count total number of overloads</span>
  852. <a name="l00823"></a>00823 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* method = wxlMethod;
  853. <a name="l00824"></a>00824
  854. <a name="l00825"></a>00825 <span class="comment">// traverse the methods down the baseclass methods if any</span>
  855. <a name="l00826"></a>00826 <span class="keywordflow">while</span> (method)
  856. <a name="l00827"></a>00827 {
  857. <a name="l00828"></a>00828 <a class="code" href="structwxLuaBindCFunc.html">wxLuaBindCFunc</a>* wxluacfuncs = method-&gt;<a class="code" href="structwxLuaBindMethod.html#abcc43fb837b299e7fc088fb787ad3aca">wxluacfuncs</a>;
  858. <a name="l00829"></a>00829 <span class="keywordtype">int</span> i, arg, cfuncs_count = method-&gt;<a class="code" href="structwxLuaBindMethod.html#a36285f0c5431ed28e8951b26706ee3c5">wxluacfuncs_n</a>;
  859. <a name="l00830"></a>00830 wxString className;
  860. <a name="l00831"></a>00831
  861. <a name="l00832"></a>00832 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = <a class="code" href="classwxLuaBinding.html#a7ee5e4f66198a0ef9e8cc4c2a6d0318e">wxLuaBinding::FindBindClass</a>(method);
  862. <a name="l00833"></a>00833 <span class="keywordflow">if</span> (wxlClass)
  863. <a name="l00834"></a>00834 className = <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#af89cbb87774c38c593f7ed87a68fffcb">name</a>) + wxT(<span class="stringliteral">&quot;::&quot;</span>);
  864. <a name="l00835"></a>00835
  865. <a name="l00836"></a>00836 <span class="keywordflow">for</span> (i = 0; i &lt; cfuncs_count; ++i)
  866. <a name="l00837"></a>00837 {
  867. <a name="l00838"></a>00838 i_cfunc++;
  868. <a name="l00839"></a>00839
  869. <a name="l00840"></a>00840 wxString funcStr = wxString::Format(wxT(<span class="stringliteral">&quot;%02d. %s%s(&quot;</span>), i_cfunc, className.c_str(), <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(method-&gt;<a class="code" href="structwxLuaBindMethod.html#afef5590cd8bd8a9906b658ddcadb674c">name</a>).c_str());
  870. <a name="l00841"></a>00841
  871. <a name="l00842"></a>00842 <span class="keywordflow">for</span> (arg = 0; arg &lt; wxluacfuncs[i].<a class="code" href="structwxLuaBindCFunc.html#a763cb668b2e1e6f13eafe1e922612c82">maxargs</a>; ++arg)
  872. <a name="l00843"></a>00843 {
  873. <a name="l00844"></a>00844 <span class="comment">// optional args?</span>
  874. <a name="l00845"></a>00845 <span class="keywordflow">if</span> ((wxluacfuncs[i].minargs &lt; wxluacfuncs[i].maxargs) &amp;&amp; (arg+1 == wxluacfuncs[i].<a class="code" href="structwxLuaBindCFunc.html#ab76dacd34dc14e51d580d353aad17017">minargs</a>))
  875. <a name="l00846"></a>00846 {
  876. <a name="l00847"></a>00847 <span class="keywordflow">if</span> (arg &gt; 0) funcStr += wxT(<span class="stringliteral">&quot; &quot;</span>);
  877. <a name="l00848"></a>00848 funcStr += wxT(<span class="stringliteral">&quot;[&quot;</span>);
  878. <a name="l00849"></a>00849 }
  879. <a name="l00850"></a>00850
  880. <a name="l00851"></a>00851 <span class="keywordflow">if</span> (arg &gt; 0)
  881. <a name="l00852"></a>00852 funcStr += wxT(<span class="stringliteral">&quot;, &quot;</span>);
  882. <a name="l00853"></a>00853
  883. <a name="l00854"></a>00854 <span class="keywordtype">int</span> wxl_type = (int)*(wxluacfuncs[i].argtypes[arg]);
  884. <a name="l00855"></a>00855 funcStr += <a class="code" href="wxlstate_8h.html#a6621fa5a456448acfd515112aa7b23e1">wxluaT_typename</a>(L, wxl_type);
  885. <a name="l00856"></a>00856
  886. <a name="l00857"></a>00857 <span class="keywordflow">if</span> ((arg == 0) &amp;&amp;
  887. <a name="l00858"></a>00858 !<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxluacfuncs[i].method_type, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fad2e593a9652e9ce570c780473db925a1">WXLUAMETHOD_STATIC</a>) &amp;&amp;
  888. <a name="l00859"></a>00859 !<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxluacfuncs[i].method_type, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa17851433f53b5c36f8832826c632a620">WXLUAMETHOD_CONSTRUCTOR</a>) &amp;&amp;
  889. <a name="l00860"></a>00860 !<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxluacfuncs[i].method_type, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa9d1e4fafb81ea95073b95c8e92153fbf">WXLUAMETHOD_CFUNCTION</a>))
  890. <a name="l00861"></a>00861 funcStr += wxT(<span class="stringliteral">&quot;(self)&quot;</span>);
  891. <a name="l00862"></a>00862 }
  892. <a name="l00863"></a>00863
  893. <a name="l00864"></a>00864 <span class="comment">// close optional args</span>
  894. <a name="l00865"></a>00865 <span class="keywordflow">if</span> (wxluacfuncs[i].minargs &lt; wxluacfuncs[i].maxargs)
  895. <a name="l00866"></a>00866 funcStr += wxT(<span class="stringliteral">&quot;]&quot;</span>);
  896. <a name="l00867"></a>00867
  897. <a name="l00868"></a>00868 funcStr += wxT(<span class="stringliteral">&quot;)&quot;</span>);
  898. <a name="l00869"></a>00869
  899. <a name="l00870"></a>00870 <span class="keywordflow">if</span> (<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxluacfuncs[i].method_type, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fad2e593a9652e9ce570c780473db925a1">WXLUAMETHOD_STATIC</a>))
  900. <a name="l00871"></a>00871 funcStr += wxT(<span class="stringliteral">&quot; - static&quot;</span>);
  901. <a name="l00872"></a>00872
  902. <a name="l00873"></a>00873 <span class="keywordflow">if</span> (overloadMethods.Length() &gt; 0)
  903. <a name="l00874"></a>00874 overloadMethods += wxT(<span class="stringliteral">&quot;\n&quot;</span>) + funcStr;
  904. <a name="l00875"></a>00875 <span class="keywordflow">else</span>
  905. <a name="l00876"></a>00876 overloadMethods += funcStr;
  906. <a name="l00877"></a>00877 }
  907. <a name="l00878"></a>00878
  908. <a name="l00879"></a>00879 method = method-&gt;<a class="code" href="structwxLuaBindMethod.html#a61bd0c007d8c7064a473d19eac6dd2a6">basemethod</a>;
  909. <a name="l00880"></a>00880 }
  910. <a name="l00881"></a>00881
  911. <a name="l00882"></a>00882 <span class="keywordflow">return</span> overloadMethods;
  912. <a name="l00883"></a>00883 }
  913. <a name="l00884"></a>00884
  914. <a name="l00885"></a>00885 <span class="comment">// ----------------------------------------------------------------------------</span>
  915. <a name="l00886"></a>00886 <span class="comment">// Functions to compare binding structs using qsort and bsearch</span>
  916. <a name="l00887"></a>00887 <span class="comment">// ----------------------------------------------------------------------------</span>
  917. <a name="l00888"></a>00888
  918. <a name="l00889"></a>00889 <span class="comment">// Function to compare to wxLuaBindEvents by eventType</span>
  919. <a name="l00890"></a><a class="code" href="wxlbind_8cpp.html#a600e79368d13cac59932d82c5cc1439c">00890</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#a600e79368d13cac59932d82c5cc1439c">wxLuaBindEventArrayCompareFn</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *p1, <span class="keyword">const</span> <span class="keywordtype">void</span> *p2)
  920. <a name="l00891"></a>00891 {
  921. <a name="l00892"></a>00892 <span class="keywordflow">return</span> (*((<span class="keyword">const</span> <a class="code" href="structwxLuaBindEvent.html">wxLuaBindEvent</a>*)p1)-&gt;eventType) - (*((<span class="keyword">const</span> <a class="code" href="structwxLuaBindEvent.html">wxLuaBindEvent</a>*)p2)-&gt;eventType);
  922. <a name="l00893"></a>00893 }
  923. <a name="l00894"></a>00894 <span class="comment">// Function to compare to wxLuaBindNumber by name</span>
  924. <a name="l00895"></a><a class="code" href="wxlbind_8cpp.html#ac555a84bd4aaa65442c7348524283b74">00895</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#ac555a84bd4aaa65442c7348524283b74">wxLuaBindNumberArrayCompareFn</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *p1, <span class="keyword">const</span> <span class="keywordtype">void</span> *p2)
  925. <a name="l00896"></a>00896 {
  926. <a name="l00897"></a>00897 <span class="keywordflow">return</span> strcmp(((<span class="keyword">const</span> <a class="code" href="structwxLuaBindNumber.html">wxLuaBindNumber</a>*)p1)-&gt;name, ((<span class="keyword">const</span> <a class="code" href="structwxLuaBindNumber.html">wxLuaBindNumber</a>*)p2)-&gt;name);
  927. <a name="l00898"></a>00898 }
  928. <a name="l00899"></a>00899 <span class="comment">// Function to compare to wxLuaBindStrings by name</span>
  929. <a name="l00900"></a><a class="code" href="wxlbind_8cpp.html#a085763459baf1ce6926bbb7640414d79">00900</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#a085763459baf1ce6926bbb7640414d79">wxLuaBindStringArrayCompareFn</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *p1, <span class="keyword">const</span> <span class="keywordtype">void</span> *p2)
  930. <a name="l00901"></a>00901 {
  931. <a name="l00902"></a>00902 <span class="keywordflow">return</span> strcmp(((<span class="keyword">const</span> <a class="code" href="structwxLuaBindString.html">wxLuaBindString</a>*)p1)-&gt;name, ((<span class="keyword">const</span> <a class="code" href="structwxLuaBindString.html">wxLuaBindString</a>*)p2)-&gt;name);
  932. <a name="l00903"></a>00903 }
  933. <a name="l00904"></a>00904 <span class="comment">// Function to compare to wxLuaBindObjects by name</span>
  934. <a name="l00905"></a><a class="code" href="wxlbind_8cpp.html#a90818d2e0afcef8e88d466e5fdfc3695">00905</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#a90818d2e0afcef8e88d466e5fdfc3695">wxLuaBindObjectArrayCompareFn</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *p1, <span class="keyword">const</span> <span class="keywordtype">void</span> *p2)
  935. <a name="l00906"></a>00906 {
  936. <a name="l00907"></a>00907 <span class="keywordflow">return</span> strcmp(((<span class="keyword">const</span> <a class="code" href="structwxLuaBindObject.html">wxLuaBindObject</a>*)p1)-&gt;name, ((<span class="keyword">const</span> <a class="code" href="structwxLuaBindObject.html">wxLuaBindObject</a>*)p2)-&gt;name);
  937. <a name="l00908"></a>00908 }
  938. <a name="l00909"></a>00909 <span class="comment">// Function to compare to wxLuaBindMethods by name</span>
  939. <a name="l00910"></a><a class="code" href="wxlbind_8cpp.html#ac8bd4d99006dd1ceccbbd7976c62bca6">00910</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#ac8bd4d99006dd1ceccbbd7976c62bca6">wxLuaBindMethodArrayCompareFnInit</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *p1, <span class="keyword">const</span> <span class="keywordtype">void</span> *p2)
  940. <a name="l00911"></a>00911 {
  941. <a name="l00912"></a>00912 <span class="keywordtype">int</span> v = strcmp(((<span class="keyword">const</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>*)p1)-&gt;name, ((<span class="keyword">const</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>*)p2)-&gt;name);
  942. <a name="l00913"></a>00913 <span class="keywordflow">if</span> (v == 0)
  943. <a name="l00914"></a>00914 {
  944. <a name="l00915"></a>00915 <span class="keywordtype">int</span> t1 = <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa89f98b585bf6ff387d17a22c04d61990">WXLUAMETHOD_SORT_MASK</a> &amp; ((<span class="keyword">const</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>*)p1)-&gt;method_type;
  945. <a name="l00916"></a>00916 <span class="keywordtype">int</span> t2 = <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa89f98b585bf6ff387d17a22c04d61990">WXLUAMETHOD_SORT_MASK</a> &amp; ((<span class="keyword">const</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>*)p2)-&gt;method_type;
  946. <a name="l00917"></a>00917 v = t1 - t2;
  947. <a name="l00918"></a>00918 }
  948. <a name="l00919"></a>00919
  949. <a name="l00920"></a>00920 wxCHECK_MSG(v != 0, 0, wxT(<span class="stringliteral">&quot;Duplicate wxLuaBindMethod names and method_types&quot;</span>));
  950. <a name="l00921"></a>00921
  951. <a name="l00922"></a>00922 <span class="keywordflow">return</span> v;
  952. <a name="l00923"></a>00923 }
  953. <a name="l00924"></a>00924 <span class="comment">// Function for wxLuaBinding::GetClassMethod()</span>
  954. <a name="l00925"></a><a class="code" href="wxlbind_8cpp.html#a08f882d65e213f81b1e29502e71eb174">00925</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#a08f882d65e213f81b1e29502e71eb174">wxLuaBindMethodArrayCompareFnGet</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *p1, <span class="keyword">const</span> <span class="keywordtype">void</span> *p2)
  955. <a name="l00926"></a>00926 {
  956. <a name="l00927"></a>00927 <span class="keywordtype">int</span> v = strcmp(((<span class="keyword">const</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>*)p1)-&gt;name, ((<span class="keyword">const</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>*)p2)-&gt;name);
  957. <a name="l00928"></a>00928 <span class="keywordflow">if</span> (v == 0)
  958. <a name="l00929"></a>00929 {
  959. <a name="l00930"></a>00930 <span class="keywordtype">int</span> t1 = <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa9dbba989648af34b28cf6a050a41ac46">WXLUAMETHOD_SEARCH_MASK</a> &amp; ((<span class="keyword">const</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>*)p1)-&gt;method_type;
  960. <a name="l00931"></a>00931 <span class="keywordtype">int</span> t2 = <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa9dbba989648af34b28cf6a050a41ac46">WXLUAMETHOD_SEARCH_MASK</a> &amp; ((<span class="keyword">const</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>*)p2)-&gt;method_type;
  961. <a name="l00932"></a>00932
  962. <a name="l00933"></a>00933 <span class="keywordflow">if</span> ((t1 &amp; t2) != 0) <span class="keywordflow">return</span> 0; <span class="comment">// any matched bits will work</span>
  963. <a name="l00934"></a>00934
  964. <a name="l00935"></a>00935 v = t1 - t2;
  965. <a name="l00936"></a>00936 }
  966. <a name="l00937"></a>00937
  967. <a name="l00938"></a>00938 <span class="keywordflow">return</span> v;
  968. <a name="l00939"></a>00939 }
  969. <a name="l00940"></a>00940 <span class="comment">// Function to compare the wxLuaBindClasses by name</span>
  970. <a name="l00941"></a><a class="code" href="wxlbind_8cpp.html#a6625687e644b2f8fa02fba6d7844e0cf">00941</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#a6625687e644b2f8fa02fba6d7844e0cf">wxLuaBindClassArrayCompareFn</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *p1, <span class="keyword">const</span> <span class="keywordtype">void</span> *p2)
  971. <a name="l00942"></a>00942 {
  972. <a name="l00943"></a>00943 <span class="keywordflow">return</span> strcmp(((<span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>*)p1)-&gt;name, ((<span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>*)p2)-&gt;name);
  973. <a name="l00944"></a>00944 }
  974. <a name="l00945"></a>00945 <span class="comment">// Function to compare the wxLuaBindClasses by wxluatype</span>
  975. <a name="l00946"></a><a class="code" href="wxlbind_8cpp.html#af461c435b97f5d2ff20e13510073d7b0">00946</a> <span class="keywordtype">int</span> <a class="code" href="wxlbind_8cpp.html#af461c435b97f5d2ff20e13510073d7b0">wxLuaBindClassArrayCompareBywxLuaType</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *p1, <span class="keyword">const</span> <span class="keywordtype">void</span> *p2)
  976. <a name="l00947"></a>00947 {
  977. <a name="l00948"></a>00948 <span class="keywordflow">return</span> (*((<span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>*)p1)-&gt;wxluatype) - (*((<span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>*)p2)-&gt;wxluatype);
  978. <a name="l00949"></a>00949 }
  979. <a name="l00950"></a>00950
  980. <a name="l00951"></a>00951 <span class="comment">// ----------------------------------------------------------------------------</span>
  981. <a name="l00952"></a>00952 <span class="comment">// wxLuaBinding</span>
  982. <a name="l00953"></a>00953 <span class="comment">// ----------------------------------------------------------------------------</span>
  983. <a name="l00954"></a>00954
  984. <a name="l00955"></a>00955 <a class="code" href="wxlsock_8cpp.html#abdcf9eaaef19410a688aa559de382a29">IMPLEMENT_ABSTRACT_CLASS</a>(<a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>, wxObject)
  985. <a name="l00956"></a>00956
  986. <a name="l00957"></a>00957 wxLuaBindingList <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>::sm_bindingList;
  987. <a name="l00958"></a>00958 <span class="keywordtype">bool</span> <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>::sm_bindingList_initialized = false;
  988. <a name="l00959"></a>00959 <span class="keywordtype">int</span> <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>::sm_wxluatype_max = <a class="code" href="wxlbind_8h.html#a5c88c9256d02ad58bc27ea8744c35597">WXLUA_T_MAX</a>+1; <span class="comment">// highest wxLua type initially</span>
  989. <a name="l00960"></a>00960
  990. <a name="l00961"></a><a class="code" href="classwxLuaBinding.html#a9c6bd2da8633caeb67b40d316d755c86">00961</a> <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>::<a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>()
  991. <a name="l00962"></a>00962 :m_classCount(0), m_classArray(NULL),
  992. <a name="l00963"></a>00963 m_numberCount(0), m_numberArray(NULL),
  993. <a name="l00964"></a>00964 m_stringCount(0), m_stringArray(NULL),
  994. <a name="l00965"></a>00965 m_eventCount(0), m_eventArray(NULL),
  995. <a name="l00966"></a>00966 m_objectCount(0), m_objectArray(NULL),
  996. <a name="l00967"></a>00967 m_functionCount(0), m_functionArray(NULL),
  997. <a name="l00968"></a>00968 m_first_wxluatype(<a class="code" href="wxlbind_8h.html#aeb150b964405f526ef77087288f403b2">WXLUA_TUNKNOWN</a>),
  998. <a name="l00969"></a>00969 m_last_wxluatype(WXLUA_TUNKNOWN)
  999. <a name="l00970"></a>00970 {
  1000. <a name="l00971"></a>00971 }
  1001. <a name="l00972"></a>00972
  1002. <a name="l00973"></a><a class="code" href="classwxLuaBinding.html#a0adc360c99045857d66a8a5ba9260d51">00973</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaBinding.html#a0adc360c99045857d66a8a5ba9260d51">wxLuaBinding::InitBinding</a>()
  1003. <a name="l00974"></a>00974 {
  1004. <a name="l00975"></a>00975 <span class="comment">// Sort all the bindings by something useful for faster lookup later</span>
  1005. <a name="l00976"></a>00976
  1006. <a name="l00977"></a>00977 <span class="keywordflow">if</span> (<a class="code" href="classwxLuaBinding.html#ad49fa01f3b44889af3f0cfabe9ee4fe8">m_classArray</a> &amp;&amp; (<a class="code" href="classwxLuaBinding.html#ab668185325d94999b07fae44ef497016">m_classCount</a> &gt; 0))
  1007. <a name="l00978"></a>00978 {
  1008. <a name="l00979"></a>00979 <span class="comment">// initialize types only once, we don&#39;t need to resort them either</span>
  1009. <a name="l00980"></a>00980 <span class="keywordflow">if</span> (*<a class="code" href="classwxLuaBinding.html#ad49fa01f3b44889af3f0cfabe9ee4fe8">m_classArray</a>[0].wxluatype != <a class="code" href="wxlbind_8h.html#aeb150b964405f526ef77087288f403b2">WXLUA_TUNKNOWN</a>)
  1010. <a name="l00981"></a>00981 <span class="keywordflow">return</span>;
  1011. <a name="l00982"></a>00982
  1012. <a name="l00983"></a>00983 qsort(<a class="code" href="classwxLuaBinding.html#ad49fa01f3b44889af3f0cfabe9ee4fe8">m_classArray</a>, <a class="code" href="classwxLuaBinding.html#ab668185325d94999b07fae44ef497016">m_classCount</a>, <span class="keyword">sizeof</span>(<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>), <a class="code" href="wxlbind_8cpp.html#a6625687e644b2f8fa02fba6d7844e0cf">wxLuaBindClassArrayCompareFn</a>);
  1013. <a name="l00984"></a>00984
  1014. <a name="l00985"></a>00985 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = <a class="code" href="classwxLuaBinding.html#ad49fa01f3b44889af3f0cfabe9ee4fe8">m_classArray</a>;
  1015. <a name="l00986"></a>00986 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; <a class="code" href="classwxLuaBinding.html#ab668185325d94999b07fae44ef497016">m_classCount</a>; ++i, ++wxlClass)
  1016. <a name="l00987"></a>00987 {
  1017. <a name="l00988"></a>00988 *wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a487a56c7a763a21041272c4b053e6c99">wxluatype</a> = ++<a class="code" href="classwxLuaBinding.html#ac2305a8cfb14b5d1caf5c83114dcffdd">wxLuaBinding::sm_wxluatype_max</a>;
  1018. <a name="l00989"></a>00989
  1019. <a name="l00990"></a>00990 <span class="comment">// Also sort the member functions for each class</span>
  1020. <a name="l00991"></a>00991 <span class="keywordflow">if</span> (wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a313c0c5eeb60ca717bae7d286dc41d28">wxluamethods</a> &amp;&amp; (wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a5eac6feca088451706f0fde55dd73393">wxluamethods_n</a> &gt; 0))
  1021. <a name="l00992"></a>00992 qsort(wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a313c0c5eeb60ca717bae7d286dc41d28">wxluamethods</a>, wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a5eac6feca088451706f0fde55dd73393">wxluamethods_n</a>, <span class="keyword">sizeof</span>(<a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>), <a class="code" href="wxlbind_8cpp.html#ac8bd4d99006dd1ceccbbd7976c62bca6">wxLuaBindMethodArrayCompareFnInit</a>);
  1022. <a name="l00993"></a>00993 <span class="comment">// And their enums</span>
  1023. <a name="l00994"></a>00994 <span class="keywordflow">if</span> (wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a62e18d1022d4369511cbf0584990cca4">enums</a> &amp;&amp; (wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#aadcfb36d6f271ada8864f1d88a0ca5fc">enums_n</a> &gt; 0))
  1024. <a name="l00995"></a>00995 qsort(wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a62e18d1022d4369511cbf0584990cca4">enums</a>, wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#aadcfb36d6f271ada8864f1d88a0ca5fc">enums_n</a>, <span class="keyword">sizeof</span>(<a class="code" href="structwxLuaBindNumber.html">wxLuaBindNumber</a>), <a class="code" href="wxlbind_8cpp.html#ac555a84bd4aaa65442c7348524283b74">wxLuaBindNumberArrayCompareFn</a>);
  1025. <a name="l00996"></a>00996 }
  1026. <a name="l00997"></a>00997
  1027. <a name="l00998"></a>00998 <span class="comment">// these mark what types numbers are declared in this binding</span>
  1028. <a name="l00999"></a>00999 <a class="code" href="classwxLuaBinding.html#aeb539e1acc75ea37c2fe40618256eb6d">m_first_wxluatype</a> = *<a class="code" href="classwxLuaBinding.html#ad49fa01f3b44889af3f0cfabe9ee4fe8">m_classArray</a>[0].<a class="code" href="structwxLuaBindClass.html#a487a56c7a763a21041272c4b053e6c99">wxluatype</a>;
  1029. <a name="l01000"></a>01000 <a class="code" href="classwxLuaBinding.html#a951d6dc060ad4efa3957752b01bc0d49">m_last_wxluatype</a> = *<a class="code" href="classwxLuaBinding.html#ad49fa01f3b44889af3f0cfabe9ee4fe8">m_classArray</a>[m_classCount-1].<a class="code" href="structwxLuaBindClass.html#a487a56c7a763a21041272c4b053e6c99">wxluatype</a>;
  1030. <a name="l01001"></a>01001 }
  1031. <a name="l01002"></a>01002
  1032. <a name="l01003"></a>01003 <span class="keywordflow">if</span> (<a class="code" href="classwxLuaBinding.html#a2d7dd4ea59cac79f5ce9d6c3784dfe5c">m_numberArray</a> &amp;&amp; (<a class="code" href="classwxLuaBinding.html#ad448b65743bf6bdf27b31346a176c166">m_numberCount</a> &gt; 0))
  1033. <a name="l01004"></a>01004 qsort(<a class="code" href="classwxLuaBinding.html#a2d7dd4ea59cac79f5ce9d6c3784dfe5c">m_numberArray</a>, <a class="code" href="classwxLuaBinding.html#ad448b65743bf6bdf27b31346a176c166">m_numberCount</a>, <span class="keyword">sizeof</span>(<a class="code" href="structwxLuaBindNumber.html">wxLuaBindNumber</a>), <a class="code" href="wxlbind_8cpp.html#ac555a84bd4aaa65442c7348524283b74">wxLuaBindNumberArrayCompareFn</a>);
  1034. <a name="l01005"></a>01005
  1035. <a name="l01006"></a>01006 <span class="keywordflow">if</span> (<a class="code" href="classwxLuaBinding.html#a2628550ef0a15f71b338b8d3f1bf25d8">m_stringArray</a> &amp;&amp; (<a class="code" href="classwxLuaBinding.html#a1861c30baba1384af84f0889af12cbec">m_stringCount</a> &gt; 0))
  1036. <a name="l01007"></a>01007 qsort(<a class="code" href="classwxLuaBinding.html#a2628550ef0a15f71b338b8d3f1bf25d8">m_stringArray</a>, <a class="code" href="classwxLuaBinding.html#a1861c30baba1384af84f0889af12cbec">m_stringCount</a>, <span class="keyword">sizeof</span>(<a class="code" href="structwxLuaBindString.html">wxLuaBindString</a>), <a class="code" href="wxlbind_8cpp.html#a085763459baf1ce6926bbb7640414d79">wxLuaBindStringArrayCompareFn</a>);
  1037. <a name="l01008"></a>01008
  1038. <a name="l01009"></a>01009 <span class="comment">// sort by event type for fastest lookup</span>
  1039. <a name="l01010"></a>01010 <span class="keywordflow">if</span> (<a class="code" href="classwxLuaBinding.html#ac80f0d9d548d389a5b02ad9a3e8806a7">m_eventArray</a> &amp;&amp; (<a class="code" href="classwxLuaBinding.html#a74ce8ec75efc3422cc56558c72382960">m_eventCount</a> &gt; 0))
  1040. <a name="l01011"></a>01011 qsort(<a class="code" href="classwxLuaBinding.html#ac80f0d9d548d389a5b02ad9a3e8806a7">m_eventArray</a>, <a class="code" href="classwxLuaBinding.html#a74ce8ec75efc3422cc56558c72382960">m_eventCount</a>, <span class="keyword">sizeof</span>(<a class="code" href="structwxLuaBindEvent.html">wxLuaBindEvent</a>), <a class="code" href="wxlbind_8cpp.html#a600e79368d13cac59932d82c5cc1439c">wxLuaBindEventArrayCompareFn</a>);
  1041. <a name="l01012"></a>01012
  1042. <a name="l01013"></a>01013 <span class="keywordflow">if</span> (<a class="code" href="classwxLuaBinding.html#ac640cacc363dce505f374fe687d4e820">m_objectArray</a> &amp;&amp; (<a class="code" href="classwxLuaBinding.html#afc25c25aea5ef7dcade8234546fac380">m_objectCount</a> &gt; 0))
  1043. <a name="l01014"></a>01014 qsort(<a class="code" href="classwxLuaBinding.html#ac640cacc363dce505f374fe687d4e820">m_objectArray</a>, <a class="code" href="classwxLuaBinding.html#afc25c25aea5ef7dcade8234546fac380">m_objectCount</a>, <span class="keyword">sizeof</span>(<a class="code" href="structwxLuaBindObject.html">wxLuaBindObject</a>), <a class="code" href="wxlbind_8cpp.html#a90818d2e0afcef8e88d466e5fdfc3695">wxLuaBindObjectArrayCompareFn</a>);
  1044. <a name="l01015"></a>01015 }
  1045. <a name="l01016"></a>01016
  1046. <a name="l01017"></a><a class="code" href="classwxLuaBinding.html#a56f0796417c56b0ecee1366ec68484aa">01017</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaBinding.html#a56f0796417c56b0ecee1366ec68484aa">wxLuaBinding::RegisterBinding</a>(<span class="keyword">const</span> <a class="code" href="classwxLuaState.html">wxLuaState</a>&amp; wxlState)
  1047. <a name="l01018"></a>01018 {
  1048. <a name="l01019"></a>01019 wxCHECK_MSG(wxlState.<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), <span class="keyword">false</span>, wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  1049. <a name="l01020"></a>01020 lua_State *L = wxlState.<a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">GetLuaState</a>();
  1050. <a name="l01021"></a>01021
  1051. <a name="l01022"></a>01022 <span class="comment">// Let Lua create a new table for us and add it to these places.</span>
  1052. <a name="l01023"></a>01023 <span class="comment">// We use an empty luaL_Reg since we just want luaI_openlib to create the</span>
  1053. <a name="l01024"></a>01024 <span class="comment">// tables for us, but we want to install the elements ourselves since</span>
  1054. <a name="l01025"></a>01025 <span class="comment">// wxLua is too large to follow the luaI_openlib method without being</span>
  1055. <a name="l01026"></a>01026 <span class="comment">// wasteful of memory and slow down the initialization.</span>
  1056. <a name="l01027"></a>01027 <span class="comment">// LUA_REGISTRYINDEX[&quot;_LOADED&quot;][m_nameSpace] = table</span>
  1057. <a name="l01028"></a>01028 <span class="comment">// LUA_GLOBALSINDEX[m_nameSpace] = table</span>
  1058. <a name="l01029"></a>01029 <span class="comment">// LUA_GLOBALSINDEX[&quot;package&quot;][&quot;loaded&quot;][m_nameSpace] = table</span>
  1059. <a name="l01030"></a>01030 <span class="keyword">static</span> <span class="keyword">const</span> luaL_Reg wxlualib[] = { {NULL, NULL} };
  1060. <a name="l01031"></a>01031 luaI_openlib(L, <a class="code" href="wxlstate_8h.html#a41976a7549ef4bfa7e9a1147dc7b4d55">wx2lua</a>(<a class="code" href="classwxLuaBinding.html#abf0157571f52ff7741e09880fce8f78d">m_nameSpace</a>), wxlualib, 0);
  1061. <a name="l01032"></a>01032
  1062. <a name="l01033"></a>01033 <span class="comment">// luaI_openlib should have given error message about why it couldn&#39;t</span>
  1063. <a name="l01034"></a>01034 <span class="comment">// create the table for us</span>
  1064. <a name="l01035"></a>01035 <span class="keywordflow">if</span> (!lua_istable(L, -1))
  1065. <a name="l01036"></a>01036 {
  1066. <a name="l01037"></a>01037 lua_pop(L, 1); <span class="comment">// pop the nil value</span>
  1067. <a name="l01038"></a>01038 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  1068. <a name="l01039"></a>01039 }
  1069. <a name="l01040"></a>01040
  1070. <a name="l01041"></a>01041 <span class="comment">// Find a registered binding with the same namespace, if any,</span>
  1071. <a name="l01042"></a>01042 <span class="comment">// and share the table with that of the previously loaded binding</span>
  1072. <a name="l01043"></a>01043 <span class="keywordtype">int</span> luaTable_ref = -1;
  1073. <a name="l01044"></a>01044
  1074. <a name="l01045"></a>01045 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a80a0d4c84529abdcf6b46237431832ce">wxlua_lreg_wxluabindings_key</a>); <span class="comment">// push key</span>
  1075. <a name="l01046"></a>01046 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (the bindings table)</span>
  1076. <a name="l01047"></a>01047
  1077. <a name="l01048"></a>01048 lua_pushnil(L);
  1078. <a name="l01049"></a>01049 <span class="keywordflow">while</span> (lua_next(L, -2) != 0)
  1079. <a name="l01050"></a>01050 {
  1080. <a name="l01051"></a>01051 <span class="comment">// value = -1, key = -2, table = -3</span>
  1081. <a name="l01052"></a>01052 <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding = (<a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>*)lua_touserdata(L, -2);
  1082. <a name="l01053"></a>01053
  1083. <a name="l01054"></a>01054 <span class="keywordflow">if</span> (binding-&gt;<a class="code" href="classwxLuaBinding.html#a511674a9760efa5e05eb6fcaf5c5a969">GetLuaNamespace</a>() == <a class="code" href="classwxLuaBinding.html#abf0157571f52ff7741e09880fce8f78d">m_nameSpace</a>)
  1084. <a name="l01055"></a>01055 {
  1085. <a name="l01056"></a>01056 luaTable_ref = (int)lua_tonumber(L, -1);
  1086. <a name="l01057"></a>01057 lua_pop(L, 2); <span class="comment">// pop key and value</span>
  1087. <a name="l01058"></a>01058 <span class="keywordflow">break</span>;
  1088. <a name="l01059"></a>01059 }
  1089. <a name="l01060"></a>01060
  1090. <a name="l01061"></a>01061 lua_pop(L, 1); <span class="comment">// pop value, lua_next will pop key at end</span>
  1091. <a name="l01062"></a>01062 }
  1092. <a name="l01063"></a>01063
  1093. <a name="l01064"></a>01064 lua_pop(L, 1); <span class="comment">// pop table</span>
  1094. <a name="l01065"></a>01065
  1095. <a name="l01066"></a>01066
  1096. <a name="l01067"></a>01067 <span class="comment">// first time adding this namespace table</span>
  1097. <a name="l01068"></a>01068 <span class="keywordflow">if</span> (luaTable_ref &lt; 1)
  1098. <a name="l01069"></a>01069 {
  1099. <a name="l01070"></a>01070 <span class="comment">// create a ref for the wxLua table we&#39;re filling</span>
  1100. <a name="l01071"></a>01071 luaTable_ref = <a class="code" href="wxlstate_8h.html#acbf0a32ad4b828026bd7f643557646d0">wxluaR_ref</a>(L, -1, &amp;<a class="code" href="wxlstate_8h.html#ac4ac0a3575fafde31e659ced85f69c4d">wxlua_lreg_refs_key</a>);
  1101. <a name="l01072"></a>01072 }
  1102. <a name="l01073"></a>01073
  1103. <a name="l01074"></a>01074 <span class="comment">// Add us to the LUA_REGISTRYINDEX table of bindings</span>
  1104. <a name="l01075"></a>01075 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a80a0d4c84529abdcf6b46237431832ce">wxlua_lreg_wxluabindings_key</a>); <span class="comment">// push key</span>
  1105. <a name="l01076"></a>01076 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push value (the bindings table)</span>
  1106. <a name="l01077"></a>01077
  1107. <a name="l01078"></a>01078 lua_pushlightuserdata(L, <span class="keyword">this</span>); <span class="comment">// push key</span>
  1108. <a name="l01079"></a>01079 lua_pushnumber(L, luaTable_ref); <span class="comment">// push value</span>
  1109. <a name="l01080"></a>01080 lua_rawset(L, -3); <span class="comment">// set t[key] = value; pop key and value</span>
  1110. <a name="l01081"></a>01081 lua_pop(L, 1); <span class="comment">// pop table</span>
  1111. <a name="l01082"></a>01082
  1112. <a name="l01083"></a>01083 <span class="comment">// register all our classes etc. in the wxLua table</span>
  1113. <a name="l01084"></a>01084 <a class="code" href="classwxLuaBinding.html#a954fd5c7fcc18adc4886ad9c1a36d08c">DoRegisterBinding</a>(wxlState);
  1114. <a name="l01085"></a>01085
  1115. <a name="l01086"></a>01086 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  1116. <a name="l01087"></a>01087 }
  1117. <a name="l01088"></a>01088
  1118. <a name="l01089"></a><a class="code" href="classwxLuaBinding.html#a954fd5c7fcc18adc4886ad9c1a36d08c">01089</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaBinding.html#a954fd5c7fcc18adc4886ad9c1a36d08c">wxLuaBinding::DoRegisterBinding</a>(<span class="keyword">const</span> <a class="code" href="classwxLuaState.html">wxLuaState</a>&amp; wxlState)<span class="keyword"> const</span>
  1119. <a name="l01090"></a>01090 <span class="keyword"></span>{
  1120. <a name="l01091"></a>01091 wxCHECK_RET(wxlState.<a class="code" href="classwxLuaState.html#a0a2d167b9d6d1259066d9aa771ad075e">Ok</a>(), wxT(<span class="stringliteral">&quot;Invalid wxLuaState&quot;</span>));
  1121. <a name="l01092"></a>01092 lua_State *L = wxlState.<a class="code" href="classwxLuaState.html#af0b735eca529b1fc428a0aa08d0b7434">GetLuaState</a>();
  1122. <a name="l01093"></a>01093
  1123. <a name="l01094"></a>01094 <span class="keywordtype">size_t</span> n;
  1124. <a name="l01095"></a>01095
  1125. <a name="l01096"></a>01096 <span class="comment">// install the classes, functions and methods, creating new wxLua types</span>
  1126. <a name="l01097"></a>01097 <span class="comment">// if this is the first time we&#39;re registering them</span>
  1127. <a name="l01098"></a>01098 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *wxlClass = <a class="code" href="classwxLuaBinding.html#ad49fa01f3b44889af3f0cfabe9ee4fe8">m_classArray</a>;
  1128. <a name="l01099"></a>01099 <span class="keywordflow">for</span> (n = 0; n &lt; <a class="code" href="classwxLuaBinding.html#ab668185325d94999b07fae44ef497016">m_classCount</a>; ++n, ++wxlClass)
  1129. <a name="l01100"></a>01100 {
  1130. <a name="l01101"></a>01101 <a class="code" href="classwxLuaBinding.html#a076f769e1fc9d52361832f1be869022e">InstallClassMetatable</a>(L, wxlClass);
  1131. <a name="l01102"></a>01102 <a class="code" href="classwxLuaBinding.html#a290db29e1ad9cb71ed35b7e24f9dc30b">InstallClass</a>(L, wxlClass);
  1132. <a name="l01103"></a>01103 }
  1133. <a name="l01104"></a>01104
  1134. <a name="l01105"></a>01105 <span class="comment">// register the global C style functions</span>
  1135. <a name="l01106"></a>01106 <span class="keyword">const</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod = <a class="code" href="classwxLuaBinding.html#a49d474bd3256c48346932671d2d311d1">m_functionArray</a>;
  1136. <a name="l01107"></a>01107 <span class="keywordflow">for</span> (n = 0; n &lt; <a class="code" href="classwxLuaBinding.html#ad960470e2a9637edac97252945e7000c">m_functionCount</a>; ++n, ++wxlMethod)
  1137. <a name="l01108"></a>01108 {
  1138. <a name="l01109"></a>01109 lua_pushstring(L, wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afef5590cd8bd8a9906b658ddcadb674c">name</a>);
  1139. <a name="l01110"></a>01110 lua_pushlightuserdata(L, (<span class="keywordtype">void</span>*)wxlMethod);
  1140. <a name="l01111"></a>01111 lua_pushcclosure(L, wxlMethod-&gt;wxluacfuncs[0].lua_cfunc, 1);
  1141. <a name="l01112"></a>01112 lua_rawset(L, -3);
  1142. <a name="l01113"></a>01113 }
  1143. <a name="l01114"></a>01114
  1144. <a name="l01115"></a>01115 <span class="comment">// install the numerical definitions</span>
  1145. <a name="l01116"></a>01116 <span class="keyword">const</span> <a class="code" href="structwxLuaBindNumber.html">wxLuaBindNumber</a>* wxlNumber = <a class="code" href="classwxLuaBinding.html#a2d7dd4ea59cac79f5ce9d6c3784dfe5c">m_numberArray</a>;
  1146. <a name="l01117"></a>01117 <span class="keywordflow">for</span> (n = 0; n &lt; <a class="code" href="classwxLuaBinding.html#ad448b65743bf6bdf27b31346a176c166">m_numberCount</a>; ++n, ++wxlNumber)
  1147. <a name="l01118"></a>01118 {
  1148. <a name="l01119"></a>01119 lua_pushstring(L, wxlNumber-&gt;<a class="code" href="structwxLuaBindNumber.html#a99f555b1db61778967760d74f182bbca">name</a>);
  1149. <a name="l01120"></a>01120 lua_pushnumber(L, wxlNumber-&gt;<a class="code" href="structwxLuaBindNumber.html#af3e98c3a4a775777f28a28f53ca5d9e9">value</a>);
  1150. <a name="l01121"></a>01121 lua_rawset(L, -3);
  1151. <a name="l01122"></a>01122 }
  1152. <a name="l01123"></a>01123
  1153. <a name="l01124"></a>01124 <span class="comment">// install the strings</span>
  1154. <a name="l01125"></a>01125 <span class="keyword">const</span> <a class="code" href="structwxLuaBindString.html">wxLuaBindString</a> *wxlString = <a class="code" href="classwxLuaBinding.html#a2628550ef0a15f71b338b8d3f1bf25d8">m_stringArray</a>;
  1155. <a name="l01126"></a>01126 <span class="keywordflow">for</span> (n = 0; n &lt; <a class="code" href="classwxLuaBinding.html#a1861c30baba1384af84f0889af12cbec">m_stringCount</a>; ++n, ++wxlString)
  1156. <a name="l01127"></a>01127 {
  1157. <a name="l01128"></a>01128 lua_pushstring(L, wxlString-&gt;<a class="code" href="structwxLuaBindString.html#a99b1e689b230a97ccbe89eaaa168c490">name</a>);
  1158. <a name="l01129"></a>01129 lua_pushstring(L, <a class="code" href="wxlstate_8h.html#a41976a7549ef4bfa7e9a1147dc7b4d55">wx2lua</a>(wxlString-&gt;<a class="code" href="structwxLuaBindString.html#abb201cc7ef30158a3e1fe3445d338464">value</a>));
  1159. <a name="l01130"></a>01130 lua_rawset(L, -3);
  1160. <a name="l01131"></a>01131 }
  1161. <a name="l01132"></a>01132
  1162. <a name="l01133"></a>01133 <span class="comment">// install the objects and pointers</span>
  1163. <a name="l01134"></a>01134 <span class="keyword">const</span> <a class="code" href="structwxLuaBindObject.html">wxLuaBindObject</a> *wxlObject = <a class="code" href="classwxLuaBinding.html#ac640cacc363dce505f374fe687d4e820">m_objectArray</a>;
  1164. <a name="l01135"></a>01135 <span class="keywordflow">for</span> (n = 0; n &lt; <a class="code" href="classwxLuaBinding.html#afc25c25aea5ef7dcade8234546fac380">m_objectCount</a>; ++n, ++wxlObject)
  1165. <a name="l01136"></a>01136 {
  1166. <a name="l01137"></a>01137 lua_pushstring(L, wxlObject-&gt;<a class="code" href="structwxLuaBindObject.html#a7284930268fb6a2f6024a21cbead5c9a">name</a>);
  1167. <a name="l01138"></a>01138
  1168. <a name="l01139"></a>01139 <span class="keywordflow">if</span> (wxlObject-&gt;<a class="code" href="structwxLuaBindObject.html#a1baa2f3f1bb77fc3565f5c12bec50235">objPtr</a> != 0)
  1169. <a name="l01140"></a>01140 <a class="code" href="wxlstate_8h.html#a4cd81a70613d64cac4f0f363807df6a6">wxluaT_pushuserdatatype</a>(L, wxlObject-&gt;<a class="code" href="structwxLuaBindObject.html#a1baa2f3f1bb77fc3565f5c12bec50235">objPtr</a>, *wxlObject-&gt;<a class="code" href="structwxLuaBindObject.html#ab9ff5d11002b79d2bbd43218f7b9d6d4">wxluatype</a>, <span class="keyword">true</span>);
  1170. <a name="l01141"></a>01141 <span class="keywordflow">else</span>
  1171. <a name="l01142"></a>01142 <a class="code" href="wxlstate_8h.html#a4cd81a70613d64cac4f0f363807df6a6">wxluaT_pushuserdatatype</a>(L, *wxlObject-&gt;<a class="code" href="structwxLuaBindObject.html#a5cf6abaad26fd1a06589a39caf4e44b5">pObjPtr</a>, *wxlObject-&gt;<a class="code" href="structwxLuaBindObject.html#ab9ff5d11002b79d2bbd43218f7b9d6d4">wxluatype</a>, <span class="keyword">true</span>);
  1172. <a name="l01143"></a>01143
  1173. <a name="l01144"></a>01144 lua_rawset(L, -3);
  1174. <a name="l01145"></a>01145 }
  1175. <a name="l01146"></a>01146
  1176. <a name="l01147"></a>01147 <span class="comment">// register the wxEvent types</span>
  1177. <a name="l01148"></a>01148 <span class="keyword">const</span> <a class="code" href="structwxLuaBindEvent.html">wxLuaBindEvent</a> *wxlEvent = <a class="code" href="classwxLuaBinding.html#ac80f0d9d548d389a5b02ad9a3e8806a7">m_eventArray</a>;
  1178. <a name="l01149"></a>01149 <span class="keywordflow">for</span> (n = 0; n &lt; <a class="code" href="classwxLuaBinding.html#a74ce8ec75efc3422cc56558c72382960">m_eventCount</a>; ++n, ++wxlEvent)
  1179. <a name="l01150"></a>01150 {
  1180. <a name="l01151"></a>01151 lua_pushstring(L, wxlEvent-&gt;<a class="code" href="structwxLuaBindEvent.html#a6de864ceccf61c077d89fe8abe1288ee">name</a>);
  1181. <a name="l01152"></a>01152 lua_pushnumber(L, *wxlEvent-&gt;<a class="code" href="structwxLuaBindEvent.html#aa7b7fa6270db43ac848ae37a98ea82d3">eventType</a>);
  1182. <a name="l01153"></a>01153 lua_rawset(L, -3);
  1183. <a name="l01154"></a>01154 }
  1184. <a name="l01155"></a>01155 }
  1185. <a name="l01156"></a>01156
  1186. <a name="l01157"></a>01157 <span class="comment">/* static */</span>
  1187. <a name="l01158"></a><a class="code" href="classwxLuaBinding.html#a076f769e1fc9d52361832f1be869022e">01158</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaBinding.html#a076f769e1fc9d52361832f1be869022e">wxLuaBinding::InstallClassMetatable</a>(lua_State* L, <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass)
  1188. <a name="l01159"></a>01159 {
  1189. <a name="l01160"></a>01160 <span class="comment">// Replace the metatable functions for the classes we push into Lua</span>
  1190. <a name="l01161"></a>01161 <span class="keyword">static</span> <span class="keyword">const</span> luaL_reg s_funcTable[] =
  1191. <a name="l01162"></a>01162 {
  1192. <a name="l01163"></a>01163 {<span class="stringliteral">&quot;__gc&quot;</span>, <a class="code" href="wxlbind_8h.html#afaa936338003a8c855b37aca0e2371b3">wxlua_wxLuaBindClass__gc</a> },
  1193. <a name="l01164"></a>01164 {<span class="stringliteral">&quot;__index&quot;</span>, <a class="code" href="wxlbind_8h.html#afee853d06607bbf64e889fbb248b7b72">wxlua_wxLuaBindClass__index</a> },
  1194. <a name="l01165"></a>01165 {<span class="stringliteral">&quot;__newindex&quot;</span>, <a class="code" href="wxlbind_8h.html#a95e9940883230f3fb35390c89de03200">wxlua_wxLuaBindClass__newindex</a> },
  1195. <a name="l01166"></a>01166 {<span class="stringliteral">&quot;__tostring&quot;</span>, <a class="code" href="wxlbind_8h.html#a8443ccec54d9e1ef4b4a6c3e15ba6282">wxlua_wxLuaBindClass__tostring</a> }
  1196. <a name="l01167"></a>01167 };
  1197. <a name="l01168"></a>01168 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">size_t</span> s_funcCount = <span class="keyword">sizeof</span>(s_funcTable)/<span class="keyword">sizeof</span>(s_funcTable[0]);
  1198. <a name="l01169"></a>01169
  1199. <a name="l01170"></a>01170 <span class="comment">// ------------------------------------------------------------------</span>
  1200. <a name="l01171"></a>01171 <span class="comment">// Add to the lookup table for &quot;class name&quot; to wxLuaBindClass struct</span>
  1201. <a name="l01172"></a>01172 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a0bcf696ed6d6e2b4218e9a8852a164ef">wxlua_lreg_classes_key</a>);
  1202. <a name="l01173"></a>01173 lua_rawget(L, LUA_REGISTRYINDEX); <span class="comment">// pop key, push result (the classes table)</span>
  1203. <a name="l01174"></a>01174 lua_pushstring(L, wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#af89cbb87774c38c593f7ed87a68fffcb">name</a>); <span class="comment">// push key</span>
  1204. <a name="l01175"></a>01175 lua_pushlightuserdata(L, (<span class="keywordtype">void</span> *)wxlClass); <span class="comment">// push value</span>
  1205. <a name="l01176"></a>01176 lua_rawset(L, -3); <span class="comment">// set t[key] = value, pops key and value</span>
  1206. <a name="l01177"></a>01177 lua_pop(L, 1); <span class="comment">// pop wxlua_lreg_classes_key table</span>
  1207. <a name="l01178"></a>01178
  1208. <a name="l01179"></a>01179 <span class="comment">// ------------------------------------------------------------------</span>
  1209. <a name="l01180"></a>01180 <span class="comment">// Create a new metatable for this class with a numerical wxLua type index</span>
  1210. <a name="l01181"></a>01181
  1211. <a name="l01182"></a>01182 <span class="keywordtype">int</span> wxl_type = *wxlClass-&gt;wxluatype;
  1212. <a name="l01183"></a>01183
  1213. <a name="l01184"></a>01184 <span class="comment">// we may be reregistering this binding, get the old metatable, we&#39;ll rewrite it</span>
  1214. <a name="l01185"></a>01185 <span class="keywordflow">if</span> (!<a class="code" href="wxlstate_8h.html#ae9010018526dd75ae4cb8571b8956fa5">wxluaT_getmetatable</a>(L, wxl_type))
  1215. <a name="l01186"></a>01186 <a class="code" href="wxlstate_8h.html#a6e860df2af8f36918348b8b92abfbfb4">wxluaT_newmetatable</a>(L, wxl_type); <span class="comment">// create metatable, is on top of stack</span>
  1216. <a name="l01187"></a>01187
  1217. <a name="l01188"></a>01188 <span class="comment">// store a lookup in the class metatable to the wxLuaBindClass struct</span>
  1218. <a name="l01189"></a>01189 lua_pushlightuserdata(L, &amp;<a class="code" href="wxlstate_8h.html#a8719cfeea23ebd1cb309de8296777da6">wxlua_metatable_wxluabindclass_key</a>); <span class="comment">// push key</span>
  1219. <a name="l01190"></a>01190 lua_pushlightuserdata(L, (<span class="keywordtype">void</span> *)wxlClass); <span class="comment">// push value</span>
  1220. <a name="l01191"></a>01191 lua_rawset(L, -3); <span class="comment">// set t[key] = value, pops key and value</span>
  1221. <a name="l01192"></a>01192
  1222. <a name="l01193"></a>01193 <span class="comment">// set the functions for the class in the metatable</span>
  1223. <a name="l01194"></a>01194 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i_func = 0; i_func &lt; s_funcCount; ++i_func)
  1224. <a name="l01195"></a>01195 {
  1225. <a name="l01196"></a>01196 lua_pushstring(L, s_funcTable[i_func].name); <span class="comment">// push method name</span>
  1226. <a name="l01197"></a>01197 lua_pushlightuserdata(L, (<span class="keywordtype">void</span> *)wxlClass); <span class="comment">// push the userdata</span>
  1227. <a name="l01198"></a>01198 lua_pushcclosure(L, s_funcTable[i_func].func, 1); <span class="comment">// push func with wxlClass as upvalue</span>
  1228. <a name="l01199"></a>01199 lua_rawset(L, -3); <span class="comment">// t[&quot;method_name&quot;] = closure of func and upvalues</span>
  1229. <a name="l01200"></a>01200 }
  1230. <a name="l01201"></a>01201
  1231. <a name="l01202"></a>01202 lua_pop(L, 1); <span class="comment">// pop metatable from wxluaT_newmetatable()</span>
  1232. <a name="l01203"></a>01203
  1233. <a name="l01204"></a>01204 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  1234. <a name="l01205"></a>01205 }
  1235. <a name="l01206"></a>01206
  1236. <a name="l01207"></a>01207 <span class="comment">/* static */</span>
  1237. <a name="l01208"></a><a class="code" href="classwxLuaBinding.html#a290db29e1ad9cb71ed35b7e24f9dc30b">01208</a> <span class="keywordtype">bool</span> <a class="code" href="classwxLuaBinding.html#a290db29e1ad9cb71ed35b7e24f9dc30b">wxLuaBinding::InstallClass</a>(lua_State* L, <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass)
  1238. <a name="l01209"></a>01209 {
  1239. <a name="l01210"></a>01210 <span class="comment">// ------------------------------------------------------------------</span>
  1240. <a name="l01211"></a>01211 <span class="comment">// Create and install the table for the class</span>
  1241. <a name="l01212"></a>01212
  1242. <a name="l01213"></a>01213 lua_pushstring(L, wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#af89cbb87774c38c593f7ed87a68fffcb">name</a>); <span class="comment">// push key</span>
  1243. <a name="l01214"></a>01214 lua_newtable(L); <span class="comment">// push value, the table we use as the class</span>
  1244. <a name="l01215"></a>01215
  1245. <a name="l01216"></a>01216 <span class="comment">// Install the member enums for the classname table</span>
  1246. <a name="l01217"></a>01217 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i_enum = 0; i_enum &lt; wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#aadcfb36d6f271ada8864f1d88a0ca5fc">enums_n</a>; ++i_enum)
  1247. <a name="l01218"></a>01218 {
  1248. <a name="l01219"></a>01219 lua_pushstring(L, wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a62e18d1022d4369511cbf0584990cca4">enums</a>[i_enum].<a class="code" href="structwxLuaBindNumber.html#a99f555b1db61778967760d74f182bbca">name</a>);
  1249. <a name="l01220"></a>01220 lua_pushnumber(L, wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a62e18d1022d4369511cbf0584990cca4">enums</a>[i_enum].<a class="code" href="structwxLuaBindNumber.html#af3e98c3a4a775777f28a28f53ca5d9e9">value</a>);
  1250. <a name="l01221"></a>01221 lua_rawset(L, -3);
  1251. <a name="l01222"></a>01222 }
  1252. <a name="l01223"></a>01223
  1253. <a name="l01224"></a>01224 <span class="keywordtype">int</span> method_count = wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a5eac6feca088451706f0fde55dd73393">wxluamethods_n</a>;
  1254. <a name="l01225"></a>01225
  1255. <a name="l01226"></a>01226 <span class="comment">// Install the static functions for the classname table</span>
  1256. <a name="l01227"></a>01227 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a> *wxlMethod = wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a313c0c5eeb60ca717bae7d286dc41d28">wxluamethods</a>;
  1257. <a name="l01228"></a>01228 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i_static_method = 0; i_static_method &lt; method_count; ++i_static_method, ++wxlMethod)
  1258. <a name="l01229"></a>01229 {
  1259. <a name="l01230"></a>01230 <span class="comment">// we will handle the WXLUAMETHOD_GET/SETPROP|WXLUAMETHOD_STATIC using __index and __newindex</span>
  1260. <a name="l01231"></a>01231 <span class="keywordflow">if</span> (((wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a> &amp; (<a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa60723ea1159aae6845b01c660afd54f2">WXLUAMETHOD_METHOD</a>|<a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fad2e593a9652e9ce570c780473db925a1">WXLUAMETHOD_STATIC</a>)) == (<a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa60723ea1159aae6845b01c660afd54f2">WXLUAMETHOD_METHOD</a>|<a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fad2e593a9652e9ce570c780473db925a1">WXLUAMETHOD_STATIC</a>)) &amp;&amp;
  1261. <a name="l01232"></a>01232 (wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#a36285f0c5431ed28e8951b26706ee3c5">wxluacfuncs_n</a> &gt; 0))
  1262. <a name="l01233"></a>01233 {
  1263. <a name="l01234"></a>01234 lua_pushstring(L, wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afef5590cd8bd8a9906b658ddcadb674c">name</a>);
  1264. <a name="l01235"></a>01235 lua_pushlightuserdata(L, wxlMethod);
  1265. <a name="l01236"></a>01236 <span class="keywordflow">if</span> (wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#a36285f0c5431ed28e8951b26706ee3c5">wxluacfuncs_n</a> &gt; 1)
  1266. <a name="l01237"></a>01237 lua_pushcclosure(L, <a class="code" href="wxlbind_8h.html#ae8b8fad8188c49f55361c6686266c570">wxlua_callOverloadedFunction</a>, 1);
  1267. <a name="l01238"></a>01238 <span class="keywordflow">else</span>
  1268. <a name="l01239"></a>01239 lua_pushcclosure(L, wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#abcc43fb837b299e7fc088fb787ad3aca">wxluacfuncs</a>[0].<a class="code" href="structwxLuaBindCFunc.html#a6184d5deed3363ec14f67ecf5f63c84f">lua_cfunc</a>, 1);
  1269. <a name="l01240"></a>01240
  1270. <a name="l01241"></a>01241 lua_rawset(L, -3);
  1271. <a name="l01242"></a>01242 }
  1272. <a name="l01243"></a>01243 }
  1273. <a name="l01244"></a>01244
  1274. <a name="l01245"></a>01245 <span class="comment">// Create a metatable for the &quot;class&quot; table</span>
  1275. <a name="l01246"></a>01246 lua_newtable(L);
  1276. <a name="l01247"></a>01247 lua_pushlstring(L, <span class="stringliteral">&quot;__index&quot;</span>, 7);
  1277. <a name="l01248"></a>01248 lua_pushlightuserdata(L, (<span class="keywordtype">void</span>*)wxlClass);
  1278. <a name="l01249"></a>01249 lua_pushcclosure(L, <a class="code" href="wxlbind_8cpp.html#a97e12402435dfa7a8a857cb0f39a98f3">wxlua_wxLuaBindMethod_table__index</a>, 1);
  1279. <a name="l01250"></a>01250 lua_rawset(L, -3);
  1280. <a name="l01251"></a>01251
  1281. <a name="l01252"></a>01252 lua_pushlstring(L, <span class="stringliteral">&quot;__newindex&quot;</span>, 10);
  1282. <a name="l01253"></a>01253 lua_pushlightuserdata(L, (<span class="keywordtype">void</span>*)wxlClass);
  1283. <a name="l01254"></a>01254 lua_pushcclosure(L, <a class="code" href="wxlbind_8cpp.html#a6234dfc83aabc51327e45846fe9b07a4">wxlua_wxLuaBindMethod_table__newindex</a>, 1);
  1284. <a name="l01255"></a>01255 lua_rawset(L, -3);
  1285. <a name="l01256"></a>01256
  1286. <a name="l01257"></a>01257 <span class="comment">//lua_pushstring(L, &quot;__metatable&quot;);</span>
  1287. <a name="l01258"></a>01258 <span class="comment">//lua_pushstring(L, &quot;Metatable is not accessible&quot;);</span>
  1288. <a name="l01259"></a>01259 <span class="comment">//lua_rawset(L, -3);</span>
  1289. <a name="l01260"></a>01260 lua_setmetatable(L, -2); <span class="comment">// pops the metatable</span>
  1290. <a name="l01261"></a>01261
  1291. <a name="l01262"></a>01262 <span class="comment">// Finalize the class table since we may not have a constructor</span>
  1292. <a name="l01263"></a>01263 <span class="comment">// or have multiple constructors.</span>
  1293. <a name="l01264"></a>01264 lua_rawset(L, -3); <span class="comment">// set t[key] = value, pops key and value</span>
  1294. <a name="l01265"></a>01265
  1295. <a name="l01266"></a>01266 <span class="comment">// ------------------------------------------------------------------</span>
  1296. <a name="l01267"></a>01267 <span class="comment">// Install public functions like constructors or global functions</span>
  1297. <a name="l01268"></a>01268 wxlMethod = wxlClass-&gt;wxluamethods;
  1298. <a name="l01269"></a>01269 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i_method = 0; i_method &lt; method_count; ++i_method, ++wxlMethod)
  1299. <a name="l01270"></a>01270 {
  1300. <a name="l01271"></a>01271 <span class="keywordflow">if</span> (<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a>, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa17851433f53b5c36f8832826c632a620">WXLUAMETHOD_CONSTRUCTOR</a> | <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa9d1e4fafb81ea95073b95c8e92153fbf">WXLUAMETHOD_CFUNCTION</a>) &amp;&amp; wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#a36285f0c5431ed28e8951b26706ee3c5">wxluacfuncs_n</a>)
  1301. <a name="l01272"></a>01272 {
  1302. <a name="l01273"></a>01273 <span class="comment">// push name of nested table and create the table or use existing</span>
  1303. <a name="l01274"></a>01274 <span class="comment">// we do it this way since we can have multiple constructors (renamed)</span>
  1304. <a name="l01275"></a>01275 <span class="comment">// that are of the same class and so they share the same wxLua type.</span>
  1305. <a name="l01276"></a>01276 lua_pushstring(L, wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afef5590cd8bd8a9906b658ddcadb674c">name</a>);
  1306. <a name="l01277"></a>01277
  1307. <a name="l01278"></a>01278 <span class="keywordflow">if</span> (strcmp(wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afef5590cd8bd8a9906b658ddcadb674c">name</a>, wxlClass-&gt;name) != 0)
  1308. <a name="l01279"></a>01279 lua_newtable(L);
  1309. <a name="l01280"></a>01280 <span class="keywordflow">else</span>
  1310. <a name="l01281"></a>01281 lua_getfield(L, -2, wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afef5590cd8bd8a9906b658ddcadb674c">name</a>);
  1311. <a name="l01282"></a>01282
  1312. <a name="l01283"></a>01283 <span class="comment">// add the items to the table as t[first pushed] = second pushed</span>
  1313. <a name="l01284"></a>01284 lua_pushlstring(L, <span class="stringliteral">&quot;new&quot;</span>, 3);
  1314. <a name="l01285"></a>01285 lua_pushlightuserdata(L, wxlMethod);
  1315. <a name="l01286"></a>01286 lua_pushcclosure(L, <a class="code" href="wxlbind_8h.html#ae8b8fad8188c49f55361c6686266c570">wxlua_callOverloadedFunction</a>, 1);
  1316. <a name="l01287"></a>01287 lua_rawset(L, -3);
  1317. <a name="l01288"></a>01288
  1318. <a name="l01289"></a>01289 <span class="comment">// Add __call to the metatable for this table</span>
  1319. <a name="l01290"></a>01290 <span class="keywordtype">bool</span> has_meta = (lua_getmetatable(L, -1) != 0);
  1320. <a name="l01291"></a>01291 <span class="keywordflow">if</span> (!has_meta) lua_newtable(L);
  1321. <a name="l01292"></a>01292
  1322. <a name="l01293"></a>01293 lua_pushlstring(L, <span class="stringliteral">&quot;__call&quot;</span>, 6);
  1323. <a name="l01294"></a>01294 lua_pushlightuserdata(L, wxlMethod);
  1324. <a name="l01295"></a>01295 lua_pushcclosure(L, <a class="code" href="wxlbind_8cpp.html#a144b8c459569dbdac97cfcc1c4467a10">wxlua_wxLuaBindMethod_table__call</a>, 1);
  1325. <a name="l01296"></a>01296 lua_rawset(L, -3);
  1326. <a name="l01297"></a>01297
  1327. <a name="l01298"></a>01298 <span class="comment">//lua_pushstring(L, &quot;__metatable&quot;);</span>
  1328. <a name="l01299"></a>01299 <span class="comment">//lua_pushstring(L, &quot;Metatable is not accessible&quot;);</span>
  1329. <a name="l01300"></a>01300 <span class="comment">//lua_rawset(L, -3);</span>
  1330. <a name="l01301"></a>01301
  1331. <a name="l01302"></a>01302 <span class="keywordflow">if</span> (!has_meta)
  1332. <a name="l01303"></a>01303 lua_setmetatable(L, -2);
  1333. <a name="l01304"></a>01304 <span class="keywordflow">else</span>
  1334. <a name="l01305"></a>01305 lua_pop(L, 1);
  1335. <a name="l01306"></a>01306
  1336. <a name="l01307"></a>01307 <span class="comment">// add table to the binding table t[wxlMethod-&gt;name] = { this table }</span>
  1337. <a name="l01308"></a>01308 lua_rawset(L, -3); <span class="comment">// set t[key] = value, pops key and value</span>
  1338. <a name="l01309"></a>01309 }
  1339. <a name="l01310"></a>01310 }
  1340. <a name="l01311"></a>01311
  1341. <a name="l01312"></a>01312 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  1342. <a name="l01313"></a>01313 }
  1343. <a name="l01314"></a>01314
  1344. <a name="l01315"></a>01315 <span class="comment">// ---------------------------------------------------------------------------</span>
  1345. <a name="l01316"></a>01316
  1346. <a name="l01317"></a><a class="code" href="classwxLuaBinding.html#a9ab707c3960348e473d6f0b63503dd94">01317</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindEvent.html">wxLuaBindEvent</a>* <a class="code" href="classwxLuaBinding.html#a9ab707c3960348e473d6f0b63503dd94">wxLuaBinding::GetBindEvent</a>(wxEventType eventType_)<span class="keyword"> const</span>
  1347. <a name="l01318"></a>01318 <span class="keyword"></span>{
  1348. <a name="l01319"></a>01319 <span class="keyword">const</span> wxEventType eventType = eventType_;
  1349. <a name="l01320"></a>01320 <a class="code" href="structwxLuaBindEvent.html">wxLuaBindEvent</a> eventItem = { <span class="stringliteral">&quot;&quot;</span>, &amp;eventType, NULL };
  1350. <a name="l01321"></a>01321
  1351. <a name="l01322"></a>01322 <span class="keyword">const</span> <a class="code" href="structwxLuaBindEvent.html">wxLuaBindEvent</a> *pLuaEvent = (<a class="code" href="structwxLuaBindEvent.html">wxLuaBindEvent</a> *)bsearch(&amp;eventItem,
  1352. <a name="l01323"></a>01323 <a class="code" href="classwxLuaBinding.html#ac80f0d9d548d389a5b02ad9a3e8806a7">m_eventArray</a>,
  1353. <a name="l01324"></a>01324 <a class="code" href="classwxLuaBinding.html#a74ce8ec75efc3422cc56558c72382960">m_eventCount</a>,
  1354. <a name="l01325"></a>01325 <span class="keyword">sizeof</span>(<a class="code" href="structwxLuaBindEvent.html">wxLuaBindEvent</a>),
  1355. <a name="l01326"></a>01326 <a class="code" href="wxlbind_8cpp.html#a600e79368d13cac59932d82c5cc1439c">wxLuaBindEventArrayCompareFn</a>);
  1356. <a name="l01327"></a>01327 <span class="keywordflow">return</span> pLuaEvent;
  1357. <a name="l01328"></a>01328 }
  1358. <a name="l01329"></a>01329
  1359. <a name="l01330"></a><a class="code" href="classwxLuaBinding.html#ab67ab6bf271641ef2f97817d65161c91">01330</a> wxString <a class="code" href="classwxLuaBinding.html#ab67ab6bf271641ef2f97817d65161c91">wxLuaBinding::GetEventTypeName</a>(wxEventType eventType)<span class="keyword"> const</span>
  1360. <a name="l01331"></a>01331 <span class="keyword"></span>{
  1361. <a name="l01332"></a>01332 <span class="keyword">const</span> <a class="code" href="structwxLuaBindEvent.html">wxLuaBindEvent</a>* wxlEvent = <a class="code" href="classwxLuaBinding.html#a9ab707c3960348e473d6f0b63503dd94">GetBindEvent</a>(eventType);
  1362. <a name="l01333"></a>01333 <span class="keywordflow">return</span> (wxlEvent != NULL) ? <a class="code" href="wxlstate_8h.html#aaa3dbc7e667edd1e7409725fe338f4e8">lua2wx</a>(wxlEvent-&gt;<a class="code" href="structwxLuaBindEvent.html#a6de864ceccf61c077d89fe8abe1288ee">name</a>) : wxString();
  1363. <a name="l01334"></a>01334 }
  1364. <a name="l01335"></a>01335
  1365. <a name="l01336"></a><a class="code" href="classwxLuaBinding.html#aa9cbed3abdafd742630ec17dadf1874b">01336</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* <a class="code" href="classwxLuaBinding.html#aa9cbed3abdafd742630ec17dadf1874b">wxLuaBinding::GetBindClass</a>(<span class="keywordtype">int</span> wxluatype_)<span class="keyword"> const</span>
  1366. <a name="l01337"></a>01337 <span class="keyword"></span>{
  1367. <a name="l01338"></a>01338 <span class="keywordtype">int</span> wxluatype = wxluatype_; <span class="comment">// create a local var to get the address of</span>
  1368. <a name="l01339"></a>01339 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> classItem = { 0, 0, 0, 0, &amp;wxluatype, 0, 0, 0, 0 };
  1369. <a name="l01340"></a>01340
  1370. <a name="l01341"></a>01341 <span class="comment">// this relies on LUA allocating the wxLua types in ascending order of definition</span>
  1371. <a name="l01342"></a>01342 <span class="comment">// if LUA stops doing this, then the search may break.</span>
  1372. <a name="l01343"></a>01343 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *wxlClass = (<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *)bsearch(&amp;classItem,
  1373. <a name="l01344"></a>01344 <a class="code" href="classwxLuaBinding.html#ad49fa01f3b44889af3f0cfabe9ee4fe8">m_classArray</a>,
  1374. <a name="l01345"></a>01345 <a class="code" href="classwxLuaBinding.html#ab668185325d94999b07fae44ef497016">m_classCount</a>,
  1375. <a name="l01346"></a>01346 <span class="keyword">sizeof</span>(<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>),
  1376. <a name="l01347"></a>01347 <a class="code" href="wxlbind_8cpp.html#af461c435b97f5d2ff20e13510073d7b0">wxLuaBindClassArrayCompareBywxLuaType</a>);
  1377. <a name="l01348"></a>01348
  1378. <a name="l01349"></a>01349 <span class="keywordflow">return</span> wxlClass;
  1379. <a name="l01350"></a>01350 }
  1380. <a name="l01351"></a>01351
  1381. <a name="l01352"></a><a class="code" href="classwxLuaBinding.html#ae819b6a94799c2419f44d564c305a052">01352</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* <a class="code" href="classwxLuaBinding.html#aa9cbed3abdafd742630ec17dadf1874b">wxLuaBinding::GetBindClass</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* className)<span class="keyword"> const</span>
  1382. <a name="l01353"></a>01353 <span class="keyword"></span>{
  1383. <a name="l01354"></a>01354 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> classItem = { className, 0, 0, 0, 0, 0, 0, 0, 0 };
  1384. <a name="l01355"></a>01355
  1385. <a name="l01356"></a>01356 <span class="comment">// this relies on LUA allocating the wxLua types in ascending order of definition</span>
  1386. <a name="l01357"></a>01357 <span class="comment">// if LUA stops doing this, then the search may break.</span>
  1387. <a name="l01358"></a>01358 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *wxlClass = (<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *)bsearch(&amp;classItem,
  1388. <a name="l01359"></a>01359 <a class="code" href="classwxLuaBinding.html#ad49fa01f3b44889af3f0cfabe9ee4fe8">m_classArray</a>,
  1389. <a name="l01360"></a>01360 <a class="code" href="classwxLuaBinding.html#ab668185325d94999b07fae44ef497016">m_classCount</a>,
  1390. <a name="l01361"></a>01361 <span class="keyword">sizeof</span>(<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>),
  1391. <a name="l01362"></a>01362 <a class="code" href="wxlbind_8cpp.html#a6625687e644b2f8fa02fba6d7844e0cf">wxLuaBindClassArrayCompareFn</a>);
  1392. <a name="l01363"></a>01363
  1393. <a name="l01364"></a>01364 <span class="keywordflow">return</span> wxlClass;
  1394. <a name="l01365"></a>01365 }
  1395. <a name="l01366"></a>01366
  1396. <a name="l01367"></a><a class="code" href="classwxLuaBinding.html#a8183cd7b5592e9577a50756867bccbba">01367</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* <a class="code" href="classwxLuaBinding.html#aa9cbed3abdafd742630ec17dadf1874b">wxLuaBinding::GetBindClass</a>(<span class="keyword">const</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod_tofind)<span class="keyword"> const</span>
  1397. <a name="l01368"></a>01368 <span class="keyword"></span>{
  1398. <a name="l01369"></a>01369 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = <a class="code" href="classwxLuaBinding.html#ad49fa01f3b44889af3f0cfabe9ee4fe8">m_classArray</a>;
  1399. <a name="l01370"></a>01370 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod = NULL;
  1400. <a name="l01371"></a>01371
  1401. <a name="l01372"></a>01372 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> c = 0; c &lt; <a class="code" href="classwxLuaBinding.html#ab668185325d94999b07fae44ef497016">m_classCount</a>; ++c, ++wxlClass)
  1402. <a name="l01373"></a>01373 {
  1403. <a name="l01374"></a>01374 wxlMethod = wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a313c0c5eeb60ca717bae7d286dc41d28">wxluamethods</a>;
  1404. <a name="l01375"></a>01375 <span class="keywordtype">int</span> m , wxluamethods_n = wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a5eac6feca088451706f0fde55dd73393">wxluamethods_n</a>;
  1405. <a name="l01376"></a>01376
  1406. <a name="l01377"></a>01377 <span class="keywordflow">for</span> (m = 0; m &lt; wxluamethods_n; ++m, ++wxlMethod)
  1407. <a name="l01378"></a>01378 {
  1408. <a name="l01379"></a>01379 <span class="keywordflow">if</span> (wxlMethod == wxlMethod_tofind)
  1409. <a name="l01380"></a>01380 <span class="keywordflow">return</span> wxlClass;
  1410. <a name="l01381"></a>01381 }
  1411. <a name="l01382"></a>01382 }
  1412. <a name="l01383"></a>01383
  1413. <a name="l01384"></a>01384 <span class="keywordflow">return</span> NULL;
  1414. <a name="l01385"></a>01385 }
  1415. <a name="l01386"></a>01386
  1416. <a name="l01387"></a><a class="code" href="classwxLuaBinding.html#a022327c542ee769f98379ee8bc7c34e2">01387</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* <a class="code" href="classwxLuaBinding.html#aa9cbed3abdafd742630ec17dadf1874b">wxLuaBinding::GetBindClass</a>(<span class="keyword">const</span> <a class="code" href="structwxLuaBindCFunc.html">wxLuaBindCFunc</a>* wxlCFunc_tofind)<span class="keyword"> const</span>
  1417. <a name="l01388"></a>01388 <span class="keyword"></span>{
  1418. <a name="l01389"></a>01389 <span class="keywordtype">size_t</span> c, m, f, methods_n, funcs_n;
  1419. <a name="l01390"></a>01390 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = <a class="code" href="classwxLuaBinding.html#ad49fa01f3b44889af3f0cfabe9ee4fe8">m_classArray</a>;
  1420. <a name="l01391"></a>01391 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod = NULL;
  1421. <a name="l01392"></a>01392 <a class="code" href="structwxLuaBindCFunc.html">wxLuaBindCFunc</a>* wxlCFunc = NULL;
  1422. <a name="l01393"></a>01393
  1423. <a name="l01394"></a>01394 <span class="keywordflow">for</span> (c = 0; c &lt; <a class="code" href="classwxLuaBinding.html#ab668185325d94999b07fae44ef497016">m_classCount</a>; ++c, ++wxlClass)
  1424. <a name="l01395"></a>01395 {
  1425. <a name="l01396"></a>01396 wxlMethod = wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a313c0c5eeb60ca717bae7d286dc41d28">wxluamethods</a>;
  1426. <a name="l01397"></a>01397 methods_n = wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a5eac6feca088451706f0fde55dd73393">wxluamethods_n</a>;
  1427. <a name="l01398"></a>01398
  1428. <a name="l01399"></a>01399 <span class="keywordflow">for</span> (m = 0; m &lt; methods_n; ++m, ++wxlMethod)
  1429. <a name="l01400"></a>01400 {
  1430. <a name="l01401"></a>01401 wxlCFunc = wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#abcc43fb837b299e7fc088fb787ad3aca">wxluacfuncs</a>;
  1431. <a name="l01402"></a>01402 funcs_n = wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#a36285f0c5431ed28e8951b26706ee3c5">wxluacfuncs_n</a>;
  1432. <a name="l01403"></a>01403
  1433. <a name="l01404"></a>01404 <span class="keywordflow">for</span> (f = 0; f &lt; funcs_n; ++f, ++wxlCFunc)
  1434. <a name="l01405"></a>01405 {
  1435. <a name="l01406"></a>01406 <span class="keywordflow">if</span> (wxlCFunc == wxlCFunc_tofind)
  1436. <a name="l01407"></a>01407 <span class="keywordflow">return</span> wxlClass;
  1437. <a name="l01408"></a>01408 }
  1438. <a name="l01409"></a>01409 }
  1439. <a name="l01410"></a>01410 }
  1440. <a name="l01411"></a>01411
  1441. <a name="l01412"></a>01412 <span class="keywordflow">return</span> NULL;
  1442. <a name="l01413"></a>01413 }
  1443. <a name="l01414"></a>01414
  1444. <a name="l01415"></a>01415 <span class="comment">// --------------------------------------------------------------------------</span>
  1445. <a name="l01416"></a>01416
  1446. <a name="l01417"></a>01417 <span class="comment">// static</span>
  1447. <a name="l01418"></a><a class="code" href="classwxLuaBinding.html#aba1bd4c8e142b2083be5b70f2570c601">01418</a> <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* <a class="code" href="classwxLuaBinding.html#aba1bd4c8e142b2083be5b70f2570c601">wxLuaBinding::GetLuaBinding</a>(<span class="keyword">const</span> wxString&amp; bindingName)
  1448. <a name="l01419"></a>01419 {
  1449. <a name="l01420"></a>01420 wxLuaBindingList::compatibility_iterator node = <a class="code" href="classwxLuaBinding.html#a37817aea87de56a4f10cb8749051cada">sm_bindingList</a>.GetFirst();
  1450. <a name="l01421"></a>01421
  1451. <a name="l01422"></a>01422 <span class="keywordflow">while</span> (node)
  1452. <a name="l01423"></a>01423 {
  1453. <a name="l01424"></a>01424 <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding = node-&gt;GetData();
  1454. <a name="l01425"></a>01425 <span class="keywordflow">if</span> (binding-&gt;<a class="code" href="classwxLuaBinding.html#a9878ed9507384f5820f102218c3f82f6">GetBindingName</a>() == bindingName)
  1455. <a name="l01426"></a>01426 <span class="keywordflow">return</span> binding;
  1456. <a name="l01427"></a>01427
  1457. <a name="l01428"></a>01428 node = node-&gt;GetNext();
  1458. <a name="l01429"></a>01429 }
  1459. <a name="l01430"></a>01430
  1460. <a name="l01431"></a>01431 <span class="keywordflow">return</span> NULL;
  1461. <a name="l01432"></a>01432 }
  1462. <a name="l01433"></a>01433
  1463. <a name="l01434"></a>01434 <span class="comment">// static</span>
  1464. <a name="l01435"></a><a class="code" href="classwxLuaBinding.html#a4a5dc22602c636813af39476548af49b">01435</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* <a class="code" href="classwxLuaBinding.html#a7ee5e4f66198a0ef9e8cc4c2a6d0318e">wxLuaBinding::FindBindClass</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* className)
  1465. <a name="l01436"></a>01436 {
  1466. <a name="l01437"></a>01437 wxLuaBindingList::compatibility_iterator node = <a class="code" href="classwxLuaBinding.html#a37817aea87de56a4f10cb8749051cada">sm_bindingList</a>.GetFirst();
  1467. <a name="l01438"></a>01438
  1468. <a name="l01439"></a>01439 <span class="keywordflow">while</span> (node)
  1469. <a name="l01440"></a>01440 {
  1470. <a name="l01441"></a>01441 <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding = node-&gt;GetData();
  1471. <a name="l01442"></a>01442 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = binding-&gt;<a class="code" href="classwxLuaBinding.html#aa9cbed3abdafd742630ec17dadf1874b">GetBindClass</a>(className);
  1472. <a name="l01443"></a>01443
  1473. <a name="l01444"></a>01444 <span class="keywordflow">if</span> (wxlClass)
  1474. <a name="l01445"></a>01445 <span class="keywordflow">return</span> wxlClass;
  1475. <a name="l01446"></a>01446
  1476. <a name="l01447"></a>01447 node = node-&gt;GetNext();
  1477. <a name="l01448"></a>01448 }
  1478. <a name="l01449"></a>01449
  1479. <a name="l01450"></a>01450 <span class="keywordflow">return</span> NULL;
  1480. <a name="l01451"></a>01451 }
  1481. <a name="l01452"></a>01452
  1482. <a name="l01453"></a>01453 <span class="comment">// static</span>
  1483. <a name="l01454"></a><a class="code" href="classwxLuaBinding.html#a7ee5e4f66198a0ef9e8cc4c2a6d0318e">01454</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* <a class="code" href="classwxLuaBinding.html#a7ee5e4f66198a0ef9e8cc4c2a6d0318e">wxLuaBinding::FindBindClass</a>(<span class="keywordtype">int</span> wxluatype)
  1484. <a name="l01455"></a>01455 {
  1485. <a name="l01456"></a>01456 wxLuaBindingList::compatibility_iterator node = <a class="code" href="classwxLuaBinding.html#a37817aea87de56a4f10cb8749051cada">sm_bindingList</a>.GetFirst();
  1486. <a name="l01457"></a>01457
  1487. <a name="l01458"></a>01458 <span class="keywordflow">while</span> (node)
  1488. <a name="l01459"></a>01459 {
  1489. <a name="l01460"></a>01460 <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding = node-&gt;GetData();
  1490. <a name="l01461"></a>01461 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = binding-&gt;<a class="code" href="classwxLuaBinding.html#aa9cbed3abdafd742630ec17dadf1874b">GetBindClass</a>(wxluatype);
  1491. <a name="l01462"></a>01462
  1492. <a name="l01463"></a>01463 <span class="keywordflow">if</span> (wxlClass)
  1493. <a name="l01464"></a>01464 <span class="keywordflow">return</span> wxlClass;
  1494. <a name="l01465"></a>01465
  1495. <a name="l01466"></a>01466 node = node-&gt;GetNext();
  1496. <a name="l01467"></a>01467 }
  1497. <a name="l01468"></a>01468
  1498. <a name="l01469"></a>01469 <span class="keywordflow">return</span> NULL;
  1499. <a name="l01470"></a>01470 }
  1500. <a name="l01471"></a>01471
  1501. <a name="l01472"></a>01472 <span class="comment">// static</span>
  1502. <a name="l01473"></a><a class="code" href="classwxLuaBinding.html#ad59bdead48e7fbcdae57442939eb9e8f">01473</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* <a class="code" href="classwxLuaBinding.html#a7ee5e4f66198a0ef9e8cc4c2a6d0318e">wxLuaBinding::FindBindClass</a>(<span class="keyword">const</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod)
  1503. <a name="l01474"></a>01474 {
  1504. <a name="l01475"></a>01475 wxLuaBindingList::compatibility_iterator node = <a class="code" href="classwxLuaBinding.html#a37817aea87de56a4f10cb8749051cada">sm_bindingList</a>.GetFirst();
  1505. <a name="l01476"></a>01476
  1506. <a name="l01477"></a>01477 <span class="keywordflow">while</span> (node)
  1507. <a name="l01478"></a>01478 {
  1508. <a name="l01479"></a>01479 <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding = node-&gt;GetData();
  1509. <a name="l01480"></a>01480 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = binding-&gt;<a class="code" href="classwxLuaBinding.html#aa9cbed3abdafd742630ec17dadf1874b">GetBindClass</a>(wxlMethod);
  1510. <a name="l01481"></a>01481
  1511. <a name="l01482"></a>01482 <span class="keywordflow">if</span> (wxlClass)
  1512. <a name="l01483"></a>01483 <span class="keywordflow">return</span> wxlClass;
  1513. <a name="l01484"></a>01484
  1514. <a name="l01485"></a>01485 node = node-&gt;GetNext();
  1515. <a name="l01486"></a>01486 }
  1516. <a name="l01487"></a>01487
  1517. <a name="l01488"></a>01488 <span class="keywordflow">return</span> NULL;
  1518. <a name="l01489"></a>01489 }
  1519. <a name="l01490"></a>01490
  1520. <a name="l01491"></a>01491 <span class="comment">// static</span>
  1521. <a name="l01492"></a><a class="code" href="classwxLuaBinding.html#a3644274fa9fe3ebca6aa50e0a77fea1f">01492</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* <a class="code" href="classwxLuaBinding.html#a7ee5e4f66198a0ef9e8cc4c2a6d0318e">wxLuaBinding::FindBindClass</a>(<span class="keyword">const</span> <a class="code" href="structwxLuaBindCFunc.html">wxLuaBindCFunc</a>* wxlCFunc)
  1522. <a name="l01493"></a>01493 {
  1523. <a name="l01494"></a>01494 wxLuaBindingList::compatibility_iterator node = <a class="code" href="classwxLuaBinding.html#a37817aea87de56a4f10cb8749051cada">sm_bindingList</a>.GetFirst();
  1524. <a name="l01495"></a>01495
  1525. <a name="l01496"></a>01496 <span class="keywordflow">while</span> (node)
  1526. <a name="l01497"></a>01497 {
  1527. <a name="l01498"></a>01498 <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding = node-&gt;GetData();
  1528. <a name="l01499"></a>01499 <span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = binding-&gt;<a class="code" href="classwxLuaBinding.html#aa9cbed3abdafd742630ec17dadf1874b">GetBindClass</a>(wxlCFunc);
  1529. <a name="l01500"></a>01500
  1530. <a name="l01501"></a>01501 <span class="keywordflow">if</span> (wxlClass)
  1531. <a name="l01502"></a>01502 <span class="keywordflow">return</span> wxlClass;
  1532. <a name="l01503"></a>01503
  1533. <a name="l01504"></a>01504 node = node-&gt;GetNext();
  1534. <a name="l01505"></a>01505 }
  1535. <a name="l01506"></a>01506
  1536. <a name="l01507"></a>01507 <span class="keywordflow">return</span> NULL;
  1537. <a name="l01508"></a>01508 }
  1538. <a name="l01509"></a>01509
  1539. <a name="l01510"></a>01510 <span class="comment">// static</span>
  1540. <a name="l01511"></a><a class="code" href="classwxLuaBinding.html#acb5add21a46e8c314d94069bb639ca96">01511</a> <span class="keyword">const</span> <a class="code" href="structwxLuaBindEvent.html">wxLuaBindEvent</a>* <a class="code" href="classwxLuaBinding.html#acb5add21a46e8c314d94069bb639ca96">wxLuaBinding::FindBindEvent</a>(wxEventType eventType)
  1541. <a name="l01512"></a>01512 {
  1542. <a name="l01513"></a>01513 wxLuaBindingList::compatibility_iterator node = <a class="code" href="classwxLuaBinding.html#a37817aea87de56a4f10cb8749051cada">sm_bindingList</a>.GetFirst();
  1543. <a name="l01514"></a>01514
  1544. <a name="l01515"></a>01515 <span class="keywordflow">while</span> (node)
  1545. <a name="l01516"></a>01516 {
  1546. <a name="l01517"></a>01517 <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding = node-&gt;GetData();
  1547. <a name="l01518"></a>01518 <span class="keyword">const</span> <a class="code" href="structwxLuaBindEvent.html">wxLuaBindEvent</a>* wxlEvent = binding-&gt;<a class="code" href="classwxLuaBinding.html#a9ab707c3960348e473d6f0b63503dd94">GetBindEvent</a>(eventType);
  1548. <a name="l01519"></a>01519
  1549. <a name="l01520"></a>01520 <span class="keywordflow">if</span> (wxlEvent)
  1550. <a name="l01521"></a>01521 <span class="keywordflow">return</span> wxlEvent;
  1551. <a name="l01522"></a>01522
  1552. <a name="l01523"></a>01523 node = node-&gt;GetNext();
  1553. <a name="l01524"></a>01524 }
  1554. <a name="l01525"></a>01525
  1555. <a name="l01526"></a>01526 <span class="keywordflow">return</span> NULL;
  1556. <a name="l01527"></a>01527 }
  1557. <a name="l01528"></a>01528
  1558. <a name="l01529"></a>01529 <span class="comment">// static</span>
  1559. <a name="l01530"></a><a class="code" href="classwxLuaBinding.html#a463d056fe9bcb54f0408a8ae523ba64e">01530</a> <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* <a class="code" href="classwxLuaBinding.html#a463d056fe9bcb54f0408a8ae523ba64e">wxLuaBinding::FindMethodBinding</a>(<span class="keyword">const</span> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod)
  1560. <a name="l01531"></a>01531 {
  1561. <a name="l01532"></a>01532 wxLuaBindingList::compatibility_iterator node = <a class="code" href="classwxLuaBinding.html#a37817aea87de56a4f10cb8749051cada">sm_bindingList</a>.GetFirst();
  1562. <a name="l01533"></a>01533
  1563. <a name="l01534"></a>01534 <span class="keywordflow">while</span> (node)
  1564. <a name="l01535"></a>01535 {
  1565. <a name="l01536"></a>01536 <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding = node-&gt;GetData();
  1566. <a name="l01537"></a>01537 <span class="keywordtype">size_t</span> n, count = binding-&gt;<a class="code" href="classwxLuaBinding.html#ad36e156e405608f2a78b356cb00006c4">GetFunctionCount</a>();
  1567. <a name="l01538"></a>01538 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* m = binding-&gt;<a class="code" href="classwxLuaBinding.html#acbdedc8269da3564a988771f190932ef">GetFunctionArray</a>();
  1568. <a name="l01539"></a>01539
  1569. <a name="l01540"></a>01540 <span class="keywordflow">for</span> (n = 0; n &lt; count; ++n, ++m)
  1570. <a name="l01541"></a>01541 {
  1571. <a name="l01542"></a>01542 <span class="keywordflow">if</span> (m == wxlMethod)
  1572. <a name="l01543"></a>01543 <span class="keywordflow">return</span> binding;
  1573. <a name="l01544"></a>01544 }
  1574. <a name="l01545"></a>01545
  1575. <a name="l01546"></a>01546 node = node-&gt;GetNext();
  1576. <a name="l01547"></a>01547 }
  1577. <a name="l01548"></a>01548
  1578. <a name="l01549"></a>01549 <span class="keywordflow">return</span> NULL;
  1579. <a name="l01550"></a>01550 }
  1580. <a name="l01551"></a>01551
  1581. <a name="l01552"></a>01552
  1582. <a name="l01553"></a>01553 <span class="comment">// --------------------------------------------------------------------------</span>
  1583. <a name="l01554"></a>01554
  1584. <a name="l01555"></a>01555 <span class="comment">// static</span>
  1585. <a name="l01556"></a><a class="code" href="classwxLuaBinding.html#abb8ab3912057a7268eaa4b1ec900b629">01556</a> <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* <a class="code" href="classwxLuaBinding.html#abb8ab3912057a7268eaa4b1ec900b629">wxLuaBinding::GetClassMethod</a>(<span class="keyword">const</span> <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *wxlClass, <span class="keyword">const</span> <span class="keywordtype">char</span> *methodName, <span class="keywordtype">int</span> method_type, <span class="keywordtype">bool</span> search_baseclasses)
  1586. <a name="l01557"></a>01557 {
  1587. <a name="l01558"></a>01558 wxCHECK_MSG(wxlClass, NULL, wxT(<span class="stringliteral">&quot;Invalid wxLuaBindClass to find method from.&quot;</span>));
  1588. <a name="l01559"></a>01559
  1589. <a name="l01560"></a>01560 <span class="preprocessor">#if 1</span>
  1590. <a name="l01561"></a>01561 <span class="preprocessor"></span>
  1591. <a name="l01562"></a>01562 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a> methodItem = { methodName, method_type, 0, 0, 0 };
  1592. <a name="l01563"></a>01563
  1593. <a name="l01564"></a>01564 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a> *wxlMethod = (<a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a> *)bsearch(&amp;methodItem,
  1594. <a name="l01565"></a>01565 wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a313c0c5eeb60ca717bae7d286dc41d28">wxluamethods</a>,
  1595. <a name="l01566"></a>01566 wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a5eac6feca088451706f0fde55dd73393">wxluamethods_n</a>,
  1596. <a name="l01567"></a>01567 <span class="keyword">sizeof</span>(<a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>),
  1597. <a name="l01568"></a>01568 <a class="code" href="wxlbind_8cpp.html#a08f882d65e213f81b1e29502e71eb174">wxLuaBindMethodArrayCompareFnGet</a>);
  1598. <a name="l01569"></a>01569
  1599. <a name="l01570"></a>01570 <span class="keywordflow">if</span> ((wxlMethod == NULL) &amp;&amp; search_baseclasses &amp;&amp; wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a22728b03f43176679679849fdb48f55e">baseclassNames</a>)
  1600. <a name="l01571"></a>01571 {
  1601. <a name="l01572"></a>01572 <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)
  1602. <a name="l01573"></a>01573 {
  1603. <a name="l01574"></a>01574 wxlMethod = <a class="code" href="classwxLuaBinding.html#abb8ab3912057a7268eaa4b1ec900b629">GetClassMethod</a>(wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#ad6e5609d26483c65f37a6968275d7a0d">baseBindClasses</a>[i], methodName, method_type, search_baseclasses);
  1604. <a name="l01575"></a>01575 <span class="keywordflow">if</span> (wxlMethod != NULL)
  1605. <a name="l01576"></a>01576 <span class="keywordflow">return</span> wxlMethod;
  1606. <a name="l01577"></a>01577 }
  1607. <a name="l01578"></a>01578 }
  1608. <a name="l01579"></a>01579
  1609. <a name="l01580"></a>01580 <span class="preprocessor">#else</span>
  1610. <a name="l01581"></a>01581 <span class="preprocessor"></span>
  1611. <a name="l01582"></a>01582 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a> *wxlMethod = wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a313c0c5eeb60ca717bae7d286dc41d28">wxluamethods</a>;
  1612. <a name="l01583"></a>01583 <span class="keywordtype">int</span> i_method, method_count = wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a5eac6feca088451706f0fde55dd73393">wxluamethods_n</a>;
  1613. <a name="l01584"></a>01584
  1614. <a name="l01585"></a>01585 <span class="comment">// find a method in the class, recurse through classes from which this class is derived.</span>
  1615. <a name="l01586"></a>01586 <span class="keywordflow">for</span> (i_method = 0; i_method &lt; method_count; ++i_method, ++wxlMethod)
  1616. <a name="l01587"></a>01587 {
  1617. <a name="l01588"></a>01588 <span class="keywordflow">if</span> (<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxlMethod-&gt;type, method_type)
  1618. <a name="l01589"></a>01589 &amp;&amp; (strcmp(wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afef5590cd8bd8a9906b658ddcadb674c">name</a>, methodName) == 0))
  1619. <a name="l01590"></a>01590 {
  1620. <a name="l01591"></a>01591 <span class="keywordflow">return</span> wxlMethod;
  1621. <a name="l01592"></a>01592 }
  1622. <a name="l01593"></a>01593 }
  1623. <a name="l01594"></a>01594
  1624. <a name="l01595"></a>01595 <span class="keywordflow">if</span> (search_baseclasses &amp;&amp; wxlClass-&gt;baseclass)
  1625. <a name="l01596"></a>01596 <span class="keywordflow">return</span> <a class="code" href="classwxLuaBinding.html#abb8ab3912057a7268eaa4b1ec900b629">GetClassMethod</a>(wxlClass-&gt;baseclass, methodName, method_type, search_baseclasses);
  1626. <a name="l01597"></a>01597
  1627. <a name="l01598"></a>01598 <span class="preprocessor">#endif</span>
  1628. <a name="l01599"></a>01599 <span class="preprocessor"></span>
  1629. <a name="l01600"></a>01600 <span class="keywordflow">return</span> wxlMethod;
  1630. <a name="l01601"></a>01601 }
  1631. <a name="l01602"></a>01602
  1632. <a name="l01603"></a>01603 <span class="comment">// --------------------------------------------------------------------------</span>
  1633. <a name="l01604"></a>01604
  1634. <a name="l01605"></a><a class="code" href="wxlbind_8cpp.html#a7e8834eee310a88bbfc8ea6b46d5092b">01605</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="wxlbind_8cpp.html#a7e8834eee310a88bbfc8ea6b46d5092b">wxLuaBinding_RecurseBaseMethods</a>(<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass, <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* wxlMethod, <span class="keywordtype">bool</span> force_update)
  1635. <a name="l01606"></a>01606 {
  1636. <a name="l01607"></a>01607 <span class="comment">// iterate through the base classes to find if this function is</span>
  1637. <a name="l01608"></a>01608 <span class="comment">// an overload, but only if we haven&#39;t checked already.</span>
  1638. <a name="l01609"></a>01609 <span class="keywordflow">if</span> (force_update || !<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a>, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fabd62afc95956323115cdd15848ae6f94">WXLUAMETHOD_CHECKED_OVERLOAD</a>|<a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa7deeba1a24d1b937c7fc5284facb0e13">WXLUAMETHOD_DELETE</a>))
  1639. <a name="l01610"></a>01610 {
  1640. <a name="l01611"></a>01611 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a> *parentMethod = wxlMethod;
  1641. <a name="l01612"></a>01612
  1642. <a name="l01613"></a>01613 <span class="comment">// Use the baseclassNames to check for terminating NULL</span>
  1643. <a name="l01614"></a>01614 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a22728b03f43176679679849fdb48f55e">baseclassNames</a> &amp;&amp; wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a22728b03f43176679679849fdb48f55e">baseclassNames</a>[i]; ++i)
  1644. <a name="l01615"></a>01615 {
  1645. <a name="l01616"></a>01616 <span class="comment">// Note that these may be NULL if the lib/module containing them wasn&#39;t loaded</span>
  1646. <a name="l01617"></a>01617 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a> *baseClass = wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#ad6e5609d26483c65f37a6968275d7a0d">baseBindClasses</a>[i];
  1647. <a name="l01618"></a>01618 <span class="keywordflow">if</span> (baseClass != NULL)
  1648. <a name="l01619"></a>01619 {
  1649. <a name="l01620"></a>01620 parentMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a> |= <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fabd62afc95956323115cdd15848ae6f94">WXLUAMETHOD_CHECKED_OVERLOAD</a>; <span class="comment">// have checked parent</span>
  1650. <a name="l01621"></a>01621
  1651. <a name="l01622"></a>01622 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a>* baseMethod = <a class="code" href="classwxLuaBinding.html#abb8ab3912057a7268eaa4b1ec900b629">wxLuaBinding::GetClassMethod</a>(baseClass, wxlMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afef5590cd8bd8a9906b658ddcadb674c">name</a>, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa9dbba989648af34b28cf6a050a41ac46">WXLUAMETHOD_SEARCH_MASK</a>, <span class="keyword">false</span>);
  1652. <a name="l01623"></a>01623 <span class="keywordflow">if</span> (baseMethod)
  1653. <a name="l01624"></a>01624 {
  1654. <a name="l01625"></a>01625 <span class="comment">// don&#39;t link to base class delete functions</span>
  1655. <a name="l01626"></a>01626 <span class="keywordflow">if</span> (!<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(baseMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a>, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fa7deeba1a24d1b937c7fc5284facb0e13">WXLUAMETHOD_DELETE</a>))
  1656. <a name="l01627"></a>01627 {
  1657. <a name="l01628"></a>01628 parentMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#a61bd0c007d8c7064a473d19eac6dd2a6">basemethod</a> = baseMethod;
  1658. <a name="l01629"></a>01629 parentMethod = baseMethod;
  1659. <a name="l01630"></a>01630 }
  1660. <a name="l01631"></a>01631
  1661. <a name="l01632"></a>01632 <span class="comment">// we have already checked the base classes below this</span>
  1662. <a name="l01633"></a>01633 <span class="keywordflow">if</span> (!<a class="code" href="wxldefs_8h.html#a94d4432b789ed04ce0ed6845cb97c1c6">WXLUA_HASBIT</a>(baseMethod-&gt;<a class="code" href="structwxLuaBindMethod.html#afe5a6ea650d981459de29640b339835e">method_type</a>, <a class="code" href="wxlbind_8h.html#aac6bce8c6fcf2445af7ac139f73ba94fabd62afc95956323115cdd15848ae6f94">WXLUAMETHOD_CHECKED_OVERLOAD</a>))
  1663. <a name="l01634"></a>01634 <a class="code" href="wxlbind_8cpp.html#a7e8834eee310a88bbfc8ea6b46d5092b">wxLuaBinding_RecurseBaseMethods</a>(baseClass, parentMethod, force_update);
  1664. <a name="l01635"></a>01635 }
  1665. <a name="l01636"></a>01636 }
  1666. <a name="l01637"></a>01637 }
  1667. <a name="l01638"></a>01638 }
  1668. <a name="l01639"></a>01639 }
  1669. <a name="l01640"></a>01640
  1670. <a name="l01641"></a>01641 <span class="comment">// static</span>
  1671. <a name="l01642"></a><a class="code" href="classwxLuaBinding.html#aba730ce7a36b85518da9ed7858c13d91">01642</a> <span class="keywordtype">void</span> <a class="code" href="classwxLuaBinding.html#aba730ce7a36b85518da9ed7858c13d91">wxLuaBinding::InitAllBindings</a>(<span class="keywordtype">bool</span> force_update)
  1672. <a name="l01643"></a>01643 {
  1673. <a name="l01644"></a>01644 <span class="keywordflow">if</span> (<a class="code" href="classwxLuaBinding.html#a624499a2732caa7d1b14dab0f0998891">sm_bindingList_initialized</a> &amp;&amp; !force_update) <span class="keywordflow">return</span>;
  1674. <a name="l01645"></a>01645
  1675. <a name="l01646"></a>01646 <span class="comment">// Initialize the bindings, sort and set the wxLua types</span>
  1676. <a name="l01647"></a>01647 wxLuaBindingList::compatibility_iterator node = <a class="code" href="classwxLuaBinding.html#a37817aea87de56a4f10cb8749051cada">sm_bindingList</a>.GetFirst();
  1677. <a name="l01648"></a>01648 <span class="keywordflow">while</span> (node)
  1678. <a name="l01649"></a>01649 {
  1679. <a name="l01650"></a>01650 <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding = node-&gt;GetData();
  1680. <a name="l01651"></a>01651 binding-&gt;<a class="code" href="classwxLuaBinding.html#a0adc360c99045857d66a8a5ba9260d51">InitBinding</a>();
  1681. <a name="l01652"></a>01652
  1682. <a name="l01653"></a>01653 node = node-&gt;GetNext();
  1683. <a name="l01654"></a>01654 }
  1684. <a name="l01655"></a>01655
  1685. <a name="l01656"></a>01656 <span class="comment">// set the base class wxLuaBindClass* using the base class names of the parent wxLuaBindClass</span>
  1686. <a name="l01657"></a>01657 node = <a class="code" href="classwxLuaBinding.html#a37817aea87de56a4f10cb8749051cada">sm_bindingList</a>.GetFirst();
  1687. <a name="l01658"></a>01658 <span class="keywordflow">while</span> (node)
  1688. <a name="l01659"></a>01659 {
  1689. <a name="l01660"></a>01660 <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding = node-&gt;GetData();
  1690. <a name="l01661"></a>01661 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = binding-&gt;<a class="code" href="classwxLuaBinding.html#a32bc027323b845ac37b1f383b1525401">GetClassArray</a>();
  1691. <a name="l01662"></a>01662 <span class="keywordtype">size_t</span> i, class_count = binding-&gt;<a class="code" href="classwxLuaBinding.html#a49392182119d61caaf1fe96b0fd51851">GetClassCount</a>();
  1692. <a name="l01663"></a>01663
  1693. <a name="l01664"></a>01664 <span class="keywordflow">for</span> (i = 0; i &lt; class_count; ++i, ++wxlClass)
  1694. <a name="l01665"></a>01665 {
  1695. <a name="l01666"></a>01666 <span class="keywordflow">if</span> (wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a22728b03f43176679679849fdb48f55e">baseclassNames</a>) <span class="comment">// does it have any base classes at all?</span>
  1696. <a name="l01667"></a>01667 {
  1697. <a name="l01668"></a>01668 <span class="comment">// find the base class using their names in the bindings</span>
  1698. <a name="l01669"></a>01669 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 0; wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a22728b03f43176679679849fdb48f55e">baseclassNames</a>[j]; ++j)
  1699. <a name="l01670"></a>01670 {
  1700. <a name="l01671"></a>01671 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlBaseClass = (<a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>*)<a class="code" href="classwxLuaBinding.html#a7ee5e4f66198a0ef9e8cc4c2a6d0318e">wxLuaBinding::FindBindClass</a>(wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a22728b03f43176679679849fdb48f55e">baseclassNames</a>[j]);
  1701. <a name="l01672"></a>01672 <span class="keywordflow">if</span> (wxlBaseClass)
  1702. <a name="l01673"></a>01673 wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#ad6e5609d26483c65f37a6968275d7a0d">baseBindClasses</a>[j] = wxlBaseClass;
  1703. <a name="l01674"></a>01674 }
  1704. <a name="l01675"></a>01675 }
  1705. <a name="l01676"></a>01676 }
  1706. <a name="l01677"></a>01677
  1707. <a name="l01678"></a>01678 node = node-&gt;GetNext();
  1708. <a name="l01679"></a>01679 }
  1709. <a name="l01680"></a>01680
  1710. <a name="l01681"></a>01681 <span class="comment">// Link together all of the class member functions with base class functions</span>
  1711. <a name="l01682"></a>01682 <span class="comment">// with the same name so the overloads work for them too.</span>
  1712. <a name="l01683"></a>01683 node = <a class="code" href="classwxLuaBinding.html#a37817aea87de56a4f10cb8749051cada">sm_bindingList</a>.GetFirst();
  1713. <a name="l01684"></a>01684 <span class="keywordflow">while</span> (node)
  1714. <a name="l01685"></a>01685 {
  1715. <a name="l01686"></a>01686 <a class="code" href="classwxLuaBinding.html">wxLuaBinding</a>* binding = node-&gt;GetData();
  1716. <a name="l01687"></a>01687 <a class="code" href="structwxLuaBindClass.html">wxLuaBindClass</a>* wxlClass = binding-&gt;<a class="code" href="classwxLuaBinding.html#a32bc027323b845ac37b1f383b1525401">GetClassArray</a>();
  1717. <a name="l01688"></a>01688 <span class="keywordtype">size_t</span> i, class_count = binding-&gt;<a class="code" href="classwxLuaBinding.html#a49392182119d61caaf1fe96b0fd51851">GetClassCount</a>();
  1718. <a name="l01689"></a>01689
  1719. <a name="l01690"></a>01690 <span class="keywordflow">for</span> (i = 0; i &lt; class_count; ++i, ++wxlClass)
  1720. <a name="l01691"></a>01691 {
  1721. <a name="l01692"></a>01692 <span class="keywordflow">if</span> (wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a22728b03f43176679679849fdb48f55e">baseclassNames</a>) <span class="comment">// does it have any base classes at all?</span>
  1722. <a name="l01693"></a>01693 {
  1723. <a name="l01694"></a>01694 <a class="code" href="structwxLuaBindMethod.html">wxLuaBindMethod</a> *wxlMethod = wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a313c0c5eeb60ca717bae7d286dc41d28">wxluamethods</a>;
  1724. <a name="l01695"></a>01695 <span class="keywordtype">size_t</span> j, method_count = wxlClass-&gt;<a class="code" href="structwxLuaBindClass.html#a5eac6feca088451706f0fde55dd73393">wxluamethods_n</a>;
  1725. <a name="l01696"></a>01696
  1726. <a name="l01697"></a>01697 <span class="keywordflow">for</span> (j = 0; j &lt; method_count; ++j, ++wxlMethod)
  1727. <a name="l01698"></a>01698 {
  1728. <a name="l01699"></a>01699 <a class="code" href="wxlbind_8cpp.html#a7e8834eee310a88bbfc8ea6b46d5092b">wxLuaBinding_RecurseBaseMethods</a>(wxlClass, wxlMethod, force_update);
  1729. <a name="l01700"></a>01700 }
  1730. <a name="l01701"></a>01701 }
  1731. <a name="l01702"></a>01702 }
  1732. <a name="l01703"></a>01703
  1733. <a name="l01704"></a>01704 node = node-&gt;GetNext();
  1734. <a name="l01705"></a>01705 }
  1735. <a name="l01706"></a>01706
  1736. <a name="l01707"></a>01707 <a class="code" href="classwxLuaBinding.html#a624499a2732caa7d1b14dab0f0998891">sm_bindingList_initialized</a> = <span class="keyword">true</span>;
  1737. <a name="l01708"></a>01708 }
  1738. </pre></div></div>
  1739. <hr class="footer"/><address style="text-align: right;"><small>Generated on Tue Jul 13 10:30:39 2010 for wxLua by&nbsp;
  1740. <a href="http://www.doxygen.org/index.html">
  1741. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
  1742. </body>
  1743. </html>