本文整理了Java中org.jruby.RubyClass.setConstant
方法的一些代码示例,展示了RubyClass.setConstant
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyClass.setConstant
方法的具体详情如下:
包路径:org.jruby.RubyClass
类名称:RubyClass
方法名:setConstant
暂无
代码示例来源:origin: org.jruby/jruby-core
static void createTCPSocket(Ruby runtime) {
RubyClass rb_cTCPSocket = runtime.defineClass("TCPSocket", runtime.getClass("IPSocket"), TCPSOCKET_ALLOCATOR);
rb_cTCPSocket.defineAnnotatedMethods(RubyTCPSocket.class);
runtime.getObject().setConstant("TCPsocket",rb_cTCPSocket);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
static void createUNIXSocket(Ruby runtime) {
RubyClass rb_cUNIXSocket = runtime.defineClass("UNIXSocket", runtime.getClass("BasicSocket"), UNIXSOCKET_ALLOCATOR);
runtime.getObject().setConstant("UNIXsocket", rb_cUNIXSocket);
rb_cUNIXSocket.defineAnnotatedMethods(RubyUNIXSocket.class);
}
代码示例来源:origin: org.jruby/jruby-complete
static void createUNIXServer(Ruby runtime) {
RubyClass rb_cUNIXServer = runtime.defineClass("UNIXServer", runtime.getClass("UNIXSocket"), UNIXSERVER_ALLOCATOR);
runtime.getObject().setConstant("UNIXserver", rb_cUNIXServer);
rb_cUNIXServer.defineAnnotatedMethods(RubyUNIXServer.class);
}
代码示例来源:origin: org.jruby/jruby-complete
static void createTCPSocket(Ruby runtime) {
RubyClass rb_cTCPSocket = runtime.defineClass("TCPSocket", runtime.getClass("IPSocket"), TCPSOCKET_ALLOCATOR);
rb_cTCPSocket.defineAnnotatedMethods(RubyTCPSocket.class);
runtime.getObject().setConstant("TCPsocket",rb_cTCPSocket);
}
代码示例来源:origin: org.jruby/jruby-complete
static void createTCPServer(Ruby runtime) {
RubyClass rb_cTCPServer = runtime.defineClass(
"TCPServer", runtime.getClass("TCPSocket"), TCPSERVER_ALLOCATOR);
rb_cTCPServer.defineAnnotatedMethods(RubyTCPServer.class);
runtime.getObject().setConstant("TCPserver",rb_cTCPServer);
}
代码示例来源:origin: org.jruby/jruby-complete
static RubyClass createDateClass(Ruby runtime) {
RubyClass Date = runtime.defineClass("Date", runtime.getObject(), ALLOCATOR);
Date.setReifiedClass(RubyDate.class);
Date.includeModule(runtime.getComparable());
Date.defineAnnotatedMethods(RubyDate.class);
Date.setConstant("ITALY", runtime.newFixnum(ITALY));
Date.setConstant("ENGLAND", runtime.newFixnum(ENGLAND));
return Date;
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyClass createStructByValueClass(Ruby runtime, RubyModule ffiModule) {
final RubyClass Type = ffiModule.getClass("Type");
RubyClass sbvClass = ffiModule.defineClassUnder("StructByValue", Type, ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
sbvClass.defineAnnotatedMethods(StructByValue.class);
sbvClass.defineAnnotatedConstants(StructByValue.class);
Type.setConstant("Struct", sbvClass);
return sbvClass;
}
代码示例来源:origin: org.jruby/jruby-complete
static void createUNIXSocket(Ruby runtime) {
RubyClass rb_cUNIXSocket = runtime.defineClass("UNIXSocket", runtime.getClass("BasicSocket"), UNIXSOCKET_ALLOCATOR);
runtime.getObject().setConstant("UNIXsocket", rb_cUNIXSocket);
rb_cUNIXSocket.defineAnnotatedMethods(RubyUNIXSocket.class);
}
代码示例来源:origin: org.jruby/jruby-complete
static void createIPSocket(Ruby runtime) {
RubyClass rb_cIPSocket = runtime.defineClass("IPSocket", runtime.getClass("BasicSocket"), IPSOCKET_ALLOCATOR);
rb_cIPSocket.defineAnnotatedMethods(RubyIPSocket.class);
rb_cIPSocket.undefineMethod("initialize");
runtime.getObject().setConstant("IPsocket",rb_cIPSocket);
}
代码示例来源:origin: org.jruby/jruby-complete
private static Mutex getMutexForThreadExclusive(ThreadContext context, RubyClass recv) {
Mutex mutex = (Mutex) recv.getConstantNoConstMissing(MUTEX_FOR_THREAD_EXCLUSIVE, false, false);
if (mutex != null) return mutex;
synchronized (recv) {
mutex = (Mutex) recv.getConstantNoConstMissing(MUTEX_FOR_THREAD_EXCLUSIVE, false, false);
if (mutex == null) {
mutex = Mutex.newInstance(context, context.runtime.getThread().getClass("Mutex"), NULL_ARRAY, Block.NULL_BLOCK);
recv.setConstant(MUTEX_FOR_THREAD_EXCLUSIVE, mutex, true);
}
return mutex;
}
}
代码示例来源:origin: org.jruby/jruby-complete
@Override
public void load(final Ruby runtime, boolean wrap) {
RubyRipper.initRipper(runtime);
runtime.getClass("Ripper").setConstant("Version",
runtime.newString(RIPPER_VERSION));
runtime.defineGlobalConstant("SCRIPT_LINES__", runtime.getNil());
}
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyClass createBignumClass(Ruby runtime) {
RubyClass bignum = runtime.getInteger();
runtime.getObject().setConstant("Bignum", bignum);
runtime.getObject().deprecateConstant(runtime, "Bignum");
runtime.setBignum(bignum);
return bignum;
}
代码示例来源:origin: org.jruby/jruby-core
public static RubyClass createBignumClass(Ruby runtime) {
RubyClass bignum = runtime.getInteger();
runtime.getObject().setConstant("Bignum", bignum);
runtime.getObject().deprecateConstant(runtime, "Bignum");
runtime.setBignum(bignum);
return bignum;
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyClass createFixnumClass(Ruby runtime) {
RubyClass fixnum = runtime.getInteger();
runtime.getObject().setConstant("Fixnum", fixnum);
runtime.getObject().deprecateConstant(runtime, "Fixnum");
runtime.setFixnum(fixnum);
for (int i = 0; i < runtime.fixnumCache.length; i++) {
runtime.fixnumCache[i] = new RubyFixnum(fixnum, i - CACHE_OFFSET);
}
return fixnum;
}
代码示例来源:origin: org.jruby/jruby-complete
public static void setup(Ruby runtime) {
RubyClass cSizedQueue = runtime.getThread().defineClassUnder("SizedQueue", runtime.getClass("Queue"), new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new SizedQueue(runtime, klass);
}
});
cSizedQueue.setReifiedClass(SizedQueue.class);
cSizedQueue.defineAnnotatedMethods(SizedQueue.class);
runtime.getObject().setConstant("SizedQueue", cSizedQueue);
}
代码示例来源:origin: org.jruby/jruby-core
public static RubyClass createFixnumClass(Ruby runtime) {
RubyClass fixnum = runtime.getInteger();
runtime.getObject().setConstant("Fixnum", fixnum);
runtime.getObject().deprecateConstant(runtime, "Fixnum");
runtime.setFixnum(fixnum);
for (int i = 0; i < runtime.fixnumCache.length; i++) {
runtime.fixnumCache[i] = new RubyFixnum(fixnum, i - CACHE_OFFSET);
}
return fixnum;
}
代码示例来源:origin: org.jruby/jruby-complete
public static void setup(Ruby runtime) {
RubyClass cMutex = runtime.getThread().defineClassUnder("Mutex", runtime.getObject(), new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new Mutex(runtime, klass);
}
});
cMutex.setReifiedClass(Mutex.class);
cMutex.defineAnnotatedMethods(Mutex.class);
runtime.getObject().setConstant("Mutex", cMutex);
}
代码示例来源:origin: org.jruby/jruby-complete
static void createUDPSocket(Ruby runtime) {
RubyClass rb_cUDPSocket = runtime.defineClass("UDPSocket", runtime.getClass("IPSocket"), UDPSOCKET_ALLOCATOR);
rb_cUDPSocket.includeModule(runtime.getClass("Socket").getConstant("Constants"));
rb_cUDPSocket.defineAnnotatedMethods(RubyUDPSocket.class);
runtime.getObject().setConstant("UDPsocket", rb_cUDPSocket);
}
代码示例来源:origin: org.jruby/jruby-complete
public static void setup(Ruby runtime) {
RubyClass cConditionVariable = runtime.getThread().defineClassUnder("ConditionVariable", runtime.getObject(), new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new ConditionVariable(runtime, klass);
}
});
cConditionVariable.undefineMethod("initialize_copy");
cConditionVariable.setReifiedClass(ConditionVariable.class);
cConditionVariable.defineAnnotatedMethods(ConditionVariable.class);
runtime.getObject().setConstant("ConditionVariable", cConditionVariable);
}
代码示例来源:origin: org.jruby/jruby-complete
@SuppressWarnings("deprecation")
public static RubyClass createRandomClass(Ruby runtime) {
RubyClass randomClass = runtime
.defineClass("Random", runtime.getObject(), RANDOM_ALLOCATOR);
randomClass.defineAnnotatedMethods(RubyRandom.class);
RubyRandom defaultRand = new RubyRandom(runtime, randomClass);
defaultRand.random = new RandomType(randomSeed(runtime));
randomClass.setConstant("DEFAULT", defaultRand);
runtime.setDefaultRand(defaultRand.random);
runtime.setRandomClass(randomClass);
return randomClass;
}
内容来源于网络,如有侵权,请联系作者删除!