Package org.jruby

Examples of org.jruby.RubyModule.callMethod()


  
        if (context.getCurrentVisibility() == Visibility.MODULE_FUNCTION) {
            containingClass.getSingletonClass().addMethod(name,
                    new WrapperMethod(containingClass.getSingletonClass(), newMethod, Visibility.PUBLIC));
           
            containingClass.callMethod(context, "singleton_method_added", runtime.fastNewSymbol(name));
        }
  
        // 'class << state.self' and 'class << obj' uses defn as opposed to defs
        if (containingClass.isSingleton()) {
            ((MetaClass) containingClass).getAttached().callMethod(context,
View Full Code Here


        // 'class << state.self' and 'class << obj' uses defn as opposed to defs
        if (containingClass.isSingleton()) {
            ((MetaClass) containingClass).getAttached().callMethod(context,
                    "singleton_method_added", runtime.fastNewSymbol(name));
        } else {
            containingClass.callMethod(context, "method_added", runtime.fastNewSymbol(name));
        }
  
        return runtime.getNil();       
    }
}
View Full Code Here

            throw context.getRuntime().newRuntimeError("invalid or corrupted FFI::TypeDefs");
        }

        IRubyObject type = ((RubyHash) typeDefs).fastARef(obj);
        if (type == null || type.isNil()) {
            type = ffi.callMethod(context, "find_type", obj);
        }

        if (!(type instanceof Type)) {
            throw context.getRuntime().newTypeError("Could not resolve type: " + obj);
        }
View Full Code Here

    public static Object convertProcToInterface(ThreadContext context, RubyBasicObject rubyObject, Class target) {
        Ruby runtime = context.getRuntime();
        RubyModule javaInterfaceModule = (RubyModule)Java.get_interface_module(runtime, JavaClass.get(runtime, target));
        if (!((RubyModule) javaInterfaceModule).isInstance(rubyObject)) {
            javaInterfaceModule.callMethod(context, "extend_object", rubyObject);
            javaInterfaceModule.callMethod(context, "extended", rubyObject);
        }

        if (rubyObject instanceof RubyProc) {
            // Proc implementing an interface, pull in the catch-all code that lets the proc get invoked
View Full Code Here

    public static Object convertProcToInterface(ThreadContext context, RubyBasicObject rubyObject, Class target) {
        Ruby runtime = context.getRuntime();
        RubyModule javaInterfaceModule = (RubyModule)Java.get_interface_module(runtime, JavaClass.get(runtime, target));
        if (!((RubyModule) javaInterfaceModule).isInstance(rubyObject)) {
            javaInterfaceModule.callMethod(context, "extend_object", rubyObject);
            javaInterfaceModule.callMethod(context, "extended", rubyObject);
        }

        if (rubyObject instanceof RubyProc) {
            // Proc implementing an interface, pull in the catch-all code that lets the proc get invoked
            // no matter what method is called on the interface
View Full Code Here

            (String) newNameArg : newNameArg.toString();
        String oldName = (oldNameArg instanceof String) ?
            (String) oldNameArg : oldNameArg.toString();

        module.defineAlias(newName, oldName);
        module.callMethod(context, "method_added", runtime.newSymbol(newName));
  
        return runtime.getNil();
    }
   
    public static IRubyObject negate(IRubyObject value, Ruby runtime) {
View Full Code Here

            return (Type) name;
        }
        final RubyModule ffi = context.getRuntime().fastGetModule("FFI");
        final IRubyObject typeDefs = ffi.fastFetchConstant("TypeDefs");
        final IRubyObject type = ((RubyHash) typeDefs).fastARef(name);
        return type instanceof Type ? (Type) type : (Type) ffi.callMethod(context, "find_type", name);
    }

    public static ByteOrder parseByteOrder(Ruby runtime, IRubyObject byte_order) {
        if (byte_order instanceof RubySymbol || byte_order instanceof RubyString) {
            String orderName = byte_order.asJavaString();
View Full Code Here

                }

                rubyObj = unmarshalObject();

                tp.extend_object(rubyObj);
                tp.callMethod(runtime.getCurrentContext(),"extended", rubyObj);
                break;
            case 'l' :
                rubyObj = RubyBignum.unmarshalFrom(this);
                break;
            case 'S' :
View Full Code Here

    }

    @Override
    public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) {
        RubyModule module = (RubyModule) receiver.retrieve(context, self, currDynScope, temp);
        return module.callMethod(context, "const_missing", context.runtime.fastNewSymbol(missingConst));
    }

    @Override
    public void visit(IRVisitor visitor) {
        visitor.ConstMissingInstr(this);
View Full Code Here

            constant = noPrivateConsts ? module.getConstantFromNoConstMissing(constName, false) : module.getConstantNoConstMissing(constName);
        }

        // Call const_missing or cache
        if (constant == null) {
            constant = module.callMethod(context, "const_missing", context.runtime.fastNewSymbol(constName));
        } else {
            // recache
            generation = runtime.getConstantInvalidator().getData();
            cachedConstant = constant;
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.