@JRubyMethod(name = "method_missing", rest = true) public IRubyObject methodMissing(ThreadContext context, IRubyObject[] args) { if (args.length == 1) { RubyDescriptor rubyDescriptor = (RubyDescriptor) getDescriptor(context, metaClass); IRubyObject oneofDescriptor = rubyDescriptor.lookupOneof(context, args[0]); if (oneofDescriptor.isNil()) { if (!hasField(args[0])) { return Helpers.invokeSuper(context, this, metaClass, "method_missing", args, Block.NULL_BLOCK); } return index(context, args[0]); } RubyOneofDescriptor rubyOneofDescriptor = (RubyOneofDescriptor) oneofDescriptor; Descriptors.FieldDescriptor fieldDescriptor = oneofCases.get(rubyOneofDescriptor.getOneofDescriptor()); if (fieldDescriptor == null) return context.runtime.getNil(); return context.runtime.newSymbol(fieldDescriptor.getName()); } else { // fieldName is RubySymbol RubyString field = args[0].asString(); RubyString equalSign = context.runtime.newString(Utils.EQUAL_SIGN); if (field.end_with_p(context, equalSign).isTrue()) { field.chomp_bang(context, equalSign); } if (!hasField(field)) { return Helpers.invokeSuper(context, this, metaClass, "method_missing", args, Block.NULL_BLOCK); } return indexSet(context, field, args[1]); } }
@Deprecated @Override public IRubyObject callSuper(ThreadContext context, IRubyObject[] args, Block block) { return Helpers.invokeSuper(context, this, args, block); }
/** * The protocol for super method invocation is a bit complicated * in Ruby. In real terms it involves first finding the real * implementation class (the super class), getting the name of the * method to call from the frame, and then invoke that on the * super class with the current self as the actual object * invoking. */ public static IRubyObject invokeSuper(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) { return invokeSuper(context, self, context.getFrameKlazz(), context.getFrameName(), args, block); }
@JRubyMethod(name = "respond_to?", frame = true, compat = RUBY1_9) public IRubyObject respond_to(ThreadContext context, IRubyObject name) { if (name.asJavaString().equals("path")) { return this.realIo.callMethod(context, "respond_to?", name); } return Helpers.invokeSuper(context, this, name, Block.NULL_BLOCK); }
public static IRubyObject get_inner_class(final ThreadContext context, final RubyModule self, final IRubyObject name) { // const_missing delegate final String constName = name.asJavaString(); final RubyModule innerClass = getProxyUnderClass(context, self, constName); if ( innerClass == null ) { return Helpers.invokeSuper(context, self, name, Block.NULL_BLOCK); } return cacheConstant(self, constName, innerClass, true); // hidden == true (private_constant) }
public static IRubyObject get_inner_class(final ThreadContext context, final RubyModule self, final IRubyObject name) { // const_missing delegate final String constName = name.asJavaString(); final RubyModule innerClass = getProxyUnderClass(context, self, constName); if ( innerClass == null ) { return Helpers.invokeSuper(context, self, name, Block.NULL_BLOCK); } return cacheConstant(self, constName, innerClass, true); // hidden == true (private_constant) }
@JRubyMethod(name = "respond_to?", frame = true) public IRubyObject respond_to(ThreadContext context, IRubyObject name, IRubyObject includePrivate) { if (name.asJavaString().equals("path")) { return sites(context).reader_respond_to.call(context, this, this.realIo, name, includePrivate); } return Helpers.invokeSuper(context, this, name, Block.NULL_BLOCK); }
@JRubyMethod(name = "respond_to?", frame = true) public IRubyObject respond_to(ThreadContext context, IRubyObject name) { if (name.asJavaString().equals("path")) { return sites(context).reader_respond_to.call(context, this, this.realIo, name); } return Helpers.invokeSuper(context, this, name, Block.NULL_BLOCK); }
@JRubyMethod(frame = true) public static IRubyObject append_features(ThreadContext context, IRubyObject self, IRubyObject clazz, Block block) { if (clazz instanceof RubyClass) { appendFeaturesToClass(context, self, (RubyClass)clazz); } else if (clazz instanceof RubyModule) { appendFeaturesToModule(context, self, (RubyModule)clazz); } else { throw context.runtime.newTypeError("received " + clazz + ", expected Class/Module"); } return Helpers.invokeSuper(context, self, clazz, block); }
@JRubyMethod(frame = true) public IRubyObject min(ThreadContext context, Block block) { if (block.isGiven()) { return Helpers.invokeSuper(context, this, block); } int cmp = RubyComparable.cmpint(context, invokedynamic(context, begin, MethodNames.OP_CMP, end), begin, end); if (cmp > 0 || (cmp == 0 && isExclusive)) { return context.nil; } return begin; }
@JRubyMethod(meta = true, frame = true) // framed for invokeSuper public static IRubyObject inherited(ThreadContext context, IRubyObject recv, IRubyObject subclass) { IRubyObject subJavaClass = JavaClass.java_class(context, (RubyClass) subclass); if (subJavaClass.isNil()) { subJavaClass = JavaClass.java_class(context, (RubyClass) recv); Helpers.invoke(context, subclass, "java_class=", subJavaClass); } return Helpers.invokeSuper(context, recv, subclass, Block.NULL_BLOCK); }
@JRubyMethod(meta = true, frame = true) // framed for invokeSuper public static IRubyObject inherited(ThreadContext context, IRubyObject recv, IRubyObject subclass) { IRubyObject subJavaClass = JavaClass.java_class(context, (RubyClass) subclass); if (subJavaClass.isNil()) { subJavaClass = JavaClass.java_class(context, (RubyClass) recv); Helpers.invoke(context, subclass, "java_class=", subJavaClass); } return Helpers.invokeSuper(context, recv, subclass, Block.NULL_BLOCK); }
public static IRubyObject callZSuper(Ruby runtime, ThreadContext context, Block block, IRubyObject self) { // Has the method that is calling super received a block argument if (!block.isGiven()) block = context.getCurrentFrame().getBlock(); return Helpers.invokeSuper(context, self, context.getCurrentScope().getArgValues(), block); }
@JRubyMethod(frame = true, meta = true) public static IRubyObject inherited(ThreadContext context, IRubyObject recv, IRubyObject subclass) { IRubyObject subJavaClass = Helpers.invoke(context, subclass, "java_class"); if (subJavaClass.isNil()) { subJavaClass = Helpers.invoke(context, recv, "java_class"); Helpers.invoke(context, subclass, "java_class=", subJavaClass); } return Helpers.invokeSuper(context, recv, subclass, Block.NULL_BLOCK); }
@JRubyMethod(frame = true, meta = true) public static IRubyObject inherited(ThreadContext context, IRubyObject recv, IRubyObject subclass) { IRubyObject subJavaClass = Helpers.invoke(context, subclass, "java_class"); if (subJavaClass.isNil()) { subJavaClass = Helpers.invoke(context, recv, "java_class"); Helpers.invoke(context, subclass, "java_class=", subJavaClass); } return Helpers.invokeSuper(context, recv, subclass, Block.NULL_BLOCK); }
@JRubyMethod(name = "escapeHTML", module = true, frame = true) public static IRubyObject cgiesc_escape_html(ThreadContext context, IRubyObject self, IRubyObject _str) { RubyString str = _str.convertToString(); if (str.getEncoding().isAsciiCompatible()) { return optimized_escape_html(context.runtime, str); } else { return Helpers.invokeSuper(context, self, _str, Block.NULL_BLOCK); } }
@JRubyMethod(name = "unescapeHTML", module = true, frame = true) public static IRubyObject cgiesc_unescape_html(ThreadContext context, IRubyObject self, IRubyObject _str) { RubyString str = _str.convertToString(); if (str.getEncoding().isAsciiCompatible()) { return optimized_unescape_html(context.runtime, str); } else { return Helpers.invokeSuper(context, self, _str, Block.NULL_BLOCK); } }
@JRubyMethod(name = "escape", module = true, frame = true) public static IRubyObject cgiesc_escape(ThreadContext context, IRubyObject self, IRubyObject _str) { RubyString str = _str.convertToString(); if (str.getEncoding().isAsciiCompatible()) { return optimized_escape(context.runtime, str); } else { return Helpers.invokeSuper(context, self, _str, Block.NULL_BLOCK); } }
@JRubyMethod(name = "unescape", required = 1, optional = 1, module = true, frame = true) public static IRubyObject cgiesc_unescape(ThreadContext context, IRubyObject self, IRubyObject[] argv) { IRubyObject _str = argv[0]; RubyString str = _str.convertToString(); if (str.getEncoding().isAsciiCompatible()) { IRubyObject enc = accept_charset(argv, argv.length - 1, 1, self); return optimized_unescape(context, str, enc); } else { return Helpers.invokeSuper(context, self, argv, Block.NULL_BLOCK); } }
@JRubyMethod(name = "unescape", required = 1, optional = 1, module = true, frame = true) public static IRubyObject cgiesc_unescape(ThreadContext context, IRubyObject self, IRubyObject[] argv) { IRubyObject _str = argv[0]; RubyString str = _str.convertToString(); if (str.getEncoding().isAsciiCompatible()) { IRubyObject enc = accept_charset(argv, argv.length - 1, 1, self); return optimized_unescape(context, str, enc); } else { return Helpers.invokeSuper(context, self, argv, Block.NULL_BLOCK); } }