summaryrefslogtreecommitdiffstats
path: root/kde/kdebindings/ruby.patch
blob: 5276dedcd99f194aa44aa45ef4f8c2c0c27df9aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
* Set up a RUBY_VERSION macro to use to test for whether QtRuby is being
  built for Ruby 1.9 or not. Add patches from Mr Napalm for building 
with
  Ruby 1.9, for the new 'per string' encoding. Also add conditional code
  for whether to use the new rb_frame_callee() function or the old
  rb_frame_last_func() one.

CCMAIL: kde-bindings@...


 M  +10 -0     CMakeLists.txt  
 M  +7 -0      qtruby/ChangeLog  
 M  +4 -0      qtruby/src/CMakeLists.txt  
 M  +37 -6     qtruby/src/handlers.cpp  
 M  +0 -1      qtruby/src/marshall_types.cpp  
 M  +4 -0      qtruby/src/qtruby.cpp  


--- trunk/KDE/kdebindings/ruby/CMakeLists.txt #920196:920197
@@ -46,6 +46,16 @@
 set(PLASMA_ENABLED "no")
 
 if(RUBY_EXECUTABLE AND RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
+   EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -e "print RUBY_VERSION"
+      OUTPUT_VARIABLE RUBY_VERSION)
+
+    STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" 
RUBY_VERSION_MAJOR "${RUBY_VERSION}")
+    STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" 
RUBY_VERSION_MINOR "${RUBY_VERSION}")
+    STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" 
RUBY_VERSION_PATCH "${RUBY_VERSION}")
+
+    # compute an overall version number which can be compared at once
+    MATH(EXPR RUBY_VERSION_NUMBER "${RUBY_VERSION_MAJOR}*10000 + 
${RUBY_VERSION_MINOR}*100 + ${RUBY_VERSION_PATCH}")
+
     if(ENABLE_QTRUBY)
         add_subdirectory( qtruby )
         set(QTRUBY_ENABLED "yes")
--- trunk/KDE/kdebindings/ruby/qtruby/ChangeLog #920196:920197
@@ -1,3 +1,10 @@
+2009-02-02  Richard Dale  <richard.j.dale@...>
+ * Set up a RUBY_VERSION macro to use to test for whether QtRuby is 
being
+  built for Ruby 1.9 or not. Add patches from Mr Napalm for building 
with
+  Ruby 1.9, for the new 'per string' encoding. Also add conditional 
code
+  for whether to use the new rb_frame_callee() function or the old
+  rb_frame_last_func() one.
+
 2009-02-01  Richard Dale  <richard.j.dale@...>
  * The construct_copy() function was using the full classname of the 
class
   to construct which meant that it didn't work with classnames 
containing
--- trunk/KDE/kdebindings/ruby/qtruby/src/CMakeLists.txt #920196:920197
@@ -9,6 +9,10 @@
     ADD_DEFINITIONS (-DQT_QWT)
 ENDIF(QWT_FOUND)
 
+if(RUBY_VERSION)
+    ADD_DEFINITIONS (-DRUBY_VERSION=0x${RUBY_VERSION_NUMBER})
+ENDIF(RUBY_VERSION)
+
 include_directories( ${CMAKE_SOURCE_DIR}/smoke ${RUBY_INCLUDE_PATH} )
 INCLUDE_DIRECTORIES (${QT_INCLUDES})
 
--- trunk/KDE/kdebindings/ruby/qtruby/src/handlers.cpp #920196:920197
@@ -891,9 +891,11 @@
  }
 }
 
-static const char * KCODE = 0;
 static QTextCodec *codec = 0;
 
+#if RUBY_VERSION < 0x10900
+static const char * KCODE = 0;
+
 static void
 init_codec() {
  VALUE temp = rb_gv_get("$KCODE");
@@ -923,11 +925,6 @@
  return new QString(QString::fromLocal8Bit(StringValuePtr(rstring), 
RSTRING_LEN(rstring)));
 }
 
-QByteArray*
-qbytearrayFromRString(VALUE rstring) {
-  return new QByteArray(StringValuePtr(rstring), RSTRING_LEN(rstring));
-}
-
 VALUE
 rstringFromQString(QString * s) {
  if (KCODE == 0) {
@@ -946,6 +943,40 @@
  return rb_str_new2(s->toLocal8Bit());
 }
 
+#else
+
+QString*
+qstringFromRString(VALUE rstring) {
+ VALUE encoding = rb_funcall(rstring, rb_intern("encoding"), 0);
+ encoding = rb_funcall(encoding, rb_intern("to_s"), 0);
+ const char * enc_s = RSTRING_PTR(encoding);
+
+ if (qstrcmp(enc_s, "UTF8") == 0) {
+ return new QString(QString::fromUtf8(StringValuePtr(rstring), 
RSTRING_LEN(rstring)));
+ } else if (qstrcmp(enc_s, "EUC-JP") == 0) {
+ codec = QTextCodec::codecForName("eucJP");
+ return new QString(codec->toUnicode(StringValuePtr(rstring)));
+ } else if (qstrcmp(enc_s, "Shift-JIS") == 0) {
+ codec = QTextCodec::codecForName("Shift-JIS");
+ return new QString(codec->toUnicode(StringValuePtr(rstring)));
+ } else if(qstrcmp(enc_s, "ISO-8859-1") == 0 || qstrcmp(enc_s, 
"US-ASCII") == 0) {
+ return new QString(QString::fromLatin1(StringValuePtr(rstring)));
+ }
+
+ return new QString(QString::fromLocal8Bit(StringValuePtr(rstring), 
RSTRING_LEN(rstring)));
+}
+
+VALUE
+rstringFromQString(QString * s) {
+ return rb_str_new2(s->toUtf8());
+}
+#endif
+
+QByteArray*
+qbytearrayFromRString(VALUE rstring) {
+  return new QByteArray(StringValuePtr(rstring), RSTRING_LEN(rstring));
+}
+
 VALUE
 rstringFromQByteArray(QByteArray * s) {
   return rb_str_new(s->data(), s->size());
--- trunk/KDE/kdebindings/ruby/qtruby/src/marshall_types.cpp 
#920196:920197
@@ -17,7 +17,6 @@
  
***************************************************************************/
 
 #include "marshall_types.h"
-#include <rubysig.h>
 #include <smoke/qt_smoke.h>
 #include <QtDBus>
 
--- trunk/KDE/kdebindings/ruby/qtruby/src/qtruby.cpp #920196:920197
@@ -1365,7 +1365,11 @@
  return Qfalse;
  }
 
+#if RUBY_VERSION >= 0x10900
+ QLatin1String signalname(rb_id2name(rb_frame_callee()));
+#else
  QLatin1String signalname(rb_id2name(rb_frame_last_func()));
+#endif
  VALUE metaObject_value = rb_funcall(qt_internal_module, 
rb_intern("getMetaObject"), 2, Qnil, self);
 
  smokeruby_object *ometa = value_obj_info(metaObject_value);