nobody at rubyforge.org
2007-Apr-13 19:21 UTC
[Wxruby-development] [961] branches/wxruby2/wxwidgets_282/swig: Move wxDateTime typemap into shared file, map to core Time class instead
<!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>[961] branches/wxruby2/wxwidgets_282/swig: Move wxDateTime typemap
into shared file, map to core Time class instead</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>961</dd>
<dt>Author</dt> <dd>brokentoy</dd>
<dt>Date</dt> <dd>2007-04-13 15:21:31 -0400 (Fri, 13 Apr
2007)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move wxDateTime typemap into shared file, map to core Time class
instead
of stdlib DateTime</pre>
<h3>Modified Paths</h3>
<ul>
<li><a
href="#brancheswxruby2wxwidgets_282swigclassesCalendarCtrli">branches/wxruby2/wxwidgets_282/swig/classes/CalendarCtrl.i</a></li>
<li><a
href="#brancheswxruby2wxwidgets_282swigclassesCalendarEventi">branches/wxruby2/wxwidgets_282/swig/classes/CalendarEvent.i</a></li>
<li><a
href="#brancheswxruby2wxwidgets_282swigtypemapi">branches/wxruby2/wxwidgets_282/swig/typemap.i</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a
href="#brancheswxruby2wxwidgets_282swigshareddatetimei">branches/wxruby2/wxwidgets_282/swig/shared/datetime.i</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a
id="brancheswxruby2wxwidgets_282swigclassesCalendarCtrli"></a>
<div class="modfile"><h4>Modified:
branches/wxruby2/wxwidgets_282/swig/classes/CalendarCtrl.i (960 =>
961)</h4>
<pre class="diff"><span>
<span class="info">---
branches/wxruby2/wxwidgets_282/swig/classes/CalendarCtrl.i        2007-04-13
19:19:44 UTC (rev 960)
+++
branches/wxruby2/wxwidgets_282/swig/classes/CalendarCtrl.i        2007-04-13
19:21:31 UTC (rev 961)
</span><span class="lines">@@ -5,10 +5,22 @@
</span><span class="cx">
</span><span class="cx"> %module(directors="1")
wxCalendarCtrl
</span><span class="cx">
</span><ins>+%include "../shared/datetime.i"
+
</ins><span class="cx"> %{
</span><span class="cx"> #include <wx/calctrl.h>
</span><span class="cx"> %}
</span><span class="cx">
</span><ins>+
+
+%typemap(in) wxCalendarDateBorder {
+        $1 =
(wxCalendarDateBorder)NUM2INT($input);
+}
+
+%typemap(out) wxCalendarDateBorder {
+ $result = INT2NUM((int)$1);
+}
+
</ins><span class="cx"> %ignore
wxCalendarCtrl::wxCalendarCtrl();
</span><span class="cx">
</span><span class="cx"> %import
"include/wxObject.h"
</span></span></pre></div>
<a
id="brancheswxruby2wxwidgets_282swigclassesCalendarEventi"></a>
<div class="modfile"><h4>Modified:
branches/wxruby2/wxwidgets_282/swig/classes/CalendarEvent.i (960 =>
961)</h4>
<pre class="diff"><span>
<span class="info">---
branches/wxruby2/wxwidgets_282/swig/classes/CalendarEvent.i        2007-04-13
19:19:44 UTC (rev 960)
+++
branches/wxruby2/wxwidgets_282/swig/classes/CalendarEvent.i        2007-04-13
19:21:31 UTC (rev 961)
</span><span class="lines">@@ -3,11 +3,13 @@
</span><span class="cx">
</span><span class="cx"> %include "../common.i"
</span><span class="cx">
</span><ins>+%module(directors="1") wxCalendarEvent
+
</ins><span class="cx"> %{
</span><span class="cx"> #include <wx/calctrl.h>
</span><span class="cx"> %}
</span><span class="cx">
</span><del>-%module(directors="1") wxCalendarEvent
</del><ins>+%include "../shared/datetime.i"
</ins><span class="cx">
</span><span class="cx"> %import
"include/wxObject.h"
</span><span class="cx"> %import
"include/wxEvent.h"
</span></span></pre></div>
<a
id="brancheswxruby2wxwidgets_282swigshareddatetimei"></a>
<div class="addfile"><h4>Added:
branches/wxruby2/wxwidgets_282/swig/shared/datetime.i (0 => 961)</h4>
<pre class="diff"><span>
<span class="info">---
branches/wxruby2/wxwidgets_282/swig/shared/datetime.i        
(rev 0)
+++
branches/wxruby2/wxwidgets_282/swig/shared/datetime.i        2007-04-13
19:21:31 UTC (rev 961)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+// Typemaps for converting between wxDateTime and
Ruby''s Date and Time classes
+
+%{
+#include <wx/datetime.h>
+%}
+
+%typemap(in) const wxDateTime& {
+ int y = NUM2INT(rb_funcall($input, rb_intern("year"), 0));
+ int rMonth = NUM2INT(rb_funcall($input, rb_intern("month"), 0));
+ int rDay = NUM2INT(rb_funcall($input, rb_intern("mday"), 0));
+ int rHour = NUM2INT(rb_funcall($input, rb_intern("hour"), 0));
+ int rMinute = NUM2INT(rb_funcall($input, rb_intern("min"), 0));
+ int rSecond = NUM2INT(rb_funcall($input, rb_intern("sec"), 0));
+ wxDateTime::Month mon = (wxDateTime::Month)(rMonth-1);
+ wxDateTime::wxDateTime_t d = (wxDateTime::wxDateTime_t)rDay;
+ wxDateTime::wxDateTime_t h = (wxDateTime::wxDateTime_t)rHour;
+ wxDateTime::wxDateTime_t min = (wxDateTime::wxDateTime_t)rMinute;
+ wxDateTime::wxDateTime_t s = (wxDateTime::wxDateTime_t)rSecond;
+
+        $1 =
new wxDateTime(d, mon, y, h, min, s, 0);
+}
+
+%typemap(out) wxDateTime& {
+ VALUE y = INT2NUM($1->GetYear());
+ VALUE mon = INT2NUM($1->GetMonth() + 1);
+ VALUE d = INT2NUM($1->GetDay());
+ VALUE h = INT2NUM($1->GetHour());
+ VALUE min = INT2NUM($1->GetMinute());
+ VALUE s = INT2NUM($1->GetSecond());
+
+ VALUE cTime = rb_iv_get(rb_cObject, "Time");
+ // $result = rb_funcall(cDateTime, rb_intern("new"), 6, y, mon,
d, h, min, s);
+ $result = rb_funcall(cTime, rb_intern("local"), 6, y, mon, d, h,
min, s);
+}
+
+// Need to have this to over-ride the default which does not work
+%typemap(typecheck) const wxDateTime& {
+        $1 =
(TYPE($input) != T_NONE);
+}
</ins></span></pre></div>
<a id="brancheswxruby2wxwidgets_282swigtypemapi"></a>
<div class="modfile"><h4>Modified:
branches/wxruby2/wxwidgets_282/swig/typemap.i (960 => 961)</h4>
<pre class="diff"><span>
<span class="info">---
branches/wxruby2/wxwidgets_282/swig/typemap.i        2007-04-13
19:19:44 UTC (rev 960)
+++
branches/wxruby2/wxwidgets_282/swig/typemap.i        2007-04-13
19:21:31 UTC (rev 961)
</span><span class="lines">@@ -169,60 +169,6 @@
</span><span class="cx">
        $1 =
(TYPE($input) == T_FIXNUM && TYPE($input) != T_TRUE &&
TYPE($input) != T_FALSE);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-##############################################################
-
-%typemap(in) wxCalendarDateBorder {
-        $1 =
(wxCalendarDateBorder)NUM2INT($input);
-}
-
-%typemap(out) wxCalendarDateBorder {
- $result = INT2NUM((int)$1);
-}
-
-##############################################################
-
-%{
-#include <wx/datetime.h>
-%}
-
-%typemap(in) const wxDateTime& {
- int y = NUM2INT(rb_funcall($input, rb_intern("year"), 0));
- int rMonth = NUM2INT(rb_funcall($input, rb_intern("month"), 0));
- int rDay = NUM2INT(rb_funcall($input, rb_intern("mday"), 0));
- int rHour = NUM2INT(rb_funcall($input, rb_intern("hour"), 0));
- int rMinute = NUM2INT(rb_funcall($input, rb_intern("min"), 0));
- int rSecond = NUM2INT(rb_funcall($input, rb_intern("sec"), 0));
- wxDateTime::Month mon = (wxDateTime::Month)(rMonth-1);
- wxDateTime::wxDateTime_t d = (wxDateTime::wxDateTime_t)rDay;
- wxDateTime::wxDateTime_t h = (wxDateTime::wxDateTime_t)rHour;
- wxDateTime::wxDateTime_t min = (wxDateTime::wxDateTime_t)rMinute;
- wxDateTime::wxDateTime_t s = (wxDateTime::wxDateTime_t)rSecond;
-
-        $1 =
new wxDateTime(d, mon, y, h, min, s, 0);
-}
-
-%typemap(out) wxDateTime& {
- VALUE y = INT2NUM($1->GetYear());
- VALUE mon = INT2NUM($1->GetMonth() + 1);
- VALUE d = INT2NUM($1->GetDay());
- VALUE h = INT2NUM($1->GetHour());
- VALUE min = INT2NUM($1->GetMinute());
- VALUE s = INT2NUM($1->GetSecond());
-
- VALUE cDateTime = rb_iv_get(rb_cObject, "DateTime");
- $result = rb_funcall(cDateTime, rb_intern("new"), 6, y, mon, d,
h, min, s);
-}
-
-# Need to have this to over-ride the default which does not work
-%typemap(typecheck) const wxDateTime& {
-        $1 =
(TYPE($input) != T_NONE);
-}
-
-%apply int { wxDateTime::WeekDay }
-
-##############################################################
-
-
</del><span class="cx"> %typemap(in,numinputs=1) (int n,
const wxString choices []) (wxString *arr)
</span><span class="cx"> {
</span><span class="cx"> if (($input == Qnil) ||
(TYPE($input) != T_ARRAY))
</span></span></pre>
</div>
</div>
</body>
</html>
Possibly Parallel Threads
- [1072] trunk/wxruby2/swig/shared/datetime.i: Add typemap for DateTime::WeekDay; plug mem leak with wxDateTime arg
- [1084] trunk/wxruby2/swig/classes/SystemSettings.i: Fix missing punctuation in SystemSettings typemaps
- [1080] trunk/wxruby2/swig: Moved typemaps specific to SystemSetting out of general typemap file
- Fwd: win32-service problems with patch
- [756] trunk/wxruby2/swig: Moved one-shot typemaps for ListBox.get_selections into ListBox.i
