Exemplo n.º 1
0
VALUE RubyInterpreter::require (VALUE obj, VALUE name)
{
#ifdef KROSS_RUBY_INTERPRETER_DEBUG
    krossdebug("RubyInterpreter::require(obj,name)");
#endif
    QString modname = StringValuePtr(name);
    if(modname.startsWith("kross")) {
        krossdebug( QString("RubyInterpreter::require() module=%1").arg(modname) );
        if( modname.find( QRegExp("[^a-zA-Z0-9\\_\\-]") ) >= 0 ) {
            krosswarning( QString("Denied import of Kross module '%1' cause of untrusted chars.").arg(modname) );
        }
        else {
            Kross::Api::Module::Ptr module = Kross::Api::Manager::scriptManager()->loadModule(modname);
            if(module)
            {
                new RubyModule(module, modname);
//                     VALUE rmodule = rb_define_module(modname.ascii());
//                     rb_define_module_function();
//                     VALUE rm = RubyExtension::toVALUE(module);
//                     rb_define_variable( ("$" + modname).ascii(), & RubyInterpreter::d->m_modules.insert( mStrVALUE::value_type( modname, rm) ).first->second );
                return Qtrue;
            }
            krosswarning( QString("Loading of Kross module '%1' failed.").arg(modname) );
        }
    } else {
        return rb_f_require(obj, name);
    }
    return Qfalse;
}
Exemplo n.º 2
0
static VALUE
rb_f_require_imp(VALUE obj, SEL sel, VALUE fname)
{
    return rb_f_require(obj, fname);
}