/** * Retrieve the named constant, invoking 'const_missing' should that be appropriate. * * @param name The constant to retrieve * @return The value for the constant, or null if not found */ public IRubyObject getConstant(String name) { return getConstant(name, true); }
/** * Retrieve the named constant, invoking 'const_missing' should that be appropriate. * * @param name The constant to retrieve * @return The value for the constant, or null if not found */ public IRubyObject getConstant(String name) { return getConstant(name, true); }
@JRubyMethod(name = "zlib_version", module = true, visibility = PRIVATE) public static IRubyObject zlib_version(IRubyObject recv) { RubyBasicObject res = (RubyBasicObject) ((RubyModule)recv).getConstant("ZLIB_VERSION"); // MRI behavior, enforced by tests res.setTaint(true); return res; }
/** rb_mod_const_get * */ @JRubyMethod(name = "const_get", required = 1, compat = CompatVersion.RUBY1_8) public IRubyObject const_get(IRubyObject symbol) { return getConstant(validateConstant(symbol.asJavaString())); }
@JRubyMethod(name = "data_type") public IRubyObject data_type() { checkClosed(); return getRuntime().getModule("Zlib").getConstant("UNKNOWN"); }
@JRubyMethod(name = "data_type") public IRubyObject data_type() { checkClosed(); return getRuntime().getModule("Zlib").getConstant("UNKNOWN"); }
@JRubyMethod(name = "data_type") public IRubyObject data_type() { checkClosed(); return getRuntime().getModule("Zlib").getConstant("UNKNOWN"); }
public static void create(Ruby runtime) { RubyModule mNet = runtime.getModule("Net"); RubyClass cBufferedIO = (RubyClass)mNet.getConstant("BufferedIO"); cBufferedIO.defineAnnotatedMethods(NetProtocolBufferedIO.class); RubyModule mNativeImpl = cBufferedIO.defineModuleUnder("NativeImplementation"); mNativeImpl.defineAnnotatedMethods(NativeImpl.class); }
public static void create(Ruby runtime) { RubyModule mNet = runtime.getModule("Net"); RubyClass cBufferedIO = (RubyClass)mNet.getConstant("BufferedIO"); cBufferedIO.defineAnnotatedMethods(NetProtocolBufferedIO.class); RubyModule mNativeImpl = cBufferedIO.defineModuleUnder("NativeImplementation"); mNativeImpl.defineAnnotatedMethods(NativeImpl.class); }
@JRubyMethod(required = 2, optional = 1, frame = true) public static IRubyObject scalar(IRubyObject self, IRubyObject[] args, Block block) { Ruby runtime = self.getRuntime(); ThreadContext ctx = runtime.getCurrentContext(); IRubyObject type_id = args[0]; IRubyObject str = args[1]; IRubyObject style = args.length == 2 ? runtime.getNil() : args[2]; IRubyObject scalar = ((RubyModule)((RubyModule)runtime.getModule("YAML")).getConstant("Yecht")).getConstant("Scalar").callMethod(ctx, "new", new IRubyObject[]{type_id, str, style}); outMark((IRubyObject)((RubyObject)self).fastGetInstanceVariable("@emitter"), scalar); return scalar; } }
@JRubyMethod(name = "data_type") public IRubyObject data_type() { checkClosed(); return getRuntime().getModule("Zlib").getConstant("UNKNOWN"); }
public static RubyClass createEnumClass(Ruby runtime, RubyModule ffiModule) { RubyClass enumClass = ffiModule.defineClassUnder("Enum", runtime.getObject(), Allocator.INSTANCE); enumClass.defineAnnotatedMethods(Enum.class); enumClass.defineAnnotatedConstants(Enum.class); enumClass.includeModule(ffiModule.getConstant("DataConverter")); return enumClass; }
public static RubyClass createEnumsClass(Ruby runtime, RubyModule ffiModule) { RubyClass enumsClass = ffiModule.defineClassUnder("Enums", runtime.getObject(), Allocator.INSTANCE); enumsClass.defineAnnotatedMethods(Enums.class); enumsClass.defineAnnotatedConstants(Enums.class); enumsClass.includeModule(ffiModule.getConstant("DataConverter")); return enumsClass; }
public static RubyClass createEnumClass(Ruby runtime, RubyModule ffiModule) { RubyClass enumClass = ffiModule.defineClassUnder("Enum", runtime.getObject(), Allocator.INSTANCE); enumClass.defineAnnotatedMethods(Enum.class); enumClass.defineAnnotatedConstants(Enum.class); enumClass.includeModule(ffiModule.getConstant("DataConverter")); return enumClass; }
@JRubyMethod(required = 1, optional = 1, frame = true) public static IRubyObject seq(IRubyObject self, IRubyObject[] args, Block block) { Ruby runtime = self.getRuntime(); ThreadContext ctx = runtime.getCurrentContext(); IRubyObject type_id = args[0]; IRubyObject style = args.length == 1 ? runtime.getNil() : args[1]; IRubyObject seq = ((RubyModule)((RubyModule)runtime.getModule("YAML")).getConstant("Yecht")).getConstant("Seq").callMethod(ctx, "new", new IRubyObject[]{type_id, RubyArray.newArray(runtime), style}); outMark((IRubyObject)((RubyObject)self).fastGetInstanceVariable("@emitter"), seq); block.yield(ctx, seq); return seq; }
@JRubyMethod(name = "const_get", required = 1, optional = 1, compat = CompatVersion.RUBY1_9) public IRubyObject const_get_1_9(ThreadContext context, IRubyObject[] args) { IRubyObject symbol = args[0]; boolean inherit = args.length == 1 || (!args[1].isNil() && args[1].isTrue()); // 1.9 only includes Object when inherit = true or unspecified (JRUBY-6224) return getConstant(validateConstant(symbol.asJavaString()), inherit, inherit); }
public static RubyClass createEnumClass(Ruby runtime, RubyModule ffiModule) { RubyClass enumClass = ffiModule.defineClassUnder("Enum", runtime.getObject(), Allocator.INSTANCE); enumClass.defineAnnotatedMethods(Enum.class); enumClass.defineAnnotatedConstants(Enum.class); enumClass.includeModule(ffiModule.getConstant("DataConverter")); return enumClass; }
public IRubyObject allocate(Ruby runtime, RubyClass klass) { // System.err.println("ALLOCATING EMITTER"); Emitter emitter = new Emitter(); emitter.bonus = new Extra(); IRubyObject pobj = runtime.newData(klass, emitter); emitter.handler(new RubyEmitterHandler(runtime)); emitter.outputHandler(new RubyOutputHandler(runtime)); ((RubyObject)pobj).fastSetInstanceVariable("@out", ((RubyModule)((RubyModule)runtime.getModule("YAML")).getConstant("Yecht")).getConstant("Out").callMethod(runtime.getCurrentContext(), "new", pobj)); return pobj; } };
@JRubyMethod(name = "ruby", meta = true) public static IRubyObject ruby(ThreadContext context, IRubyObject recv) { Ruby runtime = context.runtime; RubyHash configHash = (RubyHash) runtime.getModule("RbConfig").getConstant("CONFIG"); IRubyObject bindir = configHash.op_aref(context, runtime.newString("bindir")); IRubyObject ruby_install_name = configHash.op_aref(context, runtime.newString("ruby_install_name")); IRubyObject exeext = configHash.op_aref(context, runtime.newString("EXEEXT")); return Helpers.invoke(context, runtime.getClass("File"), "join", bindir, ruby_install_name.callMethod(context, "+", exeext)); }
@JRubyMethod(name = "ruby", meta = true) public static IRubyObject ruby(ThreadContext context, IRubyObject recv) { Ruby runtime = context.runtime; RubyHash configHash = (RubyHash) runtime.getModule("RbConfig").getConstant("CONFIG"); IRubyObject bindir = configHash.op_aref(context, runtime.newString("bindir")); IRubyObject ruby_install_name = configHash.op_aref(context, runtime.newString("ruby_install_name")); IRubyObject exeext = configHash.op_aref(context, runtime.newString("EXEEXT")); return Helpers.invoke(context, runtime.getClass("File"), "join", bindir, ruby_install_name.callMethod(context, "+", exeext)); }