Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: ruby
rvm:
- 2.2.0-rc1
- 2.1.2
- 2.0.0
- 1.9.3
Expand Down
5 changes: 4 additions & 1 deletion ext/qml/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ def configure_extension
end
$CPPFLAGS += " -DHAVE_RUBY_THREAD_H" if have_header('ruby/thread.h')

$CPPFLAGS += " -std=c++11 -Wall -Wextra -pipe"
have_func('rb_rational_num')
have_func('rb_rational_den')

$CPPFLAGS += " -std=c++11 -Wall -Wextra -pipe -Wno-reserved-user-defined-literal"
if @debug_enabled
$CPPFLAGS += " -O0 -ggdb3"
else
Expand Down
20 changes: 19 additions & 1 deletion ext/qml/rubyvalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@
#include <QSet>
#include <QJSValue>

#ifndef HAVE_RB_RATIONAL_NUM

VALUE rb_rational_num(VALUE rat)
{
return RRATIONAL(rat)->num;
}

#endif

#ifndef HAVE_RB_RATIONAL_DEN

VALUE rb_rational_den(VALUE rat)
{
return RRATIONAL(rat)->den;
}

#endif

namespace RubyQml {

namespace detail {
Expand Down Expand Up @@ -152,7 +170,7 @@ template <> QDateTime Conversion<QDateTime>::from(RubyValue time)
offset = time.send(RUBYQML_INTERN("gmt_offset")).to<int>();
} else { // DateTime
VALUE dayOffset = time.send(RUBYQML_INTERN("offset"));
offset = RubyValue(RRATIONAL(dayOffset)->num).to<int>() * 24 * 60 * 60 / RubyValue(RRATIONAL(dayOffset)->den).to<int>();
offset = RubyValue(rb_rational_num(dayOffset)).to<int>() * 24 * 60 * 60 / RubyValue(rb_rational_den(dayOffset)).to<int>();
time = time.send(RUBYQML_INTERN("to_time"));
}
timeval at = rb_time_timeval(time);
Expand Down