private RubyModule buildModuleFromDescriptor(ThreadContext context) { Ruby runtime = context.runtime; Utils.checkNameAvailability(context, name.asJavaString()); RubyModule enumModule = RubyModule.newModule(runtime); for (Descriptors.EnumValueDescriptor value : descriptor.getValues()) { enumModule.defineConstant(value.getName(), runtime.newFixnum(value.getNumber())); } enumModule.instance_variable_set(runtime.newString(Utils.DESCRIPTOR_INSTANCE_VAR), this); enumModule.defineAnnotatedMethods(RubyEnum.class); return enumModule; }
public static void createNKF(Ruby runtime) { final RubyModule NKF = runtime.defineModule("NKF"); final String version = "2.1.2"; final String relDate = "2011-09-08"; NKF.defineConstant("NKF_VERSION", runtime.newString(version)); NKF.defineConstant("NKF_RELEASE_DATE", runtime.newString(relDate)); NKF.defineConstant("VERSION", runtime.newString(version + ' ' + '(' + "JRuby" + '_' + relDate + ')')); for ( NKFCharset charset : NKFCharset.values() ) { NKFCharsetMap.put(charset.value, charset.name()); if (charset.value > 12 ) continue; NKF.defineConstant(charset.name(), charsetMappedValue(runtime, charset)); } NKF.defineAnnotatedMethods(RubyNKF.class); }
public static RubyModule createMarshalModule(Ruby runtime) { RubyModule module = runtime.defineModule("Marshal"); runtime.setMarshal(module); module.defineAnnotatedMethods(RubyMarshal.class); module.defineConstant("MAJOR_VERSION", runtime.newFixnum(Constants.MARSHAL_MAJOR)); module.defineConstant("MINOR_VERSION", runtime.newFixnum(Constants.MARSHAL_MINOR)); return module; }
public static void createNKF(Ruby runtime) { final RubyModule NKF = runtime.defineModule("NKF"); final String version = "2.1.2"; final String relDate = "2011-09-08"; NKF.defineConstant("NKF_VERSION", runtime.newString(version)); NKF.defineConstant("NKF_RELEASE_DATE", runtime.newString(relDate)); NKF.defineConstant("VERSION", runtime.newString(version + ' ' + '(' + "JRuby" + '_' + relDate + ')')); for ( NKFCharset charset : NKFCharset.values() ) { NKFCharsetMap.put(charset.value, charset.name()); if (charset.value > 12 ) continue; NKF.defineConstant(charset.name(), charsetMappedValue(runtime, charset)); } NKF.defineAnnotatedMethods(RubyNKF.class); }
/** Create the Math module and add it to the Ruby runtime. * */ public static RubyModule createMathModule(Ruby runtime) { RubyModule result = runtime.defineModule("Math"); runtime.setMath(result); result.defineConstant("E", RubyFloat.newFloat(runtime, Math.E)); result.defineConstant("PI", RubyFloat.newFloat(runtime, Math.PI)); result.defineAnnotatedMethods(RubyMath.class); return result; }
public static RubyModule createMarshalModule(Ruby runtime) { RubyModule module = runtime.defineModule("Marshal"); runtime.setMarshal(module); module.defineAnnotatedMethods(RubyMarshal.class); module.defineConstant("MAJOR_VERSION", runtime.newFixnum(Constants.MARSHAL_MAJOR)); module.defineConstant("MINOR_VERSION", runtime.newFixnum(Constants.MARSHAL_MINOR)); return module; }
/** Create the Math module and add it to the Ruby runtime. * */ public static RubyModule createMathModule(Ruby runtime) { RubyModule result = runtime.defineModule("Math"); runtime.setMath(result); result.defineConstant("E", RubyFloat.newFloat(runtime, Math.E)); result.defineConstant("PI", RubyFloat.newFloat(runtime, Math.PI)); result.defineAnnotatedMethods(RubyMath.class); return result; }
/** Create the Math module and add it to the Ruby runtime. * */ public static RubyModule createMathModule(Ruby runtime) { RubyModule result = runtime.defineModule("Math"); runtime.setMath(result); result.defineConstant("E", RubyFloat.newFloat(runtime, Math.E)); result.defineConstant("PI", RubyFloat.newFloat(runtime, Math.PI)); result.defineAnnotatedMethods(RubyMath.class); return result; }
public static RubyModule createMarshalModule(Ruby runtime) { RubyModule module = runtime.defineModule("Marshal"); runtime.setMarshal(module); module.defineAnnotatedMethods(RubyMarshal.class); module.defineConstant("MAJOR_VERSION", runtime.newFixnum(Constants.MARSHAL_MAJOR)); module.defineConstant("MINOR_VERSION", runtime.newFixnum(Constants.MARSHAL_MINOR)); return module; }
/** Create the Math module and add it to the Ruby runtime. * */ public static RubyModule createMathModule(Ruby runtime) { RubyModule result = runtime.defineModule("Math"); runtime.setMath(result); result.defineConstant("E", RubyFloat.newFloat(runtime, Math.E)); result.defineConstant("PI", RubyFloat.newFloat(runtime, Math.PI)); result.defineAnnotatedMethods(RubyMath.class); return result; }
public static RubyModule createMarshalModule(Ruby runtime) { RubyModule module = runtime.defineModule("Marshal"); runtime.setMarshal(module); module.defineAnnotatedMethods(RubyMarshal.class); module.defineConstant("MAJOR_VERSION", runtime.newFixnum(Constants.MARSHAL_MAJOR)); module.defineConstant("MINOR_VERSION", runtime.newFixnum(Constants.MARSHAL_MINOR)); return module; }
public void load(final Ruby runtime, boolean wrap) throws IOException { RubyModule mFcntl = runtime.defineModule("Fcntl"); runtime.loadConstantSet(mFcntl, "Fcntl"); runtime.loadConstantSet(mFcntl, "OpenFlags"); mFcntl.defineConstant("FD_CLOEXEC", RubyFixnum.newFixnum(runtime, FD_CLOEXEC)); } }
public void load(final Ruby runtime, boolean wrap) throws IOException { RubyModule mFcntl = runtime.defineModule("Fcntl"); runtime.loadConstantSet(mFcntl, "Fcntl"); runtime.loadConstantSet(mFcntl, "OpenFlags"); mFcntl.defineConstant("FD_CLOEXEC", RubyFixnum.newFixnum(runtime, FD_CLOEXEC)); } }
public void load(final Ruby runtime, boolean wrap) throws IOException { RubyModule mFcntl = runtime.defineModule("Fcntl"); runtime.loadConstantSet(mFcntl, "Fcntl"); runtime.loadConstantSet(mFcntl, "OpenFlags"); mFcntl.defineConstant("FD_CLOEXEC", RubyFixnum.newFixnum(runtime, FD_CLOEXEC)); } }
public void load(final Ruby runtime, boolean wrap) throws IOException { RubyModule mFcntl = runtime.defineModule("Fcntl"); runtime.loadConstantSet(mFcntl, "Fcntl"); runtime.loadConstantSet(mFcntl, "OpenFlags"); mFcntl.defineConstant("FD_CLOEXEC", RubyFixnum.newFixnum(runtime, FD_CLOEXEC)); } }
private static void defineGroupStruct(Ruby runtime) { IRubyObject[] args = new IRubyObject[] { runtime.newString("Group"), runtime.newSymbol("name"), runtime.newSymbol("passwd"), runtime.newSymbol("gid"), runtime.newSymbol("mem") }; runtime.setGroupStruct(RubyStruct.newInstance(runtime.getStructClass(), args, Block.NULL_BLOCK)); runtime.getEtc().defineConstant("Group", runtime.getGroupStruct()); }
private static void defineGroupStruct(Ruby runtime) { IRubyObject[] args = new IRubyObject[] { runtime.newString("Group"), runtime.newSymbol("name"), runtime.newSymbol("passwd"), runtime.newSymbol("gid"), runtime.newSymbol("mem") }; runtime.setGroupStruct(RubyStruct.newInstance(runtime.getStructClass(), args, Block.NULL_BLOCK)); runtime.getEtc().defineConstant("Group", runtime.getGroupStruct()); }
private static void defineGroupStruct(Ruby runtime) { IRubyObject[] args = new IRubyObject[] { runtime.newString("Group"), runtime.newSymbol("name"), runtime.newSymbol("passwd"), runtime.newSymbol("gid"), runtime.newSymbol("mem") }; runtime.setGroupStruct(RubyStruct.newInstance(runtime.getStructClass(), args, Block.NULL_BLOCK)); if (runtime.is1_9()) { runtime.getEtc().defineConstant("Group", runtime.getGroupStruct()); } }
private static void defineGroupStruct(Ruby runtime) { IRubyObject[] args = new IRubyObject[] { runtime.newString("Group"), runtime.newSymbol("name"), runtime.newSymbol("passwd"), runtime.newSymbol("gid"), runtime.newSymbol("mem") }; runtime.setGroupStruct(RubyStruct.newInstance(runtime.getStructClass(), args, Block.NULL_BLOCK)); if (runtime.is1_9()) { runtime.getEtc().defineConstant("Group", runtime.getGroupStruct()); } }
public static void createNKF(Ruby runtime) { RubyModule nkfModule = runtime.defineModule("NKF"); for (NKFCharset nkf : NKFCharset.values()) { nkfModule.defineConstant(nkf.name(), RubyFixnum.newFixnum(runtime, nkf.getValue())); NKFCharsetMap.put(nkf.getValue(), nkf.name()); } RubyString version = runtime.newString("2.0.7 (JRuby 2007-05-11)"); RubyString nkfVersion = runtime.newString("2.0.7"); RubyString nkfDate = runtime.newString("2007-05-11"); ThreadContext context = runtime.getCurrentContext(); version.freeze(context); nkfVersion.freeze(context); nkfDate.freeze(context); nkfModule.defineAnnotatedMethods(RubyNKF.class); }