if (keyType.equals(RubySymbol.newSymbol(runtime, "float")) || keyType.equals(RubySymbol.newSymbol(runtime, "double")) || keyType.equals(RubySymbol.newSymbol(runtime, "enum")) || keyType.equals(RubySymbol.newSymbol(runtime, "message"))) throw runtime.newArgumentError("Cannot add a map field with a float, double, enum, or message type."); IRubyObject mapentryDescName = RubySymbol.newSymbol(runtime, name).id2name(context); mapentryDesc.setName(context, mapentryDescName); mapentryDesc.setMapEntry(true); keyField.setLabel(context, RubySymbol.newSymbol(runtime, "optional")); keyField.setNumber(context, runtime.newFixnum(1)); keyField.setType(context, keyType); valueField.setLabel(context, RubySymbol.newSymbol(runtime, "optional")); valueField.setNumber(context, runtime.newFixnum(2)); valueField.setType(context, valueType);
private RubyMap newMapForField(ThreadContext context, Descriptors.FieldDescriptor fieldDescriptor) { RubyDescriptor mapDescriptor = (RubyDescriptor) getDescriptorForField(context, fieldDescriptor); Descriptors.FieldDescriptor keyField = fieldDescriptor.getMessageType().findFieldByNumber(1); Descriptors.FieldDescriptor valueField = fieldDescriptor.getMessageType().findFieldByNumber(2); IRubyObject keyType = RubySymbol.newSymbol(context.runtime, keyField.getType().name()); IRubyObject valueType = RubySymbol.newSymbol(context.runtime, valueField.getType().name()); if (valueField.getType() == Descriptors.FieldDescriptor.Type.MESSAGE) { RubyFieldDescriptor rubyFieldDescriptor = (RubyFieldDescriptor) mapDescriptor.lookup(context, context.runtime.newString("value")); RubyDescriptor rubyDescriptor = (RubyDescriptor) rubyFieldDescriptor.getSubType(context); return (RubyMap) cMap.newInstance(context, keyType, valueType, rubyDescriptor.msgclass(context), Block.NULL_BLOCK); } else { return (RubyMap) cMap.newInstance(context, keyType, valueType, Block.NULL_BLOCK); } }
public IRubyObject construct(ThreadContext context) { return RubySymbol.newSymbol(context.runtime, value, IRRuntimeHelpers.retrieveJCodingsEncoding(context, encoding)); } }
@JRubyMethod(name = {"succ", "next"}, compat = CompatVersion.RUBY1_9) public IRubyObject succ(ThreadContext context) { Ruby runtime = context.runtime; return newSymbol(runtime, newShared(runtime).succ19(context).toString()); }
@JRubyMethod(name = "capitalize", compat = CompatVersion.RUBY1_9) public IRubyObject capitalize(ThreadContext context) { Ruby runtime = context.runtime; return newSymbol(runtime, rubyStringFromString(runtime).capitalize19(context).toString()); }
@JRubyMethod(name = "capitalize", compat = CompatVersion.RUBY1_9) public IRubyObject capitalize(ThreadContext context) { Ruby runtime = context.runtime; return newSymbol(runtime, rubyStringFromString(runtime).capitalize19(context).toString()); }
@JRubyMethod public IRubyObject downcase(ThreadContext context, IRubyObject arg0, IRubyObject arg1) { Ruby runtime = context.runtime; return newSymbol(runtime, newShared(runtime).downcase(context, arg0, arg1).getByteList()); }
@JRubyMethod public IRubyObject capitalize(ThreadContext context, IRubyObject arg) { Ruby runtime = context.runtime; return newSymbol(runtime, newShared(runtime).capitalize(context, arg).getByteList()); }
@JRubyMethod public IRubyObject upcase(ThreadContext context, IRubyObject arg) { Ruby runtime = context.runtime; return newSymbol(runtime, newShared(runtime).upcase(context, arg).getByteList()); }
@JRubyMethod public IRubyObject swapcase(ThreadContext context) { Ruby runtime = context.runtime; return newSymbol(runtime, newShared(runtime).swapcase(context).getByteList()); }
@JRubyMethod public IRubyObject capitalize(ThreadContext context) { Ruby runtime = context.runtime; return newSymbol(runtime, newShared(runtime).capitalize(context).getByteList()); }
public static IRubyObject symbol(MutableCallSite site, String name, ThreadContext context) { RubySymbol symbol = RubySymbol.newSymbol(context.runtime, name); site.setTarget(Binder .from(IRubyObject.class, ThreadContext.class) .drop(0) .constant(symbol) ); return symbol; }
public static RubySymbol unmarshalFrom(UnmarshalStream input) throws java.io.IOException { RubySymbol result = newSymbol(input.getRuntime(), RubyString.byteListToString(input.unmarshalString())); input.registerLinkTarget(result); return result; }
@JRubyMethod public IRubyObject downcase(ThreadContext context) { Ruby runtime = context.runtime; return newSymbol(runtime, newShared(runtime).downcase(context).getByteList()); }
@JRubyMethod public IRubyObject downcase(ThreadContext context, IRubyObject arg) { Ruby runtime = context.runtime; return newSymbol(runtime, newShared(runtime).downcase(context, arg).getByteList()); }
@JRubyMethod public IRubyObject swapcase(ThreadContext context, IRubyObject arg0, IRubyObject arg1) { Ruby runtime = context.runtime; return newSymbol(runtime, newShared(runtime).swapcase(context, arg0, arg1).getByteList()); }
@JRubyMethod public IRubyObject upcase(ThreadContext context, IRubyObject arg) { Ruby runtime = context.runtime; return newSymbol(runtime, newShared(runtime).upcase(context, arg).getByteList()); }
@JRubyMethod public IRubyObject capitalize(ThreadContext context, IRubyObject arg) { Ruby runtime = context.runtime; return newSymbol(runtime, newShared(runtime).capitalize(context, arg).getByteList()); }
public void dumpDefaultObjectHeader(char tp, RubyClass type) throws IOException { dumpExtended(type); write(tp); writeAndRegisterSymbol(RubySymbol.newSymbol(runtime, getPathFromClass(type.getRealClass())).getBytes()); }
public void writeUserClass(IRubyObject obj, RubyClass type) throws IOException { write(TYPE_UCLASS); // w_unique if (type.getName().charAt(0) == '#') { Ruby runtime = obj.getRuntime(); throw runtime.newTypeError(str(runtime, "can't dump anonymous class ", types(runtime, type))); } // w_symbol writeAndRegisterSymbol(RubySymbol.newSymbol(runtime, type.getName()).getBytes()); }