#include "ruby.h"
#include "version.h"
#include "atp_ext.hpp"
using namespace ruby;
namespace ruby_atp {
VALUE cATP;
}
namespace {
VALUE build_ruby_version() {
ID const_get = rb_intern("const_get");
return rb_funcall(rb_cObject, const_get, 1, rb_str_new2("RUBY_VERSION"));
}
} // namespace
extern "C" void Init_atp_ext() {
using namespace ruby;
using namespace ruby_atp;
VALUE interpreter_version = build_ruby_version();
/*
strcmp(RUBY_VERSION, STR2CSTR(interpreter_version));
rb_raise(rb_eRuntimeError,
"Incorrect Ruby version for this extension; expected %s %s",
RUBY_VERSION, STR2CSTR(interpreter_version));
*/
if (strcmp(RUBY_VERSION, STR2CSTR(interpreter_version))) {
rb_raise(rb_eRuntimeError,
"Incorrect Ruby version for this extension; expected %s %s",
RUBY_VERSION, STR2CSTR(interpreter_version));
}
cATP = rb_define_module("ATP");
rb_define_module_function(cATP,
"extension_build_ruby_version", RUBY_METHOD(build_ruby_version), 0);
}