qtbindings 4.8.5.2 → 4.8.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7bb1a13dfa6a4788219c66e0ed52bd76f4893044
4
- data.tar.gz: 78b868e86ad325665e8f6846e2564a1ddad363ed
3
+ metadata.gz: ac37d8d099cae6f72ab5cea298864f616d32b3c0
4
+ data.tar.gz: 4ddf1bd802e1f241a3e6f1600f264276e55558d6
5
5
  SHA512:
6
- metadata.gz: 4d4e339fadc3c63d885d9d6be07a6c74e3358064dfa11f8f58740fa852c95137d4732d1624c1773ecb3053455ca5d3b1892bc39af468a8b474db420eee6b5fab
7
- data.tar.gz: 0a0b4ae4916789e898a4cc8c85daacc92710f461c7274f303ff4a3705554abd87514ab5e0d2cd158bf68222770e668ed52f8580fc1fdd693f96ad3f25065f80e
6
+ metadata.gz: ebeca2402dcdd00ea7dde6ce2df3591672a90b9585ff8fcf4b03ab2967dc8ff443a3b6ebef66c97802a6a0521da1c5c1100927262b10e339fe8a6fa44ec1603d
7
+ data.tar.gz: 5d105c6cacef2775eb1a6b263f713b87da3d74783ca08f273ee3f79b17a92aa8f703c48f95c4ca44f6e4eabe473b17f9454c818525bb762d3e20f4112d60c7bc
data/README.txt CHANGED
@@ -10,37 +10,47 @@ Goals
10
10
  1. To make it easy to install a Qt binding for Ruby on all platforms using
11
11
  RubyGems
12
12
  2. To maintain an up-to-date binary gem for Windows that is bundled with
13
- the latest version of Qt from http://qt.nokia.com
13
+ the latest version of Qt
14
14
  3. To reduce the scope and maintenance of the bindings to only bind to the
15
15
  libraries provided by the Qt SDK.
16
16
  4. To increase compatibility with non-linux platforms
17
17
 
18
- Note: This gem only supports Ruby 1.9.3 and Ruby 2.0.0 starting at qtbindings version 4.8.5.0.
18
+ Note: This gem supports Ruby 2.0.0+ starting at qtbindings version 4.8.6.0.
19
+ For Ruby 1.9.3 you should use version 4.8.5.2.
19
20
  For Ruby 1.8.x you can try installing version 4.8.3.0, however upgrading Ruby is
20
21
  highly recommended.
21
22
 
22
23
  Usage Notes
23
24
  ------------
24
- Ruby threading is now fully supported out of the box. All GUI access however must be done
25
- inside the main thread. To support updating the GUI using other threads, use the following function
25
+ Ruby threading is now fully supported out of the box. All GUI access however must be done
26
+ inside the main thread. To support updating the GUI using other threads, use the following function
26
27
  provided in Qt4.rb:
27
28
 
28
- Qt.execute_in_main_thread(true) do
29
- # GUI code here
29
+ Qt.execute_in_main_thread do # block the main thread
30
+ # GUI code which executes and then allows the main thread to execute
31
+ end
32
+
33
+ Qt.execute_in_main_thread(false) do # don't block the main thread
34
+ # GUI code which executes in parallel with the main thread
30
35
  end
31
36
 
32
37
  Tested Environments
33
38
  --------------------
34
- Mac OSX 10.6.8 (Snow Leopard)
35
- XCode 3.2.6 (gcc 4.2.1)
36
- Brew - QT 4.8.5
37
- Cmake 2.8.11.2
38
- Ruby 1.9.3p448
39
+ Mac OSX 10.9.1 (Mavericks)
40
+ XCode 5 (clang)
41
+ Brew - QT 4.8.6
42
+ Cmake 2.8.9
43
+ Ruby 2.0.0p353 - Must be compiled with clang (rvm install <version> --with-gcc=clang)
39
44
 
40
45
  Windows XP SP3
41
46
  QT SDK 4.8.5
42
47
  Cmake 2.8.8
43
- Ruby 1.9.3p448 and Ruby 2.0.0p353 installed from rubyinstaller.org
48
+ Ruby Ruby 2.0.0p481 installed from rubyinstaller.org
49
+
50
+ Windows 7 SP1
51
+ QT SDK 4.8.6
52
+ Cmake 2.8.12.2
53
+ Ruby 2.0.0p353 installed from rubyinstaller.org
44
54
 
45
55
  Ubuntu Linux 11.10
46
56
  QT SDK 4.8.1
@@ -52,7 +62,12 @@ Compiling qtbindings requires the following prerequisites:
52
62
  1. cmake 2.8.x installed and in your path
53
63
  2. QT 4.8.x installed and in your path
54
64
  3. Ruby installed and in your path
55
- 4. gcc 4.x
65
+ 4. gcc 4.x (or clang for OSX 10.9)
66
+ For Windows this means getting MingGW-w64 from http://mingw-w64.sourceforge.net/download.php (Win-builds project)
67
+
68
+ Note for OSX 10.9. The default compiler has changed from gcc to clang. All libraries
69
+ need to be compiled with clang or you will get segfaults. This includes ruby, qt, and qtbindings.
70
+ *** rvm does not compile with clang by default. You must add --with-gcc=clang when installing a version of ruby ***
56
71
 
57
72
  Additionally: all of the operating system prequisites for compiling,
58
73
  window system development, opengl, etc must be installed.
@@ -64,18 +79,20 @@ Perform the following steps to build the gem on Unix or Mac:
64
79
  Where the x is the subversion of QT and y is the patch level of qtbindings
65
80
 
66
81
  Perform the following steps to build the gem on Windows:
67
- 1. Ensure you are running Ruby 1.9.3
68
- ruby -v #=> ruby 1.9.3
82
+ 1. Ensure you are running Ruby 2.0.0
83
+ ruby -v #=> ruby 2.0.0
69
84
  2. rake distclean
70
85
  3. rake build
71
- 4. Switch to Ruby 2.0.0
72
- ruby -v #=> ruby 2.0.0
86
+ 4. Switch to Ruby 2.1.3
87
+ ruby -v #=> ruby 2.1.3
73
88
  5. rake build
74
89
  6. rake VERSION=4.8.x.y gemnative
75
90
  Where the x is the subversion of QT and y is the patch level of qtbindings
91
+ 7. rake VERSION=4.8.x.y gemqt
92
+ Where the x is the subversion of QT and y is the patch level of qtbindings
76
93
 
77
94
  Note: The gem is built twice to create the FAT binary which will work
78
- on both Ruby 1.9 and 2.0. The Windows utility called pik is useful for
95
+ on both Ruby 2.0 and 2.1. The Windows utility called pik is useful for
79
96
  switching between Ruby versions.
80
97
 
81
98
  After building the gem, verify the examples work by running:
@@ -88,7 +105,7 @@ Debian Linux
88
105
  1. The following should get you the packages you need:
89
106
  sudo aptitude install build-essential bison openssl libreadline5
90
107
  libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev vim
91
- libsqlite3-0 libsqlite3-dev sqlite3 libreadline5-dev libreadline6-dev
108
+ libsqlite3-0 libsqlite3-dev sqlite3
92
109
  libxml2-dev git-core subversion autoconf xorg-dev libgl1-mesa-dev
93
110
  libglu1-mesa-dev
94
111
 
@@ -100,7 +117,8 @@ Mac OSX Snow Leopard
100
117
 
101
118
  Windows - Note: Only necessary for debugging (binary gem available)
102
119
  --------
103
- 1. mingw 4.4 in your path (from here or elsewhere: http://nosymbolfound.blogspot.com/2012/12/since-until-now-qt-under-windows-is.html#!/2012/12/since-until-now-qt-under-windows-is.html)
120
+ QT 4.8.6 requires mingw 4.8.2 from http://mingw-w64.sourceforge.net/download.php (Win-builds project)
121
+ QT 4.8.5 requires mingw 4.4 from here or elsewhere: http://nosymbolfound.blogspot.com/2012/12/since-until-now-qt-under-windows-is.html#!/2012/12/since-until-now-qt-under-windows-is.html)
104
122
 
105
123
  Install
106
124
  ------
@@ -121,6 +139,9 @@ License:
121
139
  This library is released under the LGPL Version 2.1.
122
140
  See COPYING.LIB.txt
123
141
 
142
+ Contributing:
143
+ Fork the project and submit pull requests.
144
+
124
145
  Disclaimer:
125
146
  Almost all of this code was written by the guys who worked on the KDE
126
147
  bindings project, particurly Arno Rehn and Richard Dale. I hope to increase
data/Rakefile CHANGED
@@ -6,8 +6,14 @@ windows = true if platform =~ /mswin32/ or platform =~ /mingw32/
6
6
 
7
7
  if windows
8
8
  MAKE = 'mingw32-make'
9
+ SLASH = '\\'
10
+ COPY = 'copy'
11
+ DEL = 'del'
9
12
  else
10
13
  MAKE = 'make'
14
+ SLASH = '/'
15
+ COPY = 'cp'
16
+ DEL = 'rm'
11
17
  end
12
18
 
13
19
  def warn_version
@@ -92,7 +98,9 @@ end
92
98
  task :gemnative do
93
99
  warn_version()
94
100
  set_version()
101
+ system("#{COPY} gemspecs#{SLASH}qtbindingsnative.gemspec .")
95
102
  system("gem build qtbindingsnative.gemspec")
103
+ system("#{DEL} qtbindingsnative.gemspec")
96
104
  clear_version()
97
105
  end
98
106
 
@@ -100,7 +108,9 @@ task :gemqt do
100
108
  warn_version()
101
109
  set_version()
102
110
  system("#{MAKE} installqt")
111
+ system("#{COPY} gemspecs#{SLASH}qtbindings-qt.gemspec .")
103
112
  system("gem build qtbindings-qt.gemspec")
113
+ system("#{DEL} qtbindings-qt.gemspec")
104
114
  clear_version()
105
115
  end
106
116
 
data/bin/rbrcc CHANGED
@@ -10,9 +10,5 @@ windows = true if platform =~ /mswin32/ or platform =~ /mingw32/
10
10
  extension = ''
11
11
  extension = '.exe' if windows
12
12
 
13
- if RUBY_VERSION.split('.')[0].to_i == 1
14
- path = File.expand_path(File.join(File.dirname(__FILE__), '1.9', "rbrcc#{extension}"))
15
- else
16
- path = File.expand_path(File.join(File.dirname(__FILE__), '2.0', "rbrcc#{extension}"))
17
- end
13
+ path = File.expand_path(File.join(File.dirname(__FILE__), RUBY_VERSION.split('.')[0..1].join('.'), "rbrcc#{extension}"))
18
14
  exec(path, *ARGV)
data/bin/rbuic4 CHANGED
@@ -10,9 +10,5 @@ windows = true if platform =~ /mswin32/ or platform =~ /mingw32/
10
10
  extension = ''
11
11
  extension = '.exe' if windows
12
12
 
13
- if RUBY_VERSION.split('.')[0].to_i == 1
14
- path = File.expand_path(File.join(File.dirname(__FILE__), '1.9', "rbuic4#{extension}"))
15
- else
16
- path = File.expand_path(File.join(File.dirname(__FILE__), '2.0', "rbuic4#{extension}"))
17
- end
13
+ path = File.expand_path(File.join(File.dirname(__FILE__), RUBY_VERSION.split('.')[0..1].join('.'), "rbuic4#{extension}"))
18
14
  exec(path, *ARGV)
data/bin/smokeapi CHANGED
@@ -10,9 +10,5 @@ windows = true if platform =~ /mswin32/ or platform =~ /mingw32/
10
10
  extension = ''
11
11
  extension = '.exe' if windows
12
12
 
13
- if RUBY_VERSION.split('.')[0].to_i == 1
14
- path = File.expand_path(File.join(File.dirname(__FILE__), '1.9', "smokeapi#{extension}"))
15
- else
16
- path = File.expand_path(File.join(File.dirname(__FILE__), '2.0', "smokeapi#{extension}"))
17
- end
13
+ path = File.expand_path(File.join(File.dirname(__FILE__), RUBY_VERSION.split('.')[0..1].join('.'), "smokeapi#{extension}"))
18
14
  exec(path, *ARGV)
data/bin/smokedeptool CHANGED
@@ -10,9 +10,5 @@ windows = true if platform =~ /mswin32/ or platform =~ /mingw32/
10
10
  extension = ''
11
11
  extension = '.exe' if windows
12
12
 
13
- if RUBY_VERSION.split('.')[0].to_i == 1
14
- path = File.expand_path(File.join(File.dirname(__FILE__), '1.9', "smokedeptool#{extension}"))
15
- else
16
- path = File.expand_path(File.join(File.dirname(__FILE__), '2.0', "smokedeptool#{extension}"))
17
- end
13
+ path = File.expand_path(File.join(File.dirname(__FILE__), RUBY_VERSION.split('.')[0..1].join('.'), "smokedeptool#{extension}"))
18
14
  exec(path, *ARGV)
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/ruby -W
2
+ require "Qt"
3
+
4
+ app = Qt::Application.new(ARGV)
5
+
6
+ hello = Qt::PushButton.new('Hello World!')
7
+ hello.resize(100, 30)
8
+ hello.show()
9
+
10
+ # This code hangs the application because it is trying to access the GUI
11
+ # (QT code) outside of the main thread
12
+ #Thread.new { sleep 2; hello.resize(200,50) }
13
+
14
+ # This code executes because it puts the GUI code inside
15
+ # Qt.execute_in_main_thread
16
+ Qt.execute_in_main_thread { sleep 2; hello.resize(200,50) }
17
+
18
+ app.exec()
19
+
data/ext/CMakeLists.txt CHANGED
@@ -10,6 +10,9 @@ include(MacroOptionalAddBindings)
10
10
  include(MacroLogFeature)
11
11
  include(CheckCXXSourceCompiles)
12
12
 
13
+ # Call cmake/modules/FindQt4.cmake
14
+ # We are using the version provided by the Github project Kitware/CMake
15
+ # This sets a bunch of QT_XXX variables used throughout the build process
13
16
  FIND_PACKAGE (Qt4 REQUIRED)
14
17
 
15
18
  add_definitions (${QT_DEFINITIONS} -DHAVE_CONFIG_H=1)
@@ -1012,7 +1012,10 @@ IF (QT4_QMAKE_FOUND)
1012
1012
  _QT4_ADJUST_LIB_VARS(QtAssistant)
1013
1013
  _QT4_ADJUST_LIB_VARS(QtAssistantClient)
1014
1014
  _QT4_ADJUST_LIB_VARS(QtCLucene)
1015
- _QT4_ADJUST_LIB_VARS(QtDBus)
1015
+ # QtDBus doesn't work on WIN32
1016
+ IF(NOT WIN32)
1017
+ _QT4_ADJUST_LIB_VARS(QtDBus)
1018
+ ENDIF(NOT WIN32)
1016
1019
  _QT4_ADJUST_LIB_VARS(QtDeclarative)
1017
1020
  _QT4_ADJUST_LIB_VARS(QtDesigner)
1018
1021
  _QT4_ADJUST_LIB_VARS(QtDesignerComponents)
@@ -81,8 +81,14 @@ IF(RUBY_EXECUTABLE AND NOT RUBY_MAJOR_VERSION)
81
81
  EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['rubyhdrdir']"
82
82
  OUTPUT_VARIABLE RUBY_HDR_DIR)
83
83
 
84
+ EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['rubyarchhdrdir']"
85
+ OUTPUT_VARIABLE RUBY_ARCH_HDR_DIR)
86
+
84
87
  EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['libdir']"
85
- OUTPUT_VARIABLE RUBY_POSSIBLE_LIB_DIR)
88
+ OUTPUT_VARIABLE RUBY_LIB_DIR)
89
+
90
+ EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['archlibdir']"
91
+ OUTPUT_VARIABLE RUBY_ARCH_LIB_DIR)
86
92
 
87
93
  EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['rubylibdir']"
88
94
  OUTPUT_VARIABLE RUBY_RUBY_LIB_DIR)
@@ -106,25 +112,33 @@ IF(RUBY_EXECUTABLE AND NOT RUBY_MAJOR_VERSION)
106
112
  OUTPUT_VARIABLE RUBY_VENDORARCH_DIR)
107
113
  ENDIF(RUBY_HAS_VENDOR_RUBY)
108
114
 
115
+ EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['RUBY_SO_NAME']"
116
+ OUTPUT_VARIABLE RUBY_SONAME)
117
+
109
118
  # save the results in the cache so we don't have to run ruby the next time again
110
119
  SET(RUBY_VERSION_MAJOR ${RUBY_VERSION_MAJOR} CACHE PATH "The Ruby major version" FORCE)
111
120
  SET(RUBY_VERSION_MINOR ${RUBY_VERSION_MINOR} CACHE PATH "The Ruby minor version" FORCE)
112
121
  SET(RUBY_VERSION_PATCH ${RUBY_VERSION_PATCH} CACHE PATH "The Ruby patch version" FORCE)
113
122
  SET(RUBY_ARCH_DIR ${RUBY_ARCH_DIR} CACHE PATH "The Ruby arch dir" FORCE)
114
123
  SET(RUBY_HDR_DIR ${RUBY_HDR_DIR} CACHE PATH "The Ruby header dir (1.9)" FORCE)
115
- SET(RUBY_POSSIBLE_LIB_DIR ${RUBY_POSSIBLE_LIB_DIR} CACHE PATH "The Ruby lib dir" FORCE)
124
+ SET(RUBY_ARCH_HDR_DIR ${RUBY_ARCH_HDR_DIR} CACHE PATH "The Ruby header dir for architecture-specific headers" FORCE)
125
+ SET(RUBY_LIB_DIR ${RUBY_LIB_DIR} CACHE PATH "The Ruby base lib dir" FORCE)
126
+ SET(RUBY_ARCH_LIB_DIR ${RUBY_ARCH_LIB_DIR} CACHE PATH "The Ruby architecture-specific lib dir" FORCE)
116
127
  SET(RUBY_RUBY_LIB_DIR ${RUBY_RUBY_LIB_DIR} CACHE PATH "The Ruby ruby-lib dir" FORCE)
117
128
  SET(RUBY_SITEARCH_DIR ${RUBY_SITEARCH_DIR} CACHE PATH "The Ruby site arch dir" FORCE)
118
129
  SET(RUBY_SITELIB_DIR ${RUBY_SITELIB_DIR} CACHE PATH "The Ruby site lib dir" FORCE)
119
130
  SET(RUBY_HAS_VENDOR_RUBY ${RUBY_HAS_VENDOR_RUBY} CACHE BOOL "Vendor Ruby is available" FORCE)
120
131
  SET(RUBY_VENDORARCH_DIR ${RUBY_VENDORARCH_DIR} CACHE PATH "The Ruby vendor arch dir" FORCE)
121
132
  SET(RUBY_VENDORLIB_DIR ${RUBY_VENDORLIB_DIR} CACHE PATH "The Ruby vendor lib dir" FORCE)
133
+ SET(RUBY_SONAME ${RUBY_SONAME} CACHE PATH "The Ruby library's .so name" FORCE)
122
134
 
123
135
  MARK_AS_ADVANCED(
124
136
  RUBY_ARCH_DIR
125
137
  RUBY_ARCH
126
138
  RUBY_HDR_DIR
127
- RUBY_POSSIBLE_LIB_DIR
139
+ RUBY_ARCH_HDR_DIR
140
+ RUBY_LIB_DIR
141
+ RUBY_ARCH_LIB_DIR
128
142
  RUBY_RUBY_LIB_DIR
129
143
  RUBY_SITEARCH_DIR
130
144
  RUBY_SITELIB_DIR
@@ -134,6 +148,7 @@ IF(RUBY_EXECUTABLE AND NOT RUBY_MAJOR_VERSION)
134
148
  RUBY_VERSION_MAJOR
135
149
  RUBY_VERSION_MINOR
136
150
  RUBY_VERSION_PATCH
151
+ RUBY_SONAME
137
152
  )
138
153
  ENDIF(RUBY_EXECUTABLE AND NOT RUBY_MAJOR_VERSION)
139
154
 
@@ -178,6 +193,7 @@ FIND_PATH(RUBY_INCLUDE_DIR
178
193
  HINTS
179
194
  ${RUBY_HDR_DIR}
180
195
  ${RUBY_ARCH_DIR}
196
+ ${RUBY_ARCH_HDR_DIR}
181
197
  /usr/lib/ruby/${_RUBY_VERSION_SHORT}/i586-linux-gnu/ )
182
198
 
183
199
  SET(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIR} )
@@ -188,6 +204,7 @@ IF( ${Ruby_FIND_VERSION_SHORT_NODOT} GREATER 18 OR ${_RUBY_VERSION_SHORT_NODOT
188
204
  FIND_PATH(RUBY_CONFIG_INCLUDE_DIR
189
205
  NAMES ruby/config.h config.h
190
206
  HINTS
207
+ ${RUBY_ARCH_HDR_DIR}
191
208
  ${RUBY_HDR_DIR}/${RUBY_ARCH}
192
209
  ${RUBY_ARCH_DIR}
193
210
  )
@@ -197,7 +214,7 @@ ENDIF( ${Ruby_FIND_VERSION_SHORT_NODOT} GREATER 18 OR ${_RUBY_VERSION_SHORT_NO
197
214
 
198
215
 
199
216
  # Determine the list of possible names for the ruby library
200
- SET(_RUBY_POSSIBLE_LIB_NAMES ruby ruby-static ruby${_RUBY_VERSION_SHORT} ruby${_RUBY_VERSION_SHORT_NODOT} ruby-${RUBY_VERSION})
217
+ SET(_RUBY_POSSIBLE_LIB_NAMES ${RUBY_SONAME} ruby ruby-static ruby${_RUBY_VERSION_SHORT} ruby${_RUBY_VERSION_SHORT_NODOT} ruby-${RUBY_VERSION})
201
218
 
202
219
  IF(WIN32)
203
220
  SET( _RUBY_MSVC_RUNTIME "" )
@@ -226,7 +243,7 @@ IF(WIN32)
226
243
  "msvcrt-ruby${_RUBY_VERSION_LONG_NODOT}-static" )
227
244
  ENDIF(WIN32)
228
245
 
229
- FIND_LIBRARY(RUBY_LIBRARY NAMES ${_RUBY_POSSIBLE_LIB_NAMES} HINTS ${RUBY_POSSIBLE_LIB_DIR} )
246
+ FIND_LIBRARY(RUBY_LIBRARY NAMES ${_RUBY_POSSIBLE_LIB_NAMES} HINTS ${RUBY_ARCH_LIB_DIR} ${RUBY_LIB_DIR})
230
247
 
231
248
  INCLUDE(FindPackageHandleStandardArgs)
232
249
  SET(_RUBY_REQUIRED_VARS RUBY_EXECUTABLE RUBY_INCLUDE_DIR RUBY_LIBRARY)
@@ -259,3 +276,4 @@ MARK_AS_ADVANCED(
259
276
  SET(RUBY_POSSIBLE_LIB_PATH ${RUBY_POSSIBLE_LIB_DIR})
260
277
  SET(RUBY_RUBY_LIB_PATH ${RUBY_RUBY_LIB_DIR})
261
278
  SET(RUBY_INCLUDE_PATH ${RUBY_INCLUDE_DIRS})
279
+
@@ -1,4 +1,4 @@
1
- IF(QT_QTDBUS_FOUND)
1
+ IF(QT_QTDBUS_FOUND AND NOT WIN32)
2
2
  ADD_DEFINITIONS (-DQT_QTDBUS)
3
3
  ENDIF(QT_QTDBUS_FOUND)
4
4
 
@@ -27,7 +27,7 @@ set(qtruby_LIB_SRCS qtruby.cpp)
27
27
  add_library(qtruby4shared SHARED ${qtrubyshared_LIB_SRCS})
28
28
  add_library(qtruby4 MODULE ${qtruby_LIB_SRCS})
29
29
 
30
- if(QT_QTDBUS_FOUND)
30
+ if(QT_QTDBUS_FOUND AND NOT WIN32)
31
31
  target_link_libraries( qtruby4shared
32
32
  ${QT_QTCORE_LIBRARY}
33
33
  ${QT_QTGUI_LIBRARY}
@@ -153,36 +153,36 @@ inspectProperty(QMetaProperty property, const char * name, QVariant & value)
153
153
  {
154
154
  QFont f = value.value<QFont>();
155
155
  return QString( " %1=#<Qt::Font:0x0 family=%2, pointSize=%3, weight=%4, italic=%5, bold=%6, underline=%7, strikeOut=%8>")
156
- .arg(name)
157
- .arg(f.family())
158
- .arg(f.pointSize())
159
- .arg(f.weight())
160
- .arg(f.italic() ? "true" : "false")
161
- .arg(f.bold() ? "true" : "false")
162
- .arg(f.underline() ? "true" : "false")
163
- .arg(f.strikeOut() ? "true" : "false");
156
+ .arg(name)
157
+ .arg(f.family())
158
+ .arg(f.pointSize())
159
+ .arg(f.weight())
160
+ .arg(f.italic() ? "true" : "false")
161
+ .arg(f.bold() ? "true" : "false")
162
+ .arg(f.underline() ? "true" : "false")
163
+ .arg(f.strikeOut() ? "true" : "false");
164
164
  }
165
165
 
166
166
  case QVariant::Line:
167
167
  {
168
168
  QLine l = value.toLine();
169
169
  return QString(" %1=#<Qt::Line:0x0 x1=%2, y1=%3, x2=%4, y2=%5>")
170
- .arg(name)
171
- .arg(l.x1())
172
- .arg(l.y1())
173
- .arg(l.x2())
174
- .arg(l.y2());
170
+ .arg(name)
171
+ .arg(l.x1())
172
+ .arg(l.y1())
173
+ .arg(l.x2())
174
+ .arg(l.y2());
175
175
  }
176
176
 
177
177
  case QVariant::LineF:
178
178
  {
179
179
  QLineF l = value.toLineF();
180
180
  return QString(" %1=#<Qt::LineF:0x0 x1=%2, y1=%3, x2=%4, y2=%5>")
181
- .arg(name)
182
- .arg(l.x1())
183
- .arg(l.y1())
184
- .arg(l.x2())
185
- .arg(l.y2());
181
+ .arg(name)
182
+ .arg(l.x1())
183
+ .arg(l.y1())
184
+ .arg(l.x2())
185
+ .arg(l.y2());
186
186
  }
187
187
 
188
188
  case QVariant::Point:
@@ -201,41 +201,41 @@ inspectProperty(QMetaProperty property, const char * name, QVariant & value)
201
201
  {
202
202
  QRect r = value.toRect();
203
203
  return QString(" %1=#<Qt::Rect:0x0 left=%2, right=%3, top=%4, bottom=%5>")
204
- .arg(name)
205
- .arg(r.left()).arg(r.right()).arg(r.top()).arg(r.bottom());
204
+ .arg(name)
205
+ .arg(r.left()).arg(r.right()).arg(r.top()).arg(r.bottom());
206
206
  }
207
207
 
208
208
  case QVariant::RectF:
209
209
  {
210
210
  QRectF r = value.toRectF();
211
211
  return QString(" %1=#<Qt::RectF:0x0 left=%2, right=%3, top=%4, bottom=%5>")
212
- .arg(name)
213
- .arg(r.left()).arg(r.right()).arg(r.top()).arg(r.bottom());
212
+ .arg(name)
213
+ .arg(r.left()).arg(r.right()).arg(r.top()).arg(r.bottom());
214
214
  }
215
215
 
216
216
  case QVariant::Size:
217
217
  {
218
218
  QSize s = value.toSize();
219
219
  return QString(" %1=#<Qt::Size:0x0 width=%2, height=%3>")
220
- .arg(name)
221
- .arg(s.width()).arg(s.height());
220
+ .arg(name)
221
+ .arg(s.width()).arg(s.height());
222
222
  }
223
223
 
224
224
  case QVariant::SizeF:
225
225
  {
226
226
  QSizeF s = value.toSizeF();
227
227
  return QString(" %1=#<Qt::SizeF:0x0 width=%2, height=%3>")
228
- .arg(name)
229
- .arg(s.width()).arg(s.height());
228
+ .arg(name)
229
+ .arg(s.width()).arg(s.height());
230
230
  }
231
231
 
232
232
  case QVariant::SizePolicy:
233
233
  {
234
234
  QSizePolicy s = value.value<QSizePolicy>();
235
235
  return QString(" %1=#<Qt::SizePolicy:0x0 horizontalPolicy=%2, verticalPolicy=%3>")
236
- .arg(name)
237
- .arg(s.horizontalPolicy())
238
- .arg(s.verticalPolicy());
236
+ .arg(name)
237
+ .arg(s.horizontalPolicy())
238
+ .arg(s.verticalPolicy());
239
239
  }
240
240
 
241
241
  case QVariant::Brush:
@@ -250,7 +250,7 @@ inspectProperty(QMetaProperty property, const char * name, QVariant & value)
250
250
 
251
251
  default:
252
252
  return QString(" %1=%2").arg(name)
253
- .arg((value.isNull() || value.toString().isNull()) ? "nil" : value.toString() );
253
+ .arg((value.isNull() || value.toString().isNull()) ? "nil" : value.toString() );
254
254
  }
255
255
  }
256
256
 
@@ -272,7 +272,7 @@ inspect_qobject(VALUE self)
272
272
  rb_str_resize(inspect_str, RSTRING_LEN(inspect_str) - 1);
273
273
 
274
274
  smokeruby_object * o = 0;
275
- Data_Get_Struct(self, smokeruby_object, o);
275
+ Data_Get_Struct(self, smokeruby_object, o);
276
276
  QObject * qobject = (QObject *) o->smoke->cast(o->ptr, o->classId, o->smoke->idClass("QObject").index);
277
277
 
278
278
  QString value_list;
@@ -281,10 +281,10 @@ inspect_qobject(VALUE self)
281
281
  if (qobject->isWidgetType()) {
282
282
  QWidget * w = (QWidget *) qobject;
283
283
  value_list.append(QString(", x=%1, y=%2, width=%3, height=%4")
284
- .arg(w->x())
285
- .arg(w->y())
286
- .arg(w->width())
287
- .arg(w->height()) );
284
+ .arg(w->x())
285
+ .arg(w->y())
286
+ .arg(w->width())
287
+ .arg(w->height()) );
288
288
  }
289
289
 
290
290
  value_list.append(">");
@@ -317,7 +317,7 @@ pretty_print_qobject(VALUE self, VALUE pp)
317
317
  rb_funcall(pp, rb_intern("breakable"), 0);
318
318
 
319
319
  smokeruby_object * o = 0;
320
- Data_Get_Struct(self, smokeruby_object, o);
320
+ Data_Get_Struct(self, smokeruby_object, o);
321
321
  QObject * qobject = (QObject *) o->smoke->cast(o->ptr, o->classId, o->smoke->idClass("QObject").index);
322
322
 
323
323
  QString value_list;
@@ -336,16 +336,16 @@ pretty_print_qobject(VALUE self, VALUE pp)
336
336
  if (qobject->parent()->isWidgetType()) {
337
337
  QWidget * w = (QWidget *) qobject->parent();
338
338
  value_list = QString(" parent=%1 objectName=\"%2\", x=%3, y=%4, width=%5, height=%6>,\n")
339
- .arg(parentInspectString)
340
- .arg(w->objectName())
341
- .arg(w->x())
342
- .arg(w->y())
343
- .arg(w->width())
344
- .arg(w->height());
339
+ .arg(parentInspectString)
340
+ .arg(w->objectName())
341
+ .arg(w->x())
342
+ .arg(w->y())
343
+ .arg(w->width())
344
+ .arg(w->height());
345
345
  } else {
346
346
  value_list = QString(" parent=%1 objectName=\"%2\">,\n")
347
- .arg(parentInspectString)
348
- .arg(qobject->parent()->objectName());
347
+ .arg(parentInspectString)
348
+ .arg(qobject->parent()->objectName());
349
349
  }
350
350
 
351
351
  rb_funcall(pp, rb_intern("text"), 1, rb_str_new2(value_list.toLatin1()));
@@ -353,7 +353,7 @@ pretty_print_qobject(VALUE self, VALUE pp)
353
353
 
354
354
  if (qobject->children().count() != 0) {
355
355
  value_list = QString(" children=Array (%1 element(s)),\n")
356
- .arg(qobject->children().count());
356
+ .arg(qobject->children().count());
357
357
  rb_funcall(pp, rb_intern("text"), 1, rb_str_new2(value_list.toLatin1()));
358
358
  }
359
359
 
@@ -362,7 +362,7 @@ pretty_print_qobject(VALUE self, VALUE pp)
362
362
 
363
363
  if (qobject->metaObject()->superClass() != 0) {
364
364
  value_list.append( QString(", superClass=#<Qt::MetaObject:0x0 className=%1>")
365
- .arg(qobject->metaObject()->superClass()->className()) );
365
+ .arg(qobject->metaObject()->superClass()->className()) );
366
366
  }
367
367
 
368
368
  value_list.append(">,\n");
@@ -420,7 +420,7 @@ q_unregister_resource_data(VALUE /*self*/, VALUE version, VALUE tree_value, VALU
420
420
  static VALUE
421
421
  qabstract_item_model_rowcount(int argc, VALUE * argv, VALUE self)
422
422
  {
423
- smokeruby_object *o = value_obj_info(self);
423
+ smokeruby_object *o = value_obj_info(self);
424
424
  QAbstractItemModel * model = (QAbstractItemModel *) o->ptr;
425
425
  if (argc == 0) {
426
426
  return INT2NUM(model->rowCount());
@@ -438,7 +438,7 @@ qabstract_item_model_rowcount(int argc, VALUE * argv, VALUE self)
438
438
  static VALUE
439
439
  qabstract_item_model_columncount(int argc, VALUE * argv, VALUE self)
440
440
  {
441
- smokeruby_object *o = value_obj_info(self);
441
+ smokeruby_object *o = value_obj_info(self);
442
442
  QAbstractItemModel * model = (QAbstractItemModel *) o->ptr;
443
443
  if (argc == 0) {
444
444
  return INT2NUM(model->columnCount());
@@ -456,9 +456,9 @@ qabstract_item_model_columncount(int argc, VALUE * argv, VALUE self)
456
456
  static VALUE
457
457
  qabstract_item_model_data(int argc, VALUE * argv, VALUE self)
458
458
  {
459
- smokeruby_object * o = value_obj_info(self);
459
+ smokeruby_object * o = value_obj_info(self);
460
460
  QAbstractItemModel * model = (QAbstractItemModel *) o->ptr;
461
- smokeruby_object * mi = value_obj_info(argv[0]);
461
+ smokeruby_object * mi = value_obj_info(argv[0]);
462
462
  QModelIndex * modelIndex = (QModelIndex *) mi->ptr;
463
463
  QVariant value;
464
464
  if (argc == 1) {
@@ -471,7 +471,7 @@ qabstract_item_model_data(int argc, VALUE * argv, VALUE self)
471
471
 
472
472
 
473
473
  smokeruby_object * result = alloc_smokeruby_object( true,
474
- o->smoke,
474
+ o->smoke,
475
475
  o->smoke->findClass("QVariant").index,
476
476
  new QVariant(value) );
477
477
  return set_obj_info("Qt::Variant", result);
@@ -480,11 +480,11 @@ qabstract_item_model_data(int argc, VALUE * argv, VALUE self)
480
480
  static VALUE
481
481
  qabstract_item_model_setdata(int argc, VALUE * argv, VALUE self)
482
482
  {
483
- smokeruby_object *o = value_obj_info(self);
483
+ smokeruby_object *o = value_obj_info(self);
484
484
  QAbstractItemModel * model = (QAbstractItemModel *) o->ptr;
485
- smokeruby_object * mi = value_obj_info(argv[0]);
485
+ smokeruby_object * mi = value_obj_info(argv[0]);
486
486
  QModelIndex * modelIndex = (QModelIndex *) mi->ptr;
487
- smokeruby_object * v = value_obj_info(argv[1]);
487
+ smokeruby_object * v = value_obj_info(argv[1]);
488
488
  QVariant * variant = (QVariant *) v->ptr;
489
489
 
490
490
  if (argc == 2) {
@@ -493,8 +493,8 @@ qabstract_item_model_setdata(int argc, VALUE * argv, VALUE self)
493
493
 
494
494
  if (argc == 3) {
495
495
  return (model->setData( *modelIndex,
496
- *variant,
497
- NUM2INT(rb_funcall(argv[2], rb_intern("to_i"), 0)) ) ? Qtrue : Qfalse);
496
+ *variant,
497
+ NUM2INT(rb_funcall(argv[2], rb_intern("to_i"), 0)) ) ? Qtrue : Qfalse);
498
498
  }
499
499
 
500
500
  rb_raise(rb_eArgError, "Invalid argument list");
@@ -503,9 +503,9 @@ qabstract_item_model_setdata(int argc, VALUE * argv, VALUE self)
503
503
  static VALUE
504
504
  qabstract_item_model_flags(VALUE self, VALUE model_index)
505
505
  {
506
- smokeruby_object *o = value_obj_info(self);
506
+ smokeruby_object *o = value_obj_info(self);
507
507
  QAbstractItemModel * model = (QAbstractItemModel *) o->ptr;
508
- smokeruby_object * mi = value_obj_info(model_index);
508
+ smokeruby_object * mi = value_obj_info(model_index);
509
509
  const QModelIndex * modelIndex = (const QModelIndex *) mi->ptr;
510
510
  return INT2NUM((int) model->flags(*modelIndex));
511
511
  }
@@ -513,7 +513,7 @@ qabstract_item_model_flags(VALUE self, VALUE model_index)
513
513
  static VALUE
514
514
  qabstract_item_model_insertrows(int argc, VALUE * argv, VALUE self)
515
515
  {
516
- smokeruby_object *o = value_obj_info(self);
516
+ smokeruby_object *o = value_obj_info(self);
517
517
  QAbstractItemModel * model = (QAbstractItemModel *) o->ptr;
518
518
 
519
519
  if (argc == 2) {
@@ -521,7 +521,7 @@ qabstract_item_model_insertrows(int argc, VALUE * argv, VALUE self)
521
521
  }
522
522
 
523
523
  if (argc == 3) {
524
- smokeruby_object * mi = value_obj_info(argv[2]);
524
+ smokeruby_object * mi = value_obj_info(argv[2]);
525
525
  const QModelIndex * modelIndex = (const QModelIndex *) mi->ptr;
526
526
  return (model->insertRows(NUM2INT(argv[0]), NUM2INT(argv[1]), *modelIndex) ? Qtrue : Qfalse);
527
527
  }
@@ -532,7 +532,7 @@ qabstract_item_model_insertrows(int argc, VALUE * argv, VALUE self)
532
532
  static VALUE
533
533
  qabstract_item_model_insertcolumns(int argc, VALUE * argv, VALUE self)
534
534
  {
535
- smokeruby_object *o = value_obj_info(self);
535
+ smokeruby_object *o = value_obj_info(self);
536
536
  QAbstractItemModel * model = (QAbstractItemModel *) o->ptr;
537
537
 
538
538
  if (argc == 2) {
@@ -540,7 +540,7 @@ qabstract_item_model_insertcolumns(int argc, VALUE * argv, VALUE self)
540
540
  }
541
541
 
542
542
  if (argc == 3) {
543
- smokeruby_object * mi = value_obj_info(argv[2]);
543
+ smokeruby_object * mi = value_obj_info(argv[2]);
544
544
  const QModelIndex * modelIndex = (const QModelIndex *) mi->ptr;
545
545
  return (model->insertColumns(NUM2INT(argv[0]), NUM2INT(argv[1]), *modelIndex) ? Qtrue : Qfalse);
546
546
  }
@@ -551,7 +551,7 @@ qabstract_item_model_insertcolumns(int argc, VALUE * argv, VALUE self)
551
551
  static VALUE
552
552
  qabstract_item_model_removerows(int argc, VALUE * argv, VALUE self)
553
553
  {
554
- smokeruby_object *o = value_obj_info(self);
554
+ smokeruby_object *o = value_obj_info(self);
555
555
  QAbstractItemModel * model = (QAbstractItemModel *) o->ptr;
556
556
 
557
557
  if (argc == 2) {
@@ -559,7 +559,7 @@ qabstract_item_model_removerows(int argc, VALUE * argv, VALUE self)
559
559
  }
560
560
 
561
561
  if (argc == 3) {
562
- smokeruby_object * mi = value_obj_info(argv[2]);
562
+ smokeruby_object * mi = value_obj_info(argv[2]);
563
563
  const QModelIndex * modelIndex = (const QModelIndex *) mi->ptr;
564
564
  return (model->removeRows(NUM2INT(argv[0]), NUM2INT(argv[1]), *modelIndex) ? Qtrue : Qfalse);
565
565
  }
@@ -570,7 +570,7 @@ qabstract_item_model_removerows(int argc, VALUE * argv, VALUE self)
570
570
  static VALUE
571
571
  qabstract_item_model_removecolumns(int argc, VALUE * argv, VALUE self)
572
572
  {
573
- smokeruby_object *o = value_obj_info(self);
573
+ smokeruby_object *o = value_obj_info(self);
574
574
  QAbstractItemModel * model = (QAbstractItemModel *) o->ptr;
575
575
 
576
576
  if (argc == 2) {
@@ -578,7 +578,7 @@ qabstract_item_model_removecolumns(int argc, VALUE * argv, VALUE self)
578
578
  }
579
579
 
580
580
  if (argc == 3) {
581
- smokeruby_object * mi = value_obj_info(argv[2]);
581
+ smokeruby_object * mi = value_obj_info(argv[2]);
582
582
  const QModelIndex * modelIndex = (const QModelIndex *) mi->ptr;
583
583
  return (model->removeRows(NUM2INT(argv[0]), NUM2INT(argv[1]), *modelIndex) ? Qtrue : Qfalse);
584
584
  }
@@ -592,7 +592,7 @@ qabstract_item_model_removecolumns(int argc, VALUE * argv, VALUE self)
592
592
  static VALUE
593
593
  qbytearray_append(VALUE self, VALUE str)
594
594
  {
595
- smokeruby_object *o = value_obj_info(self);
595
+ smokeruby_object *o = value_obj_info(self);
596
596
  QByteArray * bytes = (QByteArray *) o->ptr;
597
597
  (*bytes) += (const char *) StringValuePtr(str);
598
598
  return self;
@@ -601,34 +601,34 @@ qbytearray_append(VALUE self, VALUE str)
601
601
  static VALUE
602
602
  qbytearray_data(VALUE self)
603
603
  {
604
- smokeruby_object *o = value_obj_info(self);
605
- QByteArray * bytes = (QByteArray *) o->ptr;
606
- return rb_str_new(bytes->data(), bytes->size());
604
+ smokeruby_object *o = value_obj_info(self);
605
+ QByteArray * bytes = (QByteArray *) o->ptr;
606
+ return rb_str_new(bytes->data(), bytes->size());
607
607
  }
608
608
 
609
609
  static VALUE
610
610
  qimage_bits(VALUE self)
611
611
  {
612
- smokeruby_object *o = value_obj_info(self);
613
- QImage * image = static_cast<QImage *>(o->ptr);
614
- const uchar * bytes = image->bits();
615
- return rb_str_new((const char *) bytes, image->numBytes());
612
+ smokeruby_object *o = value_obj_info(self);
613
+ QImage * image = static_cast<QImage *>(o->ptr);
614
+ const uchar * bytes = image->bits();
615
+ return rb_str_new((const char *) bytes, image->numBytes());
616
616
  }
617
617
 
618
618
  static VALUE
619
619
  qimage_scan_line(VALUE self, VALUE ix)
620
620
  {
621
- smokeruby_object *o = value_obj_info(self);
622
- QImage * image = static_cast<QImage *>(o->ptr);
623
- const uchar * bytes = image->scanLine(NUM2INT(ix));
624
- return rb_str_new((const char *) bytes, image->bytesPerLine());
621
+ smokeruby_object *o = value_obj_info(self);
622
+ QImage * image = static_cast<QImage *>(o->ptr);
623
+ const uchar * bytes = image->scanLine(NUM2INT(ix));
624
+ return rb_str_new((const char *) bytes, image->bytesPerLine());
625
625
  }
626
626
 
627
627
  #ifdef QT_QTDBUS
628
628
  static VALUE
629
629
  qdbusargument_endarraywrite(VALUE self)
630
630
  {
631
- smokeruby_object *o = value_obj_info(self);
631
+ smokeruby_object *o = value_obj_info(self);
632
632
  QDBusArgument * arg = (QDBusArgument *) o->ptr;
633
633
  arg->endArray();
634
634
  return self;
@@ -637,7 +637,7 @@ qdbusargument_endarraywrite(VALUE self)
637
637
  static VALUE
638
638
  qdbusargument_endmapwrite(VALUE self)
639
639
  {
640
- smokeruby_object *o = value_obj_info(self);
640
+ smokeruby_object *o = value_obj_info(self);
641
641
  QDBusArgument * arg = (QDBusArgument *) o->ptr;
642
642
  arg->endMap();
643
643
  return self;
@@ -646,7 +646,7 @@ qdbusargument_endmapwrite(VALUE self)
646
646
  static VALUE
647
647
  qdbusargument_endmapentrywrite(VALUE self)
648
648
  {
649
- smokeruby_object *o = value_obj_info(self);
649
+ smokeruby_object *o = value_obj_info(self);
650
650
  QDBusArgument * arg = (QDBusArgument *) o->ptr;
651
651
  arg->endMapEntry();
652
652
  return self;
@@ -655,7 +655,7 @@ qdbusargument_endmapentrywrite(VALUE self)
655
655
  static VALUE
656
656
  qdbusargument_endstructurewrite(VALUE self)
657
657
  {
658
- smokeruby_object *o = value_obj_info(self);
658
+ smokeruby_object *o = value_obj_info(self);
659
659
  QDBusArgument * arg = (QDBusArgument *) o->ptr;
660
660
  arg->endStructure();
661
661
  return self;
@@ -784,7 +784,7 @@ qabstractitemmodel_createindex(int argc, VALUE * argv, VALUE self)
784
784
  if ( qstrcmp( o->smoke->types[o->smoke->argumentList[o->smoke->methods[o->smoke->ambiguousMethodList[i]].args + 2]].name,
785
785
  "void*" ) == 0 )
786
786
  {
787
- const Smoke::Method &m = o->smoke->methods[o->smoke->ambiguousMethodList[i]];
787
+ const Smoke::Method &m = o->smoke->methods[o->smoke->ambiguousMethodList[i]];
788
788
  Smoke::ClassFn fn = o->smoke->classes[m.classId].classFn;
789
789
  Smoke::StackItem stack[4];
790
790
  stack[1].s_int = NUM2INT(argv[0]);
@@ -810,10 +810,77 @@ qabstractitemmodel_createindex(int argc, VALUE * argv, VALUE self)
810
810
  return rb_call_super(argc, argv);
811
811
  }
812
812
 
813
+ #if QT_VERSION >= 0x040600
814
+ // copy the role names defined on the model instance into a ruby hash and return it
815
+ static VALUE
816
+ qabstractitemmodel_rolenames(int argc, VALUE * argv, VALUE self)
817
+ {
818
+ smokeruby_object *o = value_obj_info(self);
819
+ if( !o->ptr )
820
+ {
821
+ // not ok
822
+ rb_raise(rb_eArgError, "NULL given, expected subclass of QAbstractItemModel");
823
+ }
824
+
825
+ QAbstractItemModel* model = (QAbstractItemModel*) o->ptr;
826
+
827
+ // convert QHash<int,QByteArray> to a ruby hash
828
+ VALUE result = rb_hash_new();
829
+ QHash<int, QByteArray>::const_iterator i;
830
+ for( i = model->roleNames().constBegin(); i != model->roleNames().constEnd(); i++)
831
+ {
832
+ rb_hash_aset(result,
833
+ INT2NUM(i.key()),
834
+ rb_str_new2(i.value().data()));
835
+ }
836
+
837
+ return result;
838
+ }
839
+
840
+ // let C++ call a protected member function from outside
841
+ // NOTE: a little hacky, but setRoleNames is deprecated in Qt 5.0, anyway...
842
+ struct SetRoleNamesExposer : QAbstractItemModel {
843
+ using QAbstractItemModel::setRoleNames;
844
+ };
845
+
846
+ // set the role names on the given model instance from the given hash
847
+ static VALUE
848
+ qabstractitemmodel_setrolenames(int argc, VALUE * argv, VALUE self)
849
+ {
850
+ if( argc != 1 || TYPE(argv[0]) != T_HASH )
851
+ {
852
+ rb_raise(rb_eArgError, "Invalid arguments");
853
+ }
854
+
855
+ // convert the ruby hash to a QHash<int,QByteArray>
856
+ QHash<int,QByteArray> rnames;
857
+ VALUE tmp = rb_funcall(argv[0], rb_intern("to_a"), 0);
858
+ for( long i=0; i<RARRAY_LEN(tmp); i++)
859
+ {
860
+ VALUE key = rb_ary_entry(rb_ary_entry(tmp, i), 0);
861
+ VALUE val = rb_ary_entry(rb_ary_entry(tmp, i), 1);
862
+ rnames[NUM2INT(key)] = QByteArray(StringValuePtr(val));
863
+ }
864
+
865
+ smokeruby_object *o = value_obj_info(self);
866
+ if( !o->ptr )
867
+ {
868
+ // not ok
869
+ rb_raise(rb_eArgError, "NULL given, expected subclass of QAbstractItemModel");
870
+ }
871
+
872
+ QAbstractItemModel* model = (QAbstractItemModel*) o->ptr;
873
+ (model->*&SetRoleNamesExposer::setRoleNames)(rnames); // just a little hacky, since
874
+ // 'setRoleNames' is protected
875
+
876
+ return Qnil;
877
+ }
878
+ #endif
879
+
813
880
  static VALUE
814
881
  qmodelindex_internalpointer(VALUE self)
815
882
  {
816
- smokeruby_object *o = value_obj_info(self);
883
+ smokeruby_object *o = value_obj_info(self);
817
884
  QModelIndex * index = (QModelIndex *) o->ptr;
818
885
  void * ptr = index->internalPointer();
819
886
  return ptr != 0 ? (VALUE) ptr : Qnil;
@@ -822,7 +889,7 @@ qmodelindex_internalpointer(VALUE self)
822
889
  static VALUE
823
890
  qitemselection_at(VALUE self, VALUE i)
824
891
  {
825
- smokeruby_object *o = value_obj_info(self);
892
+ smokeruby_object *o = value_obj_info(self);
826
893
  QItemSelection * item = (QItemSelection *) o->ptr;
827
894
  QItemSelectionRange range = item->at(NUM2INT(i));
828
895
 
@@ -837,7 +904,7 @@ qitemselection_at(VALUE self, VALUE i)
837
904
  static VALUE
838
905
  qitemselection_count(VALUE self)
839
906
  {
840
- smokeruby_object *o = value_obj_info(self);
907
+ smokeruby_object *o = value_obj_info(self);
841
908
  QItemSelection * item = (QItemSelection *) o->ptr;
842
909
  return INT2NUM(item->count());
843
910
  }
@@ -845,8 +912,8 @@ qitemselection_count(VALUE self)
845
912
  static VALUE
846
913
  metaObject(VALUE self)
847
914
  {
848
- VALUE metaObject = rb_funcall(qt_internal_module, rb_intern("getMetaObject"), 2, Qnil, self);
849
- return metaObject;
915
+ VALUE metaObject = rb_funcall(qt_internal_module, rb_intern("getMetaObject"), 2, Qnil, self);
916
+ return metaObject;
850
917
  }
851
918
 
852
919
  /* This shouldn't be needed, but kalyptus doesn't generate a staticMetaObject
@@ -860,9 +927,9 @@ qobject_staticmetaobject(VALUE /*klass*/)
860
927
  QMetaObject * meta = new QMetaObject(QObject::staticMetaObject);
861
928
 
862
929
  smokeruby_object * m = alloc_smokeruby_object( true,
863
- qtcore_Smoke,
864
- qtcore_Smoke->idClass("QMetaObject").index,
865
- meta );
930
+ qtcore_Smoke,
931
+ qtcore_Smoke->idClass("QMetaObject").index,
932
+ meta );
866
933
 
867
934
  VALUE obj = set_obj_info("Qt::MetaObject", m);
868
935
  return obj;
@@ -871,29 +938,29 @@ qobject_staticmetaobject(VALUE /*klass*/)
871
938
  static VALUE
872
939
  cast_object_to(VALUE /*self*/, VALUE object, VALUE new_klass)
873
940
  {
874
- smokeruby_object *o = value_obj_info(object);
941
+ smokeruby_object *o = value_obj_info(object);
875
942
 
876
943
  VALUE new_klassname = rb_funcall(new_klass, rb_intern("name"), 0);
877
944
 
878
- Smoke::ModuleIndex * cast_to_id = classcache.value(StringValuePtr(new_klassname));
945
+ Smoke::ModuleIndex * cast_to_id = classcache.value(StringValuePtr(new_klassname));
879
946
  if (cast_to_id == 0) {
880
947
  rb_raise(rb_eArgError, "unable to find class \"%s\" to cast to\n", StringValuePtr(new_klassname));
881
948
  }
882
949
 
883
- smokeruby_object * o_cast = alloc_smokeruby_object( o->allocated,
884
- cast_to_id->smoke,
885
- (int) cast_to_id->index,
886
- o->smoke->cast(o->ptr, o->classId, (int) cast_to_id->index) );
950
+ smokeruby_object * o_cast = alloc_smokeruby_object(o->allocated,
951
+ cast_to_id->smoke,
952
+ (int) cast_to_id->index,
953
+ o->smoke->cast(o->ptr, o->classId, (int) cast_to_id->index) );
887
954
 
888
- VALUE obj = Data_Wrap_Struct(new_klass, smokeruby_mark, smokeruby_free, (void *) o_cast);
889
- mapPointer(obj, o_cast, o_cast->classId, 0);
890
- return obj;
955
+ VALUE obj = Data_Wrap_Struct(new_klass, smokeruby_mark, smokeruby_free, (void *) o_cast);
956
+ mapPointer(obj, o_cast, o_cast->classId, 0);
957
+ return obj;
891
958
  }
892
959
 
893
960
  static VALUE
894
961
  qobject_qt_metacast(VALUE self, VALUE klass)
895
962
  {
896
- smokeruby_object *o = value_obj_info(self);
963
+ smokeruby_object *o = value_obj_info(self);
897
964
  if (o == 0 || o->ptr == 0) {
898
965
  return Qnil;
899
966
  }
@@ -916,13 +983,13 @@ qobject_qt_metacast(VALUE self, VALUE klass)
916
983
  }
917
984
 
918
985
  smokeruby_object * o_cast = alloc_smokeruby_object( o->allocated,
919
- mi->smoke,
920
- (int) mi->index,
921
- ret );
986
+ mi->smoke,
987
+ (int) mi->index,
988
+ ret );
922
989
 
923
- VALUE obj = Data_Wrap_Struct(klass, smokeruby_mark, smokeruby_free, (void *) o_cast);
924
- mapPointer(obj, o_cast, o_cast->classId, 0);
925
- return obj;
990
+ VALUE obj = Data_Wrap_Struct(klass, smokeruby_mark, smokeruby_free, (void *) o_cast);
991
+ mapPointer(obj, o_cast, o_cast->classId, 0);
992
+ return obj;
926
993
  }
927
994
 
928
995
  static VALUE
@@ -939,13 +1006,11 @@ qsignalmapper_mapping(int argc, VALUE * argv, VALUE self)
939
1006
  Smoke::Index i = meth.smoke->methodMaps[meth.index].method;
940
1007
  i = -i; // turn into ambiguousMethodList index
941
1008
  while (meth.smoke->ambiguousMethodList[i] != 0) {
942
- if ( ( qstrcmp( meth.smoke->types[meth.smoke->argumentList[meth.smoke->methods[meth.smoke->ambiguousMethodList[i]].args]].name,
943
- "QObject*" ) == 0
944
- && Smoke::isDerivedFrom(a->smoke->classes[a->classId].className, "QObject")
945
- && !Smoke::isDerivedFrom(a->smoke->classes[a->classId].className, "QWidget") )
946
- || ( qstrcmp( meth.smoke->types[meth.smoke->argumentList[meth.smoke->methods[meth.smoke->ambiguousMethodList[i]].args]].name,
947
- "QWidget*" ) == 0
948
- && Smoke::isDerivedFrom(a->smoke->classes[a->classId].className, "QWidget") ) )
1009
+ if ((qstrcmp(meth.smoke->types[meth.smoke->argumentList[meth.smoke->methods[meth.smoke->ambiguousMethodList[i]].args]].name, "QObject*" ) == 0
1010
+ && Smoke::isDerivedFrom(a->smoke->classes[a->classId].className, "QObject")
1011
+ && !Smoke::isDerivedFrom(a->smoke->classes[a->classId].className, "QWidget") )
1012
+ || (qstrcmp(meth.smoke->types[meth.smoke->argumentList[meth.smoke->methods[meth.smoke->ambiguousMethodList[i]].args]].name, "QWidget*" ) == 0
1013
+ && Smoke::isDerivedFrom(a->smoke->classes[a->classId].className, "QWidget") ) )
949
1014
  {
950
1015
  _current_method.smoke = meth.smoke;
951
1016
  _current_method.index = meth.smoke->ambiguousMethodList[i];
@@ -975,13 +1040,11 @@ qsignalmapper_set_mapping(int argc, VALUE * argv, VALUE self)
975
1040
  Smoke::Index i = meth.smoke->methodMaps[meth.index].method;
976
1041
  i = -i; // turn into ambiguousMethodList index
977
1042
  while (meth.smoke->ambiguousMethodList[i] != 0) {
978
- if ( ( qstrcmp( meth.smoke->types[meth.smoke->argumentList[meth.smoke->methods[meth.smoke->ambiguousMethodList[i]].args + 1]].name,
979
- "QObject*" ) == 0
980
- && Smoke::isDerivedFrom(a->smoke->classes[a->classId].className, "QObject")
981
- && !Smoke::isDerivedFrom(a->smoke->classes[a->classId].className, "QWidget") )
982
- || ( qstrcmp( meth.smoke->types[meth.smoke->argumentList[meth.smoke->methods[meth.smoke->ambiguousMethodList[i]].args + 1]].name,
983
- "QWidget*" ) == 0
984
- && Smoke::isDerivedFrom(a->smoke->classes[a->classId].className, "QWidget") ) )
1043
+ if ((qstrcmp(meth.smoke->types[meth.smoke->argumentList[meth.smoke->methods[meth.smoke->ambiguousMethodList[i]].args + 1]].name, "QObject*" ) == 0
1044
+ && Smoke::isDerivedFrom(a->smoke->classes[a->classId].className, "QObject")
1045
+ && !Smoke::isDerivedFrom(a->smoke->classes[a->classId].className, "QWidget") )
1046
+ || (qstrcmp(meth.smoke->types[meth.smoke->argumentList[meth.smoke->methods[meth.smoke->ambiguousMethodList[i]].args + 1]].name, "QWidget*" ) == 0
1047
+ && Smoke::isDerivedFrom(a->smoke->classes[a->classId].className, "QWidget") ) )
985
1048
  {
986
1049
  _current_method.smoke = meth.smoke;
987
1050
  _current_method.index = meth.smoke->ambiguousMethodList[i];
@@ -1027,7 +1090,7 @@ qvariant_value(VALUE /*self*/, VALUE variant_value_klass, VALUE variant_value)
1027
1090
  VALUE result = Qnil;
1028
1091
  smokeruby_object * vo = 0;
1029
1092
 
1030
- smokeruby_object *o = value_obj_info(variant_value);
1093
+ smokeruby_object *o = value_obj_info(variant_value);
1031
1094
  if (o == 0 || o->ptr == 0) {
1032
1095
  return Qnil;
1033
1096
  }
@@ -1057,7 +1120,7 @@ qvariant_value(VALUE /*self*/, VALUE variant_value_klass, VALUE variant_value)
1057
1120
  }
1058
1121
 
1059
1122
  const char * classname = rb_class2name(variant_value_klass);
1060
- Smoke::ModuleIndex * value_class_id = classcache.value(classname);
1123
+ Smoke::ModuleIndex * value_class_id = classcache.value(classname);
1061
1124
  if (value_class_id == 0) {
1062
1125
  return Qnil;
1063
1126
  }
@@ -1153,8 +1216,7 @@ qvariant_from_value(int argc, VALUE * argv, VALUE self)
1153
1216
  Smoke::Index i = meth.smoke->methodMaps[meth.index].method;
1154
1217
  i = -i; // turn into ambiguousMethodList index
1155
1218
  while (meth.smoke->ambiguousMethodList[i] != 0) {
1156
- if ( qstrcmp( meth.smoke->types[meth.smoke->argumentList[meth.smoke->methods[meth.smoke->ambiguousMethodList[i]].args]].name,
1157
- typeName ) == 0 )
1219
+ if (qstrcmp(meth.smoke->types[meth.smoke->argumentList[meth.smoke->methods[meth.smoke->ambiguousMethodList[i]].args]].name, typeName ) == 0 )
1158
1220
  {
1159
1221
  _current_method.smoke = meth.smoke;
1160
1222
  _current_method.index = meth.smoke->ambiguousMethodList[i];
@@ -1172,7 +1234,7 @@ qvariant_from_value(int argc, VALUE * argv, VALUE self)
1172
1234
  QVariant * v = 0;
1173
1235
 
1174
1236
  const char * classname = rb_obj_classname(argv[0]);
1175
- smokeruby_object *o = value_obj_info(argv[0]);
1237
+ smokeruby_object *o = value_obj_info(argv[0]);
1176
1238
  int type = 0;
1177
1239
 
1178
1240
  if (qstrcmp(classname, "Qt::Enum") == 0) {
@@ -1186,7 +1248,7 @@ qvariant_from_value(int argc, VALUE * argv, VALUE self)
1186
1248
  return result;
1187
1249
  } else {
1188
1250
  VALUE lasterr = rb_gv_get("$!");
1189
- VALUE klass = rb_class_path(CLASS_OF(lasterr));
1251
+ VALUE klass = rb_class_name(CLASS_OF(lasterr));
1190
1252
  if (qstrcmp(StringValuePtr(klass), "ArgumentError") == 0) {
1191
1253
  // ArgumentError - no suitable constructor found
1192
1254
  // Create a QVariant that contains an rObject
@@ -1232,7 +1294,7 @@ static Smoke::Index new_qvariant_qmap = 0;
1232
1294
  _current_method.index = new_qvariant_qmap;
1233
1295
  QtRuby::MethodCall c(qtcore_Smoke, _current_method.index, self, argv, argc-1);
1234
1296
  c.next();
1235
- return *(c.var());
1297
+ return *(c.var());
1236
1298
  } else if ( argc == 1
1237
1299
  && TYPE(argv[0]) == T_ARRAY
1238
1300
  && RARRAY_LEN(argv[0]) > 0
@@ -1250,7 +1312,7 @@ static Smoke::Index new_qvariant_qmap = 0;
1250
1312
 
1251
1313
  static VALUE module_method_missing(int argc, VALUE * argv, VALUE klass)
1252
1314
  {
1253
- return class_method_missing(argc, argv, klass);
1315
+ return class_method_missing(argc, argv, klass);
1254
1316
  }
1255
1317
 
1256
1318
  /*
@@ -1288,7 +1350,6 @@ initialize_qt(int argc, VALUE * argv, VALUE self)
1288
1350
  if (rb_block_given_p()) {
1289
1351
  rb_funcall(qt_internal_module, rb_intern("run_initializer_block"), 2, self, rb_block_proc());
1290
1352
  }
1291
-
1292
1353
  return self;
1293
1354
  }
1294
1355
 
@@ -1335,9 +1396,9 @@ initialize_qt(int argc, VALUE * argv, VALUE self)
1335
1396
  Data_Get_Struct(temp_obj, smokeruby_object, p);
1336
1397
 
1337
1398
  smokeruby_object * o = alloc_smokeruby_object( true,
1338
- p->smoke,
1339
- p->classId,
1340
- p->ptr );
1399
+ p->smoke,
1400
+ p->classId,
1401
+ p->ptr );
1341
1402
  p->ptr = 0;
1342
1403
  p->allocated = false;
1343
1404
 
@@ -1352,7 +1413,7 @@ initialize_qt(int argc, VALUE * argv, VALUE self)
1352
1413
  VALUE
1353
1414
  new_qt(int argc, VALUE * argv, VALUE klass)
1354
1415
  {
1355
- VALUE * temp_stack = ALLOCA_N(VALUE, argc + 1);
1416
+ VALUE * temp_stack = ALLOCA_N(VALUE, argc + 1);
1356
1417
  temp_stack[0] = rb_obj_alloc(klass);
1357
1418
 
1358
1419
  for (int count = 0; count < argc; count++) {
@@ -1387,7 +1448,7 @@ qt_signal(int argc, VALUE * argv, VALUE self)
1387
1448
  {
1388
1449
  smokeruby_object *o = value_obj_info(self);
1389
1450
  QObject *qobj = (QObject*)o->smoke->cast(o->ptr, o->classId, o->smoke->idClass("QObject").index);
1390
- if (qobj->signalsBlocked()) {
1451
+ if (qobj->signalsBlocked()) {
1391
1452
  return Qfalse;
1392
1453
  }
1393
1454
 
@@ -1406,9 +1467,9 @@ qt_signal(int argc, VALUE * argv, VALUE self)
1406
1467
  return Qnil;
1407
1468
  }
1408
1469
 
1409
- int i = -1;
1470
+ int i = -1;
1410
1471
  const QMetaObject * m = (QMetaObject*) ometa->ptr;
1411
- for (i = m->methodCount() - 1; i > -1; i--) {
1472
+ for (i = m->methodCount() - 1; i > -1; i--) {
1412
1473
  if (m->method(i).methodType() == QMetaMethod::Signal) {
1413
1474
  QString name(m->method(i).signature());
1414
1475
  static QRegExp * rx = 0;
@@ -1421,7 +1482,7 @@ static QRegExp * rx = 0;
1421
1482
  break;
1422
1483
  }
1423
1484
  }
1424
- }
1485
+ }
1425
1486
 
1426
1487
  if (i == -1) {
1427
1488
  return Qnil;
@@ -1474,7 +1535,7 @@ qt_metacall(int /*argc*/, VALUE * argv, VALUE self)
1474
1535
  o->smoke->classes[o->classId].className );
1475
1536
  }
1476
1537
 
1477
- if (_c != QMetaObject::InvokeMetaMethod) {
1538
+ if (_c != QMetaObject::InvokeMetaMethod) {
1478
1539
  return argv[1];
1479
1540
  }
1480
1541
 
@@ -1501,7 +1562,7 @@ qt_metacall(int /*argc*/, VALUE * argv, VALUE self)
1501
1562
  QList<MocArgument*> mocArgs = get_moc_arguments(o->smoke, method.typeName(), method.parameterTypes());
1502
1563
 
1503
1564
  QString name(method.signature());
1504
- static QRegExp * rx = 0;
1565
+ static QRegExp * rx = 0;
1505
1566
  if (rx == 0) {
1506
1567
  rx = new QRegExp("\\(.*");
1507
1568
  }
@@ -1555,38 +1616,38 @@ qtimer_single_shot(int argc, VALUE * argv, VALUE /*self*/)
1555
1616
  static VALUE
1556
1617
  getMethStat(VALUE /*self*/)
1557
1618
  {
1558
- VALUE result_list = rb_ary_new();
1559
- rb_ary_push(result_list, INT2NUM((int)methcache.size()));
1560
- rb_ary_push(result_list, INT2NUM((int)methcache.count()));
1561
- return result_list;
1619
+ VALUE result_list = rb_ary_new();
1620
+ rb_ary_push(result_list, INT2NUM((int)methcache.size()));
1621
+ rb_ary_push(result_list, INT2NUM((int)methcache.count()));
1622
+ return result_list;
1562
1623
  }
1563
1624
 
1564
1625
  static VALUE
1565
1626
  getClassStat(VALUE /*self*/)
1566
1627
  {
1567
- VALUE result_list = rb_ary_new();
1568
- rb_ary_push(result_list, INT2NUM((int)classcache.size()));
1569
- rb_ary_push(result_list, INT2NUM((int)classcache.count()));
1570
- return result_list;
1628
+ VALUE result_list = rb_ary_new();
1629
+ rb_ary_push(result_list, INT2NUM((int)classcache.size()));
1630
+ rb_ary_push(result_list, INT2NUM((int)classcache.count()));
1631
+ return result_list;
1571
1632
  }
1572
1633
 
1573
1634
  static VALUE
1574
1635
  getIsa(VALUE /*self*/, VALUE classId)
1575
1636
  {
1576
- VALUE parents_list = rb_ary_new();
1637
+ VALUE parents_list = rb_ary_new();
1577
1638
 
1578
- int id = NUM2INT(rb_funcall(classId, rb_intern("index"), 0));
1579
- Smoke* smoke = smokeList[NUM2INT(rb_funcall(classId, rb_intern("smoke"), 0))];
1639
+ int id = NUM2INT(rb_funcall(classId, rb_intern("index"), 0));
1640
+ Smoke* smoke = smokeList[NUM2INT(rb_funcall(classId, rb_intern("smoke"), 0))];
1580
1641
 
1581
- Smoke::Index *parents =
1642
+ Smoke::Index *parents =
1582
1643
  smoke->inheritanceList +
1583
1644
  smoke->classes[id].parents;
1584
1645
 
1585
- while(*parents) {
1646
+ while(*parents) {
1586
1647
  //logger("\tparent: %s", qtcore_Smoke->classes[*parents].className);
1587
1648
  rb_ary_push(parents_list, rb_str_new2(smoke->classes[*parents++].className));
1588
- }
1589
- return parents_list;
1649
+ }
1650
+ return parents_list;
1590
1651
  }
1591
1652
 
1592
1653
  // Return the class name of a QObject. Note that the name will be in the
@@ -1594,8 +1655,8 @@ getIsa(VALUE /*self*/, VALUE classId)
1594
1655
  static VALUE
1595
1656
  class_name(VALUE self)
1596
1657
  {
1597
- VALUE klass = rb_funcall(self, rb_intern("class"), 0);
1598
- return rb_funcall(klass, rb_intern("name"), 0);
1658
+ VALUE klass = rb_funcall(self, rb_intern("class"), 0);
1659
+ return rb_funcall(klass, rb_intern("name"), 0);
1599
1660
  }
1600
1661
 
1601
1662
  // Allow classnames in both 'Qt::Widget' and 'QWidget' formats to be
@@ -1620,37 +1681,37 @@ inherits_qobject(int argc, VALUE * argv, VALUE /*self*/)
1620
1681
  /* Adapted from the internal function qt_qFindChildren() in qobject.cpp */
1621
1682
  static void
1622
1683
  rb_qFindChildren_helper(VALUE parent, const QString &name, VALUE re,
1623
- const QMetaObject &mo, VALUE list)
1684
+ const QMetaObject &mo, VALUE list)
1624
1685
  {
1625
- if (parent == Qnil || list == Qnil)
1626
- return;
1686
+ if (parent == Qnil || list == Qnil)
1687
+ return;
1627
1688
  VALUE children = rb_funcall(parent, rb_intern("children"), 0);
1628
- VALUE rv = Qnil;
1629
- for (int i = 0; i < RARRAY_LEN(children); ++i) {
1630
- rv = RARRAY_PTR(children)[i];
1689
+ VALUE rv = Qnil;
1690
+ for (int i = 0; i < RARRAY_LEN(children); ++i) {
1691
+ rv = RARRAY_PTR(children)[i];
1631
1692
  smokeruby_object *o = value_obj_info(rv);
1632
1693
  QObject * obj = (QObject *) o->smoke->cast(o->ptr, o->classId, o->smoke->idClass("QObject").index);
1633
1694
 
1634
1695
  // The original code had 'if (mo.cast(obj))' as a test, but it doesn't work here
1635
- if (obj->qt_metacast(mo.className()) != 0) {
1636
- if (re != Qnil) {
1696
+ if (obj->qt_metacast(mo.className()) != 0) {
1697
+ if (re != Qnil) {
1637
1698
  VALUE re_test = rb_funcall(re, rb_intern("=~"), 1, rb_funcall(rv, rb_intern("objectName"), 0));
1638
1699
  if (re_test != Qnil && re_test != Qfalse) {
1639
1700
  rb_ary_push(list, rv);
1640
1701
  }
1641
- } else {
1642
- if (name.isNull() || obj->objectName() == name) {
1702
+ } else {
1703
+ if (name.isNull() || obj->objectName() == name) {
1643
1704
  rb_ary_push(list, rv);
1644
1705
  }
1645
- }
1646
- }
1647
- rb_qFindChildren_helper(rv, name, re, mo, list);
1648
- }
1706
+ }
1707
+ }
1708
+ rb_qFindChildren_helper(rv, name, re, mo, list);
1709
+ }
1649
1710
  return;
1650
1711
  }
1651
1712
 
1652
1713
  /* Should mimic Qt4's QObject::findChildren method with this syntax:
1653
- obj.findChildren(Qt::Widget, "Optional Widget Name")
1714
+ obj.findChildren(Qt::Widget, "Optional Widget Name")
1654
1715
  */
1655
1716
  static VALUE
1656
1717
  find_qobject_children(int argc, VALUE *argv, VALUE self)
@@ -1681,24 +1742,24 @@ find_qobject_children(int argc, VALUE *argv, VALUE self)
1681
1742
  static VALUE
1682
1743
  rb_qFindChild_helper(VALUE parent, const QString &name, const QMetaObject &mo)
1683
1744
  {
1684
- if (parent == Qnil)
1685
- return Qnil;
1745
+ if (parent == Qnil)
1746
+ return Qnil;
1686
1747
  VALUE children = rb_funcall(parent, rb_intern("children"), 0);
1687
- VALUE rv;
1748
+ VALUE rv;
1688
1749
  int i;
1689
- for (i = 0; i < RARRAY_LEN(children); ++i) {
1690
- rv = RARRAY_PTR(children)[i];
1750
+ for (i = 0; i < RARRAY_LEN(children); ++i) {
1751
+ rv = RARRAY_PTR(children)[i];
1691
1752
  smokeruby_object *o = value_obj_info(rv);
1692
1753
  QObject * obj = (QObject *) o->smoke->cast(o->ptr, o->classId, o->smoke->idClass("QObject").index);
1693
- if (obj->qt_metacast(mo.className()) != 0 && (name.isNull() || obj->objectName() == name))
1694
- return rv;
1695
- }
1696
- for (i = 0; i < RARRAY_LEN(children); ++i) {
1697
- rv = rb_qFindChild_helper(RARRAY_PTR(children)[i], name, mo);
1698
- if (rv != Qnil)
1699
- return rv;
1700
- }
1701
- return Qnil;
1754
+ if (obj->qt_metacast(mo.className()) != 0 && (name.isNull() || obj->objectName() == name))
1755
+ return rv;
1756
+ }
1757
+ for (i = 0; i < RARRAY_LEN(children); ++i) {
1758
+ rv = rb_qFindChild_helper(RARRAY_PTR(children)[i], name, mo);
1759
+ if (rv != Qnil)
1760
+ return rv;
1761
+ }
1762
+ return Qnil;
1702
1763
  }
1703
1764
 
1704
1765
  static VALUE
@@ -1721,50 +1782,50 @@ find_qobject_child(int argc, VALUE *argv, VALUE self)
1721
1782
  static VALUE
1722
1783
  setDebug(VALUE self, VALUE on_value)
1723
1784
  {
1724
- int on = NUM2INT(on_value);
1725
- do_debug = on;
1726
- return self;
1785
+ int on = NUM2INT(on_value);
1786
+ do_debug = on;
1787
+ return self;
1727
1788
  }
1728
1789
 
1729
1790
  static VALUE
1730
1791
  debugging(VALUE /*self*/)
1731
1792
  {
1732
- return INT2NUM(do_debug);
1793
+ return INT2NUM(do_debug);
1733
1794
  }
1734
1795
 
1735
1796
  static VALUE
1736
1797
  get_arg_type_name(VALUE /*self*/, VALUE method_value, VALUE idx_value)
1737
1798
  {
1738
- int method = NUM2INT(rb_funcall(method_value, rb_intern("index"), 0));
1739
- int smokeIndex = NUM2INT(rb_funcall(method_value, rb_intern("smoke"), 0));
1740
- Smoke * smoke = smokeList[smokeIndex];
1741
- int idx = NUM2INT(idx_value);
1742
- const Smoke::Method &m = smoke->methods[method];
1743
- Smoke::Index *args = smoke->argumentList + m.args;
1744
- return rb_str_new2((char*)smoke->types[args[idx]].name);
1799
+ int method = NUM2INT(rb_funcall(method_value, rb_intern("index"), 0));
1800
+ int smokeIndex = NUM2INT(rb_funcall(method_value, rb_intern("smoke"), 0));
1801
+ Smoke * smoke = smokeList[smokeIndex];
1802
+ int idx = NUM2INT(idx_value);
1803
+ const Smoke::Method &m = smoke->methods[method];
1804
+ Smoke::Index *args = smoke->argumentList + m.args;
1805
+ return rb_str_new2((char*)smoke->types[args[idx]].name);
1745
1806
  }
1746
1807
 
1747
1808
  static VALUE
1748
1809
  classIsa(VALUE /*self*/, VALUE className_value, VALUE base_value)
1749
1810
  {
1750
- char *className = StringValuePtr(className_value);
1751
- char *base = StringValuePtr(base_value);
1752
- return Smoke::isDerivedFrom(className, base) ? Qtrue : Qfalse;
1811
+ char *className = StringValuePtr(className_value);
1812
+ char *base = StringValuePtr(base_value);
1813
+ return Smoke::isDerivedFrom(className, base) ? Qtrue : Qfalse;
1753
1814
  }
1754
1815
 
1755
1816
  static VALUE
1756
1817
  isEnum(VALUE /*self*/, VALUE enumName_value)
1757
1818
  {
1758
- char *enumName = StringValuePtr(enumName_value);
1759
- Smoke::Index typeId = 0;
1760
- Smoke* s = 0;
1761
- for (int i = 0; i < smokeList.count(); i++) {
1762
- typeId = smokeList[i]->idType(enumName);
1763
- if (typeId > 0) {
1764
- s = smokeList[i];
1765
- break;
1766
- }
1767
- }
1819
+ char *enumName = StringValuePtr(enumName_value);
1820
+ Smoke::Index typeId = 0;
1821
+ Smoke* s = 0;
1822
+ for (int i = 0; i < smokeList.count(); i++) {
1823
+ typeId = smokeList[i]->idType(enumName);
1824
+ if (typeId > 0) {
1825
+ s = smokeList[i];
1826
+ break;
1827
+ }
1828
+ }
1768
1829
  return typeId > 0
1769
1830
  && ( (s->types[typeId].flags & Smoke::tf_elem) == Smoke::t_enum
1770
1831
  || (s->types[typeId].flags & Smoke::tf_elem) == Smoke::t_ulong
@@ -1776,44 +1837,44 @@ isEnum(VALUE /*self*/, VALUE enumName_value)
1776
1837
  static VALUE
1777
1838
  insert_pclassid(VALUE self, VALUE p_value, VALUE mi_value)
1778
1839
  {
1779
- char *p = StringValuePtr(p_value);
1780
- int ix = NUM2INT(rb_funcall(mi_value, rb_intern("index"), 0));
1781
- int smokeidx = NUM2INT(rb_funcall(mi_value, rb_intern("smoke"), 0));
1782
- Smoke::ModuleIndex mi(smokeList[smokeidx], ix);
1783
- classcache.insert(QByteArray(p), new Smoke::ModuleIndex(mi));
1784
- IdToClassNameMap.insert(mi, new QByteArray(p));
1785
- return self;
1840
+ char *p = StringValuePtr(p_value);
1841
+ int ix = NUM2INT(rb_funcall(mi_value, rb_intern("index"), 0));
1842
+ int smokeidx = NUM2INT(rb_funcall(mi_value, rb_intern("smoke"), 0));
1843
+ Smoke::ModuleIndex mi(smokeList[smokeidx], ix);
1844
+ classcache.insert(QByteArray(p), new Smoke::ModuleIndex(mi));
1845
+ IdToClassNameMap.insert(mi, new QByteArray(p));
1846
+ return self;
1786
1847
  }
1787
1848
 
1788
1849
  static VALUE
1789
1850
  classid2name(VALUE /*self*/, VALUE mi_value)
1790
1851
  {
1791
- int ix = NUM2INT(rb_funcall(mi_value, rb_intern("index"), 0));
1792
- int smokeidx = NUM2INT(rb_funcall(mi_value, rb_intern("smoke"), 0));
1793
- Smoke::ModuleIndex mi(smokeList[smokeidx], ix);
1794
- return rb_str_new2(IdToClassNameMap[mi]->constData());
1852
+ int ix = NUM2INT(rb_funcall(mi_value, rb_intern("index"), 0));
1853
+ int smokeidx = NUM2INT(rb_funcall(mi_value, rb_intern("smoke"), 0));
1854
+ Smoke::ModuleIndex mi(smokeList[smokeidx], ix);
1855
+ return rb_str_new2(IdToClassNameMap[mi]->constData());
1795
1856
  }
1796
1857
 
1797
1858
  static VALUE
1798
1859
  find_pclassid(VALUE /*self*/, VALUE p_value)
1799
1860
  {
1800
- if (NIL_P(p_value)) {
1801
- return rb_funcall(moduleindex_class, rb_intern("new"), 2, 0, 0);
1802
- }
1861
+ if (NIL_P(p_value)) {
1862
+ return rb_funcall(moduleindex_class, rb_intern("new"), 2, 0, 0);
1863
+ }
1803
1864
 
1804
- char *p = StringValuePtr(p_value);
1805
- Smoke::ModuleIndex *r = classcache.value(QByteArray(p));
1806
- if (r != 0) {
1807
- return rb_funcall(moduleindex_class, rb_intern("new"), 2, INT2NUM(smokeList.indexOf(r->smoke)), INT2NUM(r->index));
1808
- } else {
1809
- return rb_funcall(moduleindex_class, rb_intern("new"), 2, Qnil, Qnil);
1810
- }
1865
+ char *p = StringValuePtr(p_value);
1866
+ Smoke::ModuleIndex *r = classcache.value(QByteArray(p));
1867
+ if (r != 0) {
1868
+ return rb_funcall(moduleindex_class, rb_intern("new"), 2, INT2NUM(smokeList.indexOf(r->smoke)), INT2NUM(r->index));
1869
+ } else {
1870
+ return rb_funcall(moduleindex_class, rb_intern("new"), 2, Qnil, Qnil);
1871
+ }
1811
1872
  }
1812
1873
 
1813
1874
  static VALUE
1814
1875
  get_value_type(VALUE /*self*/, VALUE ruby_value)
1815
1876
  {
1816
- return rb_str_new2(value_to_type_flag(ruby_value));
1877
+ return rb_str_new2(value_to_type_flag(ruby_value));
1817
1878
  }
1818
1879
 
1819
1880
  static QMetaObject*
@@ -1874,12 +1935,12 @@ make_metaObject(VALUE /*self*/, VALUE obj, VALUE parentMeta, VALUE stringdata_va
1874
1935
 
1875
1936
  printf(
1876
1937
  " // content:\n"
1877
- " %d, // revision\n"
1878
- " %d, // classname\n"
1879
- " %d, %d, // classinfo\n"
1880
- " %d, %d, // methods\n"
1881
- " %d, %d, // properties\n"
1882
- " %d, %d, // enums/sets\n",
1938
+ " %d, // revision\n"
1939
+ " %d, // classname\n"
1940
+ " %d, %d, // classinfo\n"
1941
+ " %d, %d, // methods\n"
1942
+ " %d, %d, // properties\n"
1943
+ " %d, %d, // enums/sets\n",
1883
1944
  data[0], data[1], data[2], data[3],
1884
1945
  data[4], data[5], data[6], data[7], data[8], data[9]);
1885
1946
 
@@ -1888,7 +1949,7 @@ make_metaObject(VALUE /*self*/, VALUE obj, VALUE parentMeta, VALUE stringdata_va
1888
1949
  if (data[2] > 0) {
1889
1950
  printf("\n // classinfo: key, value\n");
1890
1951
  for (uint j = 0; j < data[2]; j++) {
1891
- printf(" %d, %d\n", data[s + (j * 2)], data[s + (j * 2) + 1]);
1952
+ printf(" %d, %d\n", data[s + (j * 2)], data[s + (j * 2) + 1]);
1892
1953
  }
1893
1954
  }
1894
1955
 
@@ -1907,7 +1968,7 @@ make_metaObject(VALUE /*self*/, VALUE obj, VALUE parentMeta, VALUE stringdata_va
1907
1968
  slot_headings = false;
1908
1969
  }
1909
1970
 
1910
- printf(" %d, %d, %d, %d, 0x%2.2x\n",
1971
+ printf(" %d, %d, %d, %d, 0x%2.2x\n",
1911
1972
  data[s + (j * 5)], data[s + (j * 5) + 1], data[s + (j * 5) + 2],
1912
1973
  data[s + (j * 5) + 3], data[s + (j * 5) + 4]);
1913
1974
  }
@@ -1915,24 +1976,24 @@ make_metaObject(VALUE /*self*/, VALUE obj, VALUE parentMeta, VALUE stringdata_va
1915
1976
  s += (data[4] * 5);
1916
1977
  for (uint j = 0; j < data[6]; j++) {
1917
1978
  printf("\n // properties: name, type, flags\n");
1918
- printf(" %d, %d, 0x%8.8x\n",
1979
+ printf(" %d, %d, 0x%8.8x\n",
1919
1980
  data[s + (j * 3)], data[s + (j * 3) + 1], data[s + (j * 3) + 2]);
1920
1981
  }
1921
1982
 
1922
1983
  s += (data[6] * 3);
1923
1984
  for (int i = s; i < count; i++) {
1924
- printf("\n %d // eod\n", data[i]);
1985
+ printf("\n %d // eod\n", data[i]);
1925
1986
  }
1926
1987
 
1927
- printf("\nqt_meta_stringdata:\n \"");
1988
+ printf("\nqt_meta_stringdata:\n \"");
1928
1989
 
1929
- int strlength = 0;
1990
+ int strlength = 0;
1930
1991
  for (int j = 0; j < RSTRING_LEN(stringdata_value); j++) {
1931
- strlength++;
1992
+ strlength++;
1932
1993
  if (meta->d.stringdata[j] == 0) {
1933
1994
  printf("\\0");
1934
1995
  if (strlength > 40) {
1935
- printf("\"\n \"");
1996
+ printf("\"\n \"");
1936
1997
  strlength = 0;
1937
1998
  }
1938
1999
  } else {
@@ -1943,11 +2004,11 @@ make_metaObject(VALUE /*self*/, VALUE obj, VALUE parentMeta, VALUE stringdata_va
1943
2004
 
1944
2005
  #endif
1945
2006
  smokeruby_object * m = alloc_smokeruby_object( true,
1946
- qtcore_Smoke,
1947
- qtcore_Smoke->idClass("QMetaObject").index,
1948
- meta );
2007
+ qtcore_Smoke,
2008
+ qtcore_Smoke->idClass("QMetaObject").index,
2009
+ meta );
1949
2010
 
1950
- return Data_Wrap_Struct(qmetaobject_class, smokeruby_mark, smokeruby_free, m);
2011
+ return Data_Wrap_Struct(qmetaobject_class, smokeruby_mark, smokeruby_free, m);
1951
2012
  }
1952
2013
 
1953
2014
  static VALUE
@@ -1971,10 +2032,10 @@ add_signal_methods(VALUE self, VALUE klass, VALUE signalNames)
1971
2032
  static VALUE
1972
2033
  dispose(VALUE self)
1973
2034
  {
1974
- smokeruby_object *o = value_obj_info(self);
1975
- if (o == 0 || o->ptr == 0) { return Qnil; }
2035
+ smokeruby_object *o = value_obj_info(self);
2036
+ if (o == 0 || o->ptr == 0) { return Qnil; }
1976
2037
 
1977
- const char *className = o->smoke->classes[o->classId].className;
2038
+ const char *className = o->smoke->classes[o->classId].className;
1978
2039
  if(do_debug & qtdb_gc) printf("Deleting (%s*)%p\n", className, o->ptr);
1979
2040
 
1980
2041
  unmapPointer(o, o->classId, 0);
@@ -2009,60 +2070,60 @@ is_disposed(VALUE self)
2009
2070
  VALUE
2010
2071
  isQObject(VALUE /*self*/, VALUE c)
2011
2072
  {
2012
- return Smoke::isDerivedFrom(StringValuePtr(c), "QObject");
2073
+ return Smoke::isDerivedFrom(StringValuePtr(c), "QObject");
2013
2074
  }
2014
2075
 
2015
2076
  // Returns the Smoke classId of a ruby instance
2016
2077
  static VALUE
2017
2078
  idInstance(VALUE /*self*/, VALUE instance)
2018
2079
  {
2019
- smokeruby_object *o = value_obj_info(instance);
2020
- if(!o)
2021
- return Qnil;
2080
+ smokeruby_object *o = value_obj_info(instance);
2081
+ if(!o)
2082
+ return Qnil;
2022
2083
 
2023
- return rb_funcall(moduleindex_class, rb_intern("new"), 2, INT2NUM(smokeList.indexOf(o->smoke)), INT2NUM(o->classId));
2084
+ return rb_funcall(moduleindex_class, rb_intern("new"), 2, INT2NUM(smokeList.indexOf(o->smoke)), INT2NUM(o->classId));
2024
2085
  }
2025
2086
 
2026
2087
  static VALUE
2027
2088
  findClass(VALUE /*self*/, VALUE name_value)
2028
2089
  {
2029
- char *name = StringValuePtr(name_value);
2030
- Smoke::ModuleIndex mi = Smoke::findClass(name);
2031
- return rb_funcall(moduleindex_class, rb_intern("new"), 2, INT2NUM(smokeList.indexOf(mi.smoke)), INT2NUM(mi.index));
2090
+ char *name = StringValuePtr(name_value);
2091
+ Smoke::ModuleIndex mi = Smoke::findClass(name);
2092
+ return rb_funcall(moduleindex_class, rb_intern("new"), 2, INT2NUM(smokeList.indexOf(mi.smoke)), INT2NUM(mi.index));
2032
2093
  }
2033
2094
 
2034
2095
  // static VALUE
2035
2096
  // idMethodName(VALUE /*self*/, VALUE name_value)
2036
2097
  // {
2037
- // char *name = StringValuePtr(name_value);
2038
- // return INT2NUM(qtcore_Smoke->idMethodName(name).index);
2098
+ // char *name = StringValuePtr(name_value);
2099
+ // return INT2NUM(qtcore_Smoke->idMethodName(name).index);
2039
2100
  // }
2040
2101
  //
2041
2102
  // static VALUE
2042
2103
  // idMethod(VALUE /*self*/, VALUE idclass_value, VALUE idmethodname_value)
2043
2104
  // {
2044
- // int idclass = NUM2INT(idclass_value);
2045
- // int idmethodname = NUM2INT(idmethodname_value);
2046
- // return INT2NUM(qtcore_Smoke->idMethod(idclass, idmethodname).index);
2105
+ // int idclass = NUM2INT(idclass_value);
2106
+ // int idmethodname = NUM2INT(idmethodname_value);
2107
+ // return INT2NUM(qtcore_Smoke->idMethod(idclass, idmethodname).index);
2047
2108
  // }
2048
2109
 
2049
2110
  static VALUE
2050
2111
  dumpCandidates(VALUE /*self*/, VALUE rmeths)
2051
2112
  {
2052
- VALUE errmsg = rb_str_new2("");
2053
- if(rmeths != Qnil) {
2113
+ VALUE errmsg = rb_str_new2("");
2114
+ if(rmeths != Qnil) {
2054
2115
  int count = RARRAY_LEN(rmeths);
2055
- for(int i = 0; i < count; i++) {
2056
- rb_str_catf(errmsg, "\t");
2057
- int id = NUM2INT(rb_funcall(rb_ary_entry(rmeths, i), rb_intern("index"), 0));
2058
- Smoke* smoke = smokeList[NUM2INT(rb_funcall(rb_ary_entry(rmeths, i), rb_intern("smoke"), 0))];
2059
- const Smoke::Method &meth = smoke->methods[id];
2060
- const char *tname = smoke->types[meth.ret].name;
2061
- if(meth.flags & Smoke::mf_enum) {
2116
+ for(int i = 0; i < count; i++) {
2117
+ rb_str_catf(errmsg, "\t");
2118
+ int id = NUM2INT(rb_funcall(rb_ary_entry(rmeths, i), rb_intern("index"), 0));
2119
+ Smoke* smoke = smokeList[NUM2INT(rb_funcall(rb_ary_entry(rmeths, i), rb_intern("smoke"), 0))];
2120
+ const Smoke::Method &meth = smoke->methods[id];
2121
+ const char *tname = smoke->types[meth.ret].name;
2122
+ if(meth.flags & Smoke::mf_enum) {
2062
2123
  rb_str_catf(errmsg, "enum ");
2063
2124
  rb_str_catf(errmsg, "%s::%s", smoke->classes[meth.classId].className, smoke->methodNames[meth.name]);
2064
2125
  rb_str_catf(errmsg, "\n");
2065
- } else {
2126
+ } else {
2066
2127
  if(meth.flags & Smoke::mf_static) rb_str_catf(errmsg, "static ");
2067
2128
  rb_str_catf(errmsg, "%s ", (tname ? tname:"void"));
2068
2129
  rb_str_catf(errmsg, "%s::%s(", smoke->classes[meth.classId].className, smoke->methodNames[meth.name]);
@@ -2074,10 +2135,10 @@ dumpCandidates(VALUE /*self*/, VALUE rmeths)
2074
2135
  rb_str_catf(errmsg, ")");
2075
2136
  if(meth.flags & Smoke::mf_const) rb_str_catf(errmsg, " const");
2076
2137
  rb_str_catf(errmsg, "\n");
2077
- }
2078
- }
2079
- }
2080
- return errmsg;
2138
+ }
2139
+ }
2140
+ }
2141
+ return errmsg;
2081
2142
  }
2082
2143
 
2083
2144
  static VALUE
@@ -2092,70 +2153,70 @@ isConstMethod(VALUE /*self*/, VALUE idx)
2092
2153
  static VALUE
2093
2154
  isObject(VALUE /*self*/, VALUE obj)
2094
2155
  {
2095
- void * ptr = 0;
2096
- ptr = value_to_ptr(obj);
2097
- return (ptr > 0 ? Qtrue : Qfalse);
2156
+ void * ptr = 0;
2157
+ ptr = value_to_ptr(obj);
2158
+ return (ptr > 0 ? Qtrue : Qfalse);
2098
2159
  }
2099
2160
 
2100
2161
  static VALUE
2101
2162
  setCurrentMethod(VALUE self, VALUE meth_value)
2102
2163
  {
2103
- int smokeidx = NUM2INT(rb_funcall(meth_value, rb_intern("smoke"), 0));
2104
- int meth = NUM2INT(rb_funcall(meth_value, rb_intern("index"), 0));
2105
- // FIXME: damn, this is lame, and it doesn't handle ambiguous methods
2106
- _current_method.smoke = smokeList[smokeidx]; //qtcore_Smoke->methodMaps[meth].method;
2107
- _current_method.index = meth;
2108
- return self;
2164
+ int smokeidx = NUM2INT(rb_funcall(meth_value, rb_intern("smoke"), 0));
2165
+ int meth = NUM2INT(rb_funcall(meth_value, rb_intern("index"), 0));
2166
+ // FIXME: damn, this is lame, and it doesn't handle ambiguous methods
2167
+ _current_method.smoke = smokeList[smokeidx]; //qtcore_Smoke->methodMaps[meth].method;
2168
+ _current_method.index = meth;
2169
+ return self;
2109
2170
  }
2110
2171
 
2111
2172
  static VALUE
2112
2173
  getClassList(VALUE /*self*/)
2113
2174
  {
2114
- VALUE class_list = rb_ary_new();
2175
+ VALUE class_list = rb_ary_new();
2115
2176
 
2116
- for (int i = 1; i <= qtcore_Smoke->numClasses; i++) {
2117
- if (qtcore_Smoke->classes[i].className && !qtcore_Smoke->classes[i].external)
2118
- rb_ary_push(class_list, rb_str_new2(qtcore_Smoke->classes[i].className));
2119
- }
2177
+ for (int i = 1; i <= qtcore_Smoke->numClasses; i++) {
2178
+ if (qtcore_Smoke->classes[i].className && !qtcore_Smoke->classes[i].external)
2179
+ rb_ary_push(class_list, rb_str_new2(qtcore_Smoke->classes[i].className));
2180
+ }
2120
2181
 
2121
- for (int i = 1; i <= qtgui_Smoke->numClasses; i++) {
2122
- if (qtgui_Smoke->classes[i].className && !qtgui_Smoke->classes[i].external)
2123
- rb_ary_push(class_list, rb_str_new2(qtgui_Smoke->classes[i].className));
2124
- }
2182
+ for (int i = 1; i <= qtgui_Smoke->numClasses; i++) {
2183
+ if (qtgui_Smoke->classes[i].className && !qtgui_Smoke->classes[i].external)
2184
+ rb_ary_push(class_list, rb_str_new2(qtgui_Smoke->classes[i].className));
2185
+ }
2125
2186
 
2126
- for (int i = 1; i <= qtxml_Smoke->numClasses; i++) {
2127
- if (qtxml_Smoke->classes[i].className && !qtxml_Smoke->classes[i].external)
2128
- rb_ary_push(class_list, rb_str_new2(qtxml_Smoke->classes[i].className));
2129
- }
2187
+ for (int i = 1; i <= qtxml_Smoke->numClasses; i++) {
2188
+ if (qtxml_Smoke->classes[i].className && !qtxml_Smoke->classes[i].external)
2189
+ rb_ary_push(class_list, rb_str_new2(qtxml_Smoke->classes[i].className));
2190
+ }
2130
2191
 
2131
- for (int i = 1; i <= qtsql_Smoke->numClasses; i++) {
2132
- if (qtsql_Smoke->classes[i].className && !qtsql_Smoke->classes[i].external)
2133
- rb_ary_push(class_list, rb_str_new2(qtsql_Smoke->classes[i].className));
2134
- }
2192
+ for (int i = 1; i <= qtsql_Smoke->numClasses; i++) {
2193
+ if (qtsql_Smoke->classes[i].className && !qtsql_Smoke->classes[i].external)
2194
+ rb_ary_push(class_list, rb_str_new2(qtsql_Smoke->classes[i].className));
2195
+ }
2135
2196
 
2136
- for (int i = 1; i <= qtopengl_Smoke->numClasses; i++) {
2137
- if (qtopengl_Smoke->classes[i].className && !qtopengl_Smoke->classes[i].external)
2138
- rb_ary_push(class_list, rb_str_new2(qtopengl_Smoke->classes[i].className));
2139
- }
2197
+ for (int i = 1; i <= qtopengl_Smoke->numClasses; i++) {
2198
+ if (qtopengl_Smoke->classes[i].className && !qtopengl_Smoke->classes[i].external)
2199
+ rb_ary_push(class_list, rb_str_new2(qtopengl_Smoke->classes[i].className));
2200
+ }
2140
2201
 
2141
- for (int i = 1; i <= qtnetwork_Smoke->numClasses; i++) {
2142
- if (qtnetwork_Smoke->classes[i].className && !qtnetwork_Smoke->classes[i].external)
2143
- rb_ary_push(class_list, rb_str_new2(qtnetwork_Smoke->classes[i].className));
2144
- }
2202
+ for (int i = 1; i <= qtnetwork_Smoke->numClasses; i++) {
2203
+ if (qtnetwork_Smoke->classes[i].className && !qtnetwork_Smoke->classes[i].external)
2204
+ rb_ary_push(class_list, rb_str_new2(qtnetwork_Smoke->classes[i].className));
2205
+ }
2145
2206
 
2146
- for (int i = 1; i <= qtsvg_Smoke->numClasses; i++) {
2147
- if (qtsvg_Smoke->classes[i].className && !qtsvg_Smoke->classes[i].external)
2148
- rb_ary_push(class_list, rb_str_new2(qtsvg_Smoke->classes[i].className));
2149
- }
2207
+ for (int i = 1; i <= qtsvg_Smoke->numClasses; i++) {
2208
+ if (qtsvg_Smoke->classes[i].className && !qtsvg_Smoke->classes[i].external)
2209
+ rb_ary_push(class_list, rb_str_new2(qtsvg_Smoke->classes[i].className));
2210
+ }
2150
2211
 
2151
2212
  #ifdef QT_QTDBUS
2152
- for (int i = 1; i <= qtdbus_Smoke->numClasses; i++) {
2153
- if (qtdbus_Smoke->classes[i].className && !qtdbus_Smoke->classes[i].external)
2154
- rb_ary_push(class_list, rb_str_new2(qtdbus_Smoke->classes[i].className));
2155
- }
2213
+ for (int i = 1; i <= qtdbus_Smoke->numClasses; i++) {
2214
+ if (qtdbus_Smoke->classes[i].className && !qtdbus_Smoke->classes[i].external)
2215
+ rb_ary_push(class_list, rb_str_new2(qtdbus_Smoke->classes[i].className));
2216
+ }
2156
2217
  #endif
2157
2218
 
2158
- return class_list;
2219
+ return class_list;
2159
2220
  }
2160
2221
 
2161
2222
  static VALUE
@@ -2215,6 +2276,13 @@ create_qobject_class(VALUE /*self*/, VALUE package_value, VALUE module_value)
2215
2276
  rb_define_method(qlistmodel_class, "remove_rows", (VALUE (*) (...)) qabstract_item_model_removerows, -1);
2216
2277
  rb_define_method(qlistmodel_class, "removeColumns", (VALUE (*) (...)) qabstract_item_model_removecolumns, -1);
2217
2278
  rb_define_method(qlistmodel_class, "remove_columns", (VALUE (*) (...)) qabstract_item_model_removecolumns, -1);
2279
+ #if QT_VERSION >= 0x040600
2280
+ // make it work with qml
2281
+ rb_define_method(qlistmodel_class, "roleNames", (VALUE (*) (...)) qabstractitemmodel_rolenames, -1);
2282
+ rb_define_method(qlistmodel_class, "role_names", (VALUE (*) (...)) qabstractitemmodel_rolenames, -1);
2283
+ rb_define_method(qlistmodel_class, "setRoleNames", (VALUE (*) (...)) qabstractitemmodel_setrolenames, -1);
2284
+ rb_define_method(qlistmodel_class, "set_role_names", (VALUE (*) (...)) qabstractitemmodel_setrolenames, -1);
2285
+ #endif
2218
2286
  }
2219
2287
  else if (packageName == "Qt::AbstractItemModel") {
2220
2288
  rb_define_method(klass, "createIndex", (VALUE (*) (...)) qabstractitemmodel_createindex, -1);
@@ -2260,8 +2328,8 @@ create_qt_class(VALUE /*self*/, VALUE package_value, VALUE module_value)
2260
2328
  QString packageName(package);
2261
2329
 
2262
2330
  /*
2263
- rb_define_singleton_method(module_value, "method_missing", (VALUE (*) (...)) module_method_missing, -1);
2264
- rb_define_singleton_method(module_value, "const_missing", (VALUE (*) (...)) module_method_missing, -1);
2331
+ rb_define_singleton_method(module_value, "method_missing", (VALUE (*) (...)) module_method_missing, -1);
2332
+ rb_define_singleton_method(module_value, "const_missing", (VALUE (*) (...)) module_method_missing, -1);
2265
2333
  */
2266
2334
  foreach(QString s, packageName.mid(strlen(moduleName) + 2).split("::")) {
2267
2335
  klass = rb_define_class_under(klass, (const char*) s.toLatin1(), qt_base_class);
@@ -2273,12 +2341,12 @@ create_qt_class(VALUE /*self*/, VALUE package_value, VALUE module_value)
2273
2341
  qvariant_class = klass;
2274
2342
  rb_define_singleton_method(qvariant_class, "fromValue", (VALUE (*) (...)) qvariant_from_value, -1);
2275
2343
  rb_define_singleton_method(qvariant_class, "from_value", (VALUE (*) (...)) qvariant_from_value, -1);
2276
- rb_define_singleton_method(qvariant_class, "new", (VALUE (*) (...)) new_qvariant, -1);
2344
+ rb_define_singleton_method(qvariant_class, "new", (VALUE (*) (...)) new_qvariant, -1);
2277
2345
  } else if (packageName == "Qt::ByteArray") {
2278
2346
  rb_define_method(klass, "+", (VALUE (*) (...)) qbytearray_append, 1);
2279
- rb_define_method(klass, "data", (VALUE (*) (...)) qbytearray_data, 0);
2280
- rb_define_method(klass, "constData", (VALUE (*) (...)) qbytearray_data, 0);
2281
- rb_define_method(klass, "const_data", (VALUE (*) (...)) qbytearray_data, 0);
2347
+ rb_define_method(klass, "data", (VALUE (*) (...)) qbytearray_data, 0);
2348
+ rb_define_method(klass, "constData", (VALUE (*) (...)) qbytearray_data, 0);
2349
+ rb_define_method(klass, "const_data", (VALUE (*) (...)) qbytearray_data, 0);
2282
2350
  } else if (packageName == "Qt::Char") {
2283
2351
  rb_define_method(klass, "to_s", (VALUE (*) (...)) qchar_to_s, 0);
2284
2352
  } else if (packageName == "Qt::Image") {
@@ -2326,19 +2394,19 @@ create_qt_class(VALUE /*self*/, VALUE package_value, VALUE module_value)
2326
2394
  static VALUE
2327
2395
  version(VALUE /*self*/)
2328
2396
  {
2329
- return rb_str_new2(QT_VERSION_STR);
2397
+ return rb_str_new2(QT_VERSION_STR);
2330
2398
  }
2331
2399
 
2332
2400
  static VALUE
2333
2401
  qtruby_version(VALUE /*self*/)
2334
2402
  {
2335
- return rb_str_new2(QTRUBY_VERSION);
2403
+ return rb_str_new2(QTRUBY_VERSION);
2336
2404
  }
2337
2405
 
2338
2406
  static VALUE
2339
2407
  set_application_terminated(VALUE /*self*/, VALUE yn)
2340
2408
  {
2341
- application_terminated = (yn == Qtrue ? true : false);
2409
+ application_terminated = (yn == Qtrue ? true : false);
2342
2410
  return Qnil;
2343
2411
  }
2344
2412
 
@@ -2350,35 +2418,35 @@ set_qtruby_embedded_wrapped(VALUE /*self*/, VALUE yn)
2350
2418
  }
2351
2419
 
2352
2420
  #define INIT_BINDING(module) \
2353
- static QtRuby::Binding module##_binding = QtRuby::Binding(module##_Smoke); \
2354
- QtRubyModule module = { "QtRuby_" #module, resolve_classname_qt, 0, &module##_binding }; \
2355
- qtruby_modules[module##_Smoke] = module; \
2421
+ static QtRuby::Binding module##_binding = QtRuby::Binding(module##_Smoke); \
2422
+ QtRubyModule module = { "QtRuby_" #module, resolve_classname_qt, 0, &module##_binding }; \
2423
+ qtruby_modules[module##_Smoke] = module; \
2356
2424
  smokeList << module##_Smoke;
2357
2425
 
2358
2426
  extern Q_DECL_EXPORT void
2359
2427
  Init_qtruby4()
2360
2428
  {
2361
- init_qtcore_Smoke();
2362
- init_qtgui_Smoke();
2363
- init_qtxml_Smoke();
2364
- init_qtsql_Smoke();
2365
- init_qtopengl_Smoke();
2366
- init_qtnetwork_Smoke();
2367
- init_qtsvg_Smoke();
2429
+ init_qtcore_Smoke();
2430
+ init_qtgui_Smoke();
2431
+ init_qtxml_Smoke();
2432
+ init_qtsql_Smoke();
2433
+ init_qtopengl_Smoke();
2434
+ init_qtnetwork_Smoke();
2435
+ init_qtsvg_Smoke();
2368
2436
  #ifdef QT_QTDBUS
2369
- init_qtdbus_Smoke();
2437
+ init_qtdbus_Smoke();
2370
2438
  #endif
2371
- install_handlers(Qt_handlers);
2372
-
2373
- INIT_BINDING(qtcore)
2374
- INIT_BINDING(qtgui)
2375
- INIT_BINDING(qtxml)
2376
- INIT_BINDING(qtsql)
2377
- INIT_BINDING(qtopengl)
2378
- INIT_BINDING(qtnetwork)
2379
- INIT_BINDING(qtsvg)
2439
+ install_handlers(Qt_handlers);
2440
+
2441
+ INIT_BINDING(qtcore)
2442
+ INIT_BINDING(qtgui)
2443
+ INIT_BINDING(qtxml)
2444
+ INIT_BINDING(qtsql)
2445
+ INIT_BINDING(qtopengl)
2446
+ INIT_BINDING(qtnetwork)
2447
+ INIT_BINDING(qtsvg)
2380
2448
  #ifdef QT_QTDBUS
2381
- INIT_BINDING(qtdbus)
2449
+ INIT_BINDING(qtdbus)
2382
2450
  #endif
2383
2451
 
2384
2452
  if (qt_module == Qnil) {
@@ -2388,19 +2456,19 @@ Init_qtruby4()
2388
2456
  moduleindex_class = rb_define_class_under(qt_internal_module, "ModuleIndex", rb_cObject);
2389
2457
  }
2390
2458
 
2391
- rb_define_singleton_method(qt_base_class, "new", (VALUE (*) (...)) new_qt, -1);
2392
- rb_define_method(qt_base_class, "initialize", (VALUE (*) (...)) initialize_qt, -1);
2393
- rb_define_singleton_method(qt_base_class, "method_missing", (VALUE (*) (...)) class_method_missing, -1);
2394
- rb_define_singleton_method(qt_module, "method_missing", (VALUE (*) (...)) module_method_missing, -1);
2395
- rb_define_method(qt_base_class, "method_missing", (VALUE (*) (...)) method_missing, -1);
2459
+ rb_define_singleton_method(qt_base_class, "new", (VALUE (*) (...)) new_qt, -1);
2460
+ rb_define_method(qt_base_class, "initialize", (VALUE (*) (...)) initialize_qt, -1);
2461
+ rb_define_singleton_method(qt_base_class, "method_missing", (VALUE (*) (...)) class_method_missing, -1);
2462
+ rb_define_singleton_method(qt_module, "method_missing", (VALUE (*) (...)) module_method_missing, -1);
2463
+ rb_define_method(qt_base_class, "method_missing", (VALUE (*) (...)) method_missing, -1);
2396
2464
 
2397
- rb_define_singleton_method(qt_base_class, "const_missing", (VALUE (*) (...)) class_method_missing, -1);
2398
- rb_define_singleton_method(qt_module, "const_missing", (VALUE (*) (...)) module_method_missing, -1);
2399
- rb_define_method(qt_base_class, "const_missing", (VALUE (*) (...)) method_missing, -1);
2465
+ rb_define_singleton_method(qt_base_class, "const_missing", (VALUE (*) (...)) class_method_missing, -1);
2466
+ rb_define_singleton_method(qt_module, "const_missing", (VALUE (*) (...)) module_method_missing, -1);
2467
+ rb_define_method(qt_base_class, "const_missing", (VALUE (*) (...)) method_missing, -1);
2400
2468
 
2401
- rb_define_method(qt_base_class, "dispose", (VALUE (*) (...)) dispose, 0);
2402
- rb_define_method(qt_base_class, "isDisposed", (VALUE (*) (...)) is_disposed, 0);
2403
- rb_define_method(qt_base_class, "disposed?", (VALUE (*) (...)) is_disposed, 0);
2469
+ rb_define_method(qt_base_class, "dispose", (VALUE (*) (...)) dispose, 0);
2470
+ rb_define_method(qt_base_class, "isDisposed", (VALUE (*) (...)) is_disposed, 0);
2471
+ rb_define_method(qt_base_class, "disposed?", (VALUE (*) (...)) is_disposed, 0);
2404
2472
 
2405
2473
  rb_define_method(qt_base_class, "qVariantValue", (VALUE (*) (...)) qvariant_value, 2);
2406
2474
  rb_define_method(qt_base_class, "qVariantFromValue", (VALUE (*) (...)) qvariant_from_value, -1);
@@ -2409,86 +2477,86 @@ Init_qtruby4()
2409
2477
  rb_define_method(rb_cObject, "qFatal", (VALUE (*) (...)) qfatal, 1);
2410
2478
  rb_define_method(rb_cObject, "qWarning", (VALUE (*) (...)) qwarning, 1);
2411
2479
 
2412
- rb_define_module_function(qt_internal_module, "getMethStat", (VALUE (*) (...)) getMethStat, 0);
2413
- rb_define_module_function(qt_internal_module, "getClassStat", (VALUE (*) (...)) getClassStat, 0);
2414
- rb_define_module_function(qt_internal_module, "getIsa", (VALUE (*) (...)) getIsa, 1);
2415
- rb_define_module_function(qt_internal_module, "setDebug", (VALUE (*) (...)) setDebug, 1);
2416
- rb_define_module_function(qt_internal_module, "debug", (VALUE (*) (...)) debugging, 0);
2417
- rb_define_module_function(qt_internal_module, "get_arg_type_name", (VALUE (*) (...)) get_arg_type_name, 2);
2418
- rb_define_module_function(qt_internal_module, "classIsa", (VALUE (*) (...)) classIsa, 2);
2419
- rb_define_module_function(qt_internal_module, "isEnum", (VALUE (*) (...)) isEnum, 1);
2420
- rb_define_module_function(qt_internal_module, "insert_pclassid", (VALUE (*) (...)) insert_pclassid, 2);
2421
- rb_define_module_function(qt_internal_module, "classid2name", (VALUE (*) (...)) classid2name, 1);
2422
- rb_define_module_function(qt_internal_module, "find_pclassid", (VALUE (*) (...)) find_pclassid, 1);
2423
- rb_define_module_function(qt_internal_module, "get_value_type", (VALUE (*) (...)) get_value_type, 1);
2424
-
2425
- rb_define_module_function(qt_internal_module, "make_metaObject", (VALUE (*) (...)) make_metaObject, 4);
2426
- rb_define_module_function(qt_internal_module, "addMetaObjectMethods", (VALUE (*) (...)) add_metaobject_methods, 1);
2427
- rb_define_module_function(qt_internal_module, "addSignalMethods", (VALUE (*) (...)) add_signal_methods, 2);
2428
- rb_define_module_function(qt_internal_module, "mapObject", (VALUE (*) (...)) mapObject, 1);
2429
-
2430
- rb_define_module_function(qt_internal_module, "isQObject", (VALUE (*) (...)) isQObject, 1);
2431
- rb_define_module_function(qt_internal_module, "idInstance", (VALUE (*) (...)) idInstance, 1);
2432
- rb_define_module_function(qt_internal_module, "findClass", (VALUE (*) (...)) findClass, 1);
2433
- // rb_define_module_function(qt_internal_module, "idMethodName", (VALUE (*) (...)) idMethodName, 1);
2434
- // rb_define_module_function(qt_internal_module, "idMethod", (VALUE (*) (...)) idMethod, 2);
2435
- rb_define_module_function(qt_internal_module, "findMethod", (VALUE (*) (...)) findMethod, 2);
2436
- rb_define_module_function(qt_internal_module, "findAllMethods", (VALUE (*) (...)) findAllMethods, -1);
2437
- rb_define_module_function(qt_internal_module, "findAllMethodNames", (VALUE (*) (...)) findAllMethodNames, 3);
2438
- rb_define_module_function(qt_internal_module, "dumpCandidates", (VALUE (*) (...)) dumpCandidates, 1);
2439
- rb_define_module_function(qt_internal_module, "isConstMethod", (VALUE (*) (...)) isConstMethod, 1);
2440
- rb_define_module_function(qt_internal_module, "isObject", (VALUE (*) (...)) isObject, 1);
2441
- rb_define_module_function(qt_internal_module, "setCurrentMethod", (VALUE (*) (...)) setCurrentMethod, 1);
2442
- rb_define_module_function(qt_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0);
2443
- rb_define_module_function(qt_internal_module, "create_qt_class", (VALUE (*) (...)) create_qt_class, 2);
2444
- rb_define_module_function(qt_internal_module, "create_qobject_class", (VALUE (*) (...)) create_qobject_class, 2);
2445
- rb_define_module_function(qt_internal_module, "cast_object_to", (VALUE (*) (...)) cast_object_to, 2);
2446
- rb_define_module_function(qt_module, "dynamic_cast", (VALUE (*) (...)) cast_object_to, 2);
2447
- rb_define_module_function(qt_internal_module, "kross2smoke", (VALUE (*) (...)) kross2smoke, 2);
2448
- rb_define_module_function(qt_internal_module, "set_qtruby_embedded", (VALUE (*) (...)) set_qtruby_embedded_wrapped, 1);
2449
-
2450
- rb_define_module_function(qt_internal_module, "application_terminated=", (VALUE (*) (...)) set_application_terminated, 1);
2480
+ rb_define_module_function(qt_internal_module, "getMethStat", (VALUE (*) (...)) getMethStat, 0);
2481
+ rb_define_module_function(qt_internal_module, "getClassStat", (VALUE (*) (...)) getClassStat, 0);
2482
+ rb_define_module_function(qt_internal_module, "getIsa", (VALUE (*) (...)) getIsa, 1);
2483
+ rb_define_module_function(qt_internal_module, "setDebug", (VALUE (*) (...)) setDebug, 1);
2484
+ rb_define_module_function(qt_internal_module, "debug", (VALUE (*) (...)) debugging, 0);
2485
+ rb_define_module_function(qt_internal_module, "get_arg_type_name", (VALUE (*) (...)) get_arg_type_name, 2);
2486
+ rb_define_module_function(qt_internal_module, "classIsa", (VALUE (*) (...)) classIsa, 2);
2487
+ rb_define_module_function(qt_internal_module, "isEnum", (VALUE (*) (...)) isEnum, 1);
2488
+ rb_define_module_function(qt_internal_module, "insert_pclassid", (VALUE (*) (...)) insert_pclassid, 2);
2489
+ rb_define_module_function(qt_internal_module, "classid2name", (VALUE (*) (...)) classid2name, 1);
2490
+ rb_define_module_function(qt_internal_module, "find_pclassid", (VALUE (*) (...)) find_pclassid, 1);
2491
+ rb_define_module_function(qt_internal_module, "get_value_type", (VALUE (*) (...)) get_value_type, 1);
2492
+
2493
+ rb_define_module_function(qt_internal_module, "make_metaObject", (VALUE (*) (...)) make_metaObject, 4);
2494
+ rb_define_module_function(qt_internal_module, "addMetaObjectMethods", (VALUE (*) (...)) add_metaobject_methods, 1);
2495
+ rb_define_module_function(qt_internal_module, "addSignalMethods", (VALUE (*) (...)) add_signal_methods, 2);
2496
+ rb_define_module_function(qt_internal_module, "mapObject", (VALUE (*) (...)) mapObject, 1);
2497
+
2498
+ rb_define_module_function(qt_internal_module, "isQObject", (VALUE (*) (...)) isQObject, 1);
2499
+ rb_define_module_function(qt_internal_module, "idInstance", (VALUE (*) (...)) idInstance, 1);
2500
+ rb_define_module_function(qt_internal_module, "findClass", (VALUE (*) (...)) findClass, 1);
2501
+ // rb_define_module_function(qt_internal_module, "idMethodName", (VALUE (*) (...)) idMethodName, 1);
2502
+ // rb_define_module_function(qt_internal_module, "idMethod", (VALUE (*) (...)) idMethod, 2);
2503
+ rb_define_module_function(qt_internal_module, "findMethod", (VALUE (*) (...)) findMethod, 2);
2504
+ rb_define_module_function(qt_internal_module, "findAllMethods", (VALUE (*) (...)) findAllMethods, -1);
2505
+ rb_define_module_function(qt_internal_module, "findAllMethodNames", (VALUE (*) (...)) findAllMethodNames, 3);
2506
+ rb_define_module_function(qt_internal_module, "dumpCandidates", (VALUE (*) (...)) dumpCandidates, 1);
2507
+ rb_define_module_function(qt_internal_module, "isConstMethod", (VALUE (*) (...)) isConstMethod, 1);
2508
+ rb_define_module_function(qt_internal_module, "isObject", (VALUE (*) (...)) isObject, 1);
2509
+ rb_define_module_function(qt_internal_module, "setCurrentMethod", (VALUE (*) (...)) setCurrentMethod, 1);
2510
+ rb_define_module_function(qt_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0);
2511
+ rb_define_module_function(qt_internal_module, "create_qt_class", (VALUE (*) (...)) create_qt_class, 2);
2512
+ rb_define_module_function(qt_internal_module, "create_qobject_class", (VALUE (*) (...)) create_qobject_class, 2);
2513
+ rb_define_module_function(qt_internal_module, "cast_object_to", (VALUE (*) (...)) cast_object_to, 2);
2514
+ rb_define_module_function(qt_module, "dynamic_cast", (VALUE (*) (...)) cast_object_to, 2);
2515
+ rb_define_module_function(qt_internal_module, "kross2smoke", (VALUE (*) (...)) kross2smoke, 2);
2516
+ rb_define_module_function(qt_internal_module, "set_qtruby_embedded", (VALUE (*) (...)) set_qtruby_embedded_wrapped, 1);
2517
+
2518
+ rb_define_module_function(qt_internal_module, "application_terminated=", (VALUE (*) (...)) set_application_terminated, 1);
2451
2519
 
2452
2520
  rb_define_module_function(qt_module, "version", (VALUE (*) (...)) version, 0);
2453
- rb_define_module_function(qt_module, "qtruby_version", (VALUE (*) (...)) qtruby_version, 0);
2454
-
2455
- rb_define_module_function(qt_module, "qRegisterResourceData", (VALUE (*) (...)) q_register_resource_data, 4);
2456
- rb_define_module_function(qt_module, "qUnregisterResourceData", (VALUE (*) (...)) q_unregister_resource_data, 4);
2457
-
2458
- // A problem has been found with QtRuby when it is run with Ruby 1.9.1
2459
- // and GC.stess is true.
2460
- // In the smokeruby_mark() function called during garbage collection,
2461
- // any virtual methods which are called on the instances being checked
2462
- // could have overriden by Ruby methods. So the Wt::Ruby runtime uses
2463
- // 'respond_to()' to find out whether they have been overriden.
2464
- // However, this involves calling 'rb_intern()' on the method name,
2465
- // which means memory could be allocated, giving an error when running under
2466
- // GC.stress mode. So workround it by pre-allocating any strings with
2467
- // rb_intern() for all the C++ methods used in smokeruby_mark()
2468
- rb_intern("children");
2469
- rb_intern("childItems");
2470
- rb_intern("childCount");
2471
- rb_intern("child");
2472
- rb_intern("hasChildren");
2473
- rb_intern("parent");
2474
- rb_intern("parentItem");
2475
- rb_intern("item");
2476
- rb_intern("items");
2477
- rb_intern("rowCount");
2478
- rb_intern("rowAt");
2479
- rb_intern("columnCount");
2480
- rb_intern("elementAt");
2481
- rb_intern("columnAt");
2482
- rb_intern("topLevelItem");
2483
- rb_intern("itemAt");
2484
- rb_intern("internalPointer");
2521
+ rb_define_module_function(qt_module, "qtruby_version", (VALUE (*) (...)) qtruby_version, 0);
2522
+
2523
+ rb_define_module_function(qt_module, "qRegisterResourceData", (VALUE (*) (...)) q_register_resource_data, 4);
2524
+ rb_define_module_function(qt_module, "qUnregisterResourceData", (VALUE (*) (...)) q_unregister_resource_data, 4);
2525
+
2526
+ // A problem has been found with QtRuby when it is run with Ruby 1.9.1
2527
+ // and GC.stess is true.
2528
+ // In the smokeruby_mark() function called during garbage collection,
2529
+ // any virtual methods which are called on the instances being checked
2530
+ // could have overriden by Ruby methods. So the Wt::Ruby runtime uses
2531
+ // 'respond_to()' to find out whether they have been overriden.
2532
+ // However, this involves calling 'rb_intern()' on the method name,
2533
+ // which means memory could be allocated, giving an error when running under
2534
+ // GC.stress mode. So workround it by pre-allocating any strings with
2535
+ // rb_intern() for all the C++ methods used in smokeruby_mark()
2536
+ rb_intern("children");
2537
+ rb_intern("childItems");
2538
+ rb_intern("childCount");
2539
+ rb_intern("child");
2540
+ rb_intern("hasChildren");
2541
+ rb_intern("parent");
2542
+ rb_intern("parentItem");
2543
+ rb_intern("item");
2544
+ rb_intern("items");
2545
+ rb_intern("rowCount");
2546
+ rb_intern("rowAt");
2547
+ rb_intern("columnCount");
2548
+ rb_intern("elementAt");
2549
+ rb_intern("columnAt");
2550
+ rb_intern("topLevelItem");
2551
+ rb_intern("itemAt");
2552
+ rb_intern("internalPointer");
2485
2553
 
2486
2554
  rb_require("Qt/qtruby4.rb");
2487
2555
 
2488
2556
  rObject_typeId = QMetaType::registerType("rObject", &delete_ruby_object, &create_ruby_object);
2489
2557
 
2490
- // Do package initialization
2491
- rb_funcall(qt_internal_module, rb_intern("init_all_classes"), 0);
2558
+ // Do package initialization
2559
+ rb_funcall(qt_internal_module, rb_intern("init_all_classes"), 0);
2492
2560
  }
2493
2561
 
2494
2562
  }