nobody at rubyforge.org
2007-Jan-05 23:19 UTC
[Wxruby-development] [831] trunk/wxruby2: Use simple ruby Integers to represent TreeItemIds
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type"
content="text/html; charset=utf-8" /><style
type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:'':'';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family:
verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;
font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding:
6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid;
padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family:
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch
.binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[831] trunk/wxruby2: Use simple ruby Integers to represent
TreeItemIds</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>831</dd>
<dt>Author</dt> <dd>brokentoy</dd>
<dt>Date</dt> <dd>2007-01-05 18:19:57 -0500 (Fri, 05 Jan
2007)</dd>
</dl>
<h3>Log Message</h3>
<pre>Use simple ruby Integers to represent TreeItemIds</pre>
<h3>Modified Paths</h3>
<ul>
<li><a
href="#trunkwxruby2swigclassesTreeCtrli">trunk/wxruby2/swig/classes/TreeCtrl.i</a></li>
<li><a
href="#trunkwxruby2swigclassesTreeEventi">trunk/wxruby2/swig/classes/TreeEvent.i</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a
href="#trunkwxruby2swigsharedtreeitemid_typemapsi">trunk/wxruby2/swig/shared/treeitemid_typemaps.i</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a
href="#trunkwxruby2libwxclassestreeitemidrb">trunk/wxruby2/lib/wx/classes/treeitemid.rb</a></li>
<li><a
href="#trunkwxruby2swigclassesTreeItemIdi">trunk/wxruby2/swig/classes/TreeItemId.i</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwxruby2libwxclassestreeitemidrb"></a>
<div class="delfile"><h4>Deleted:
trunk/wxruby2/lib/wx/classes/treeitemid.rb (830 => 831)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/lib/wx/classes/treeitemid.rb        2007-01-05
22:17:42 UTC (rev 830)
+++
trunk/wxruby2/lib/wx/classes/treeitemid.rb        2007-01-05
23:19:57 UTC (rev 831)
</span><span class="lines">@@ -1,8 +0,0 @@
</span><del>-class Wx::TreeItemId
- # Fix equality here because TreeCtrl methods don''t return identical
- # TreeItemIds for repeated calls referring to the same item.
- def ==(other)
- return false unless other.is_a?(self.class)
- return self.to_i == other.to_i
- end
-end
</del></span></pre></div>
<a id="trunkwxruby2swigclassesTreeCtrli"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/swig/classes/TreeCtrl.i (830 => 831)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/TreeCtrl.i        2007-01-05
22:17:42 UTC (rev 830)
+++
trunk/wxruby2/swig/classes/TreeCtrl.i        2007-01-05
23:19:57 UTC (rev 831)
</span><span class="lines">@@ -1,3 +1,4 @@
</span><ins>+
</ins><span class="cx"> # Copyright 2004-2006 by Kevin
Smith
</span><span class="cx"> # released under the MIT-style
wxruby2 license
</span><span class="cx">
</span><span class="lines">@@ -9,7 +10,10 @@
</span><span class="cx"> #include <wx/treectrl.h>
</span><span class="cx"> %}
</span><span class="cx">
</span><del>- // ITEM DATA fixes - This is done so the API user
never sees a
</del><ins>+// wxTreeItemId fixes - these typemaps convert them to
ruby Integers
+%include "../shared/treeitemid_typemaps.i"
+
+// ITEM DATA fixes - This is done so the API user never sees a
</ins><span class="cx"> // TreeItemData object - where in
Wx C++ such an object
</span><span class="cx"> // would be passed or returned by
a method, any Ruby object may be used.
</span><span class="cx"> %{
</span><span class="lines">@@ -114,10 +118,9 @@
</span><span class="cx">
        {
</span><span class="cx">
                void*
cookie = 0;
</span><span class="cx">
                wxTreeItemId
ret_item = self->GetFirstChild(item, cookie);
</span><del>-                
</del><span class="cx">
                VALUE
array =
rb_ary_new();                        
</span><del>-                VALUE
ret_item_ruby = SWIG_NewPointerObj((new wxTreeItemId(static_cast< const
wxTreeItemId& >(ret_item))), SWIGTYPE_p_wxTreeItemId, SWIG_POINTER_OWN |
0
);                                                                        
-                rb_ary_push(array,ret_item_ruby);        
</del><ins>+
+                rb_ary_push(array,LONG2NUM((long)ret_item.m_pItem));
</ins><span class="cx">
                rb_ary_push(array,LONG2NUM((long)cookie));
</span><span class="cx">
                        
</span><span class="cx">
                return
array;                
</span><span class="lines">@@ -128,8 +131,8 @@
</span><span class="cx">
                wxTreeItemId
ret_item = self->GetNextChild(item, cookie);
</span><span class="cx">
                
</span><span class="cx">
                VALUE
array =
rb_ary_new();                        
</span><del>-                VALUE
ret_item_ruby = SWIG_NewPointerObj((new wxTreeItemId(static_cast< const
wxTreeItemId& >(ret_item))), SWIGTYPE_p_wxTreeItemId, SWIG_POINTER_OWN |
0
);                                                                        
-                rb_ary_push(array,ret_item_ruby);        
</del><ins>+
+                rb_ary_push(array,LONG2NUM((long)ret_item.m_pItem));        
</ins><span class="cx">
                rb_ary_push(array,LONG2NUM((long)cookie));
</span><span class="cx">
                        
</span><span class="cx">
                return
array;                
</span></span></pre></div>
<a id="trunkwxruby2swigclassesTreeEventi"></a>
<div class="modfile"><h4>Modified:
trunk/wxruby2/swig/classes/TreeEvent.i (830 => 831)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/TreeEvent.i        2007-01-05
22:17:42 UTC (rev 830)
+++
trunk/wxruby2/swig/classes/TreeEvent.i        2007-01-05
23:19:57 UTC (rev 831)
</span><span class="lines">@@ -9,6 +9,9 @@
</span><span class="cx"> #include <wx/treectrl.h>
</span><span class="cx"> %}
</span><span class="cx">
</span><ins>+// wxTreeItemId fixes - these typemaps convert them to
ruby Integers
+%include "../shared/treeitemid_typemaps.i"
+
</ins><span class="cx"> %import
"include/wxObject.h"
</span><span class="cx"> %import
"include/wxEvent.h"
</span><span class="cx"> %import
"include/wxCommandEvent.h"
</span></span></pre></div>
<a id="trunkwxruby2swigclassesTreeItemIdi"></a>
<div class="delfile"><h4>Deleted:
trunk/wxruby2/swig/classes/TreeItemId.i (830 => 831)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/classes/TreeItemId.i        2007-01-05
22:17:42 UTC (rev 830)
+++
trunk/wxruby2/swig/classes/TreeItemId.i        2007-01-05
23:19:57 UTC (rev 831)
</span><span class="lines">@@ -1,20 +0,0 @@
</span><del>-# Copyright 2004-2006 by Kevin Smith
-# released under the MIT-style wxruby2 license
-
-%include "../common.i"
-
-%module(directors="1") wxTreeItemId
-
-%{
-#include <wx/treectrl.h>
-%}
-
-// returns the underlying opaque identifier as a ruby fixnum
-%extend wxTreeItemId {
- VALUE to_i()
- {
-        return
INT2NUM( (int)self->m_pItem );
- }
-}
-
-%include "include/wxTreeItemId.h"
</del></span></pre></div>
<a id="trunkwxruby2swigsharedtreeitemid_typemapsi"></a>
<div class="addfile"><h4>Added:
trunk/wxruby2/swig/shared/treeitemid_typemaps.i (0 => 831)</h4>
<pre class="diff"><span>
<span class="info">---
trunk/wxruby2/swig/shared/treeitemid_typemaps.i        
(rev 0)
+++
trunk/wxruby2/swig/shared/treeitemid_typemaps.i        2007-01-05
23:19:57 UTC (rev 831)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+// These typemaps are used by TreeCtrl and TreeEvent to
convert wx tree
+// item ids into simple
+
+%typemap(in) wxTreeItemId& "$1 = new
wxTreeItemId(NUM2LONG($input));"
+%typemap(out) wxTreeItemId "$result = LONG2NUM( (long)$1.m_pItem );"
+%typemap(directorin) wxTreeItemId& "$input = LONG2NUM(
(long)$1.m_pItem );"
+%typemap(directorout) wxTreeItemId& "$result = new
wxTreeItemId(NUM2LONG($1));"
+%typemap(freearg) wxTreeItemId& "delete $1;"
+
+
</ins></span></pre>
</div>
</div>
</body>
</html>
Reasonably Related Threads
- [888] branches/wxruby2/wxwidgets_282/swig/shared/treeitemid_typemaps.i: Fix compile warning for TreeItemId typemap (Artur Kuptel)
- wxTreeItemId
- [799] trunk/wxruby2: Fixed TreeItemId == method
- [835] trunk/wxruby2/doc/textile: Updated documentation about TreeItemId
- [741] trunk/wxruby2: Fix get_item_data, hiding TreeItemData messiness, fix GC-ing (Alex Fenton)
