本文整理了Java中org.jruby.RubyClass.getSingletonClass
方法的一些代码示例,展示了RubyClass.getSingletonClass
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyClass.getSingletonClass
方法的具体详情如下:
包路径:org.jruby.RubyClass
类名称:RubyClass
方法名:getSingletonClass
暂无
代码示例来源:origin: org.jruby/jruby-complete
private RubyMethod getRubyMethod(ThreadContext context, String name, Class... argTypes) {
Method jmethod = getMethod(context, name, argTypes);
if (Modifier.isStatic(jmethod.getModifiers())) {
return RubyMethod.newMethod(metaClass.getSingletonClass(), CodegenUtils.prettyParams(argTypes).toString(), metaClass.getSingletonClass(), name, getMethodInvoker(jmethod), getMetaClass());
} else {
return RubyMethod.newMethod(metaClass, CodegenUtils.prettyParams(argTypes).toString(), metaClass, name, getMethodInvoker(jmethod), this);
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private RubyMethod getRubyMethod(String name, Class... argTypes) {
Method jmethod = getMethod(name, argTypes);
if (Modifier.isStatic(jmethod.getModifiers())) {
return RubyMethod.newMethod(metaClass.getSingletonClass(), CodegenUtils.prettyParams(argTypes), metaClass.getSingletonClass(), name, getMethodInvoker(jmethod), getMetaClass());
} else {
return RubyMethod.newMethod(metaClass, CodegenUtils.prettyParams(argTypes), metaClass, name, getMethodInvoker(jmethod), this);
}
}
代码示例来源:origin: org.jruby/jruby-complete
private RubyClass getSuperSingletonMetaClass() {
if (attached instanceof RubyClass) {
RubyClass superClass = ((RubyClass) attached).getSuperClass();
if (superClass != null) superClass = superClass.getRealClass();
// #<Class:BasicObject>'s singleton class == Class.singleton_class
if (superClass == null) return runtime.getClassClass().getSingletonClass();
return superClass.getMetaClass().getSingletonClass();
}
return getSuperClass().getRealClass().getMetaClass(); // NOTE: is this correct?
}
代码示例来源:origin: org.jruby/jruby-core
private RubyClass getSuperSingletonMetaClass() {
if (attached instanceof RubyClass) {
RubyClass superClass = ((RubyClass) attached).getSuperClass();
if (superClass != null) superClass = superClass.getRealClass();
// #<Class:BasicObject>'s singleton class == Class.singleton_class
if (superClass == null) return runtime.getClassClass().getSingletonClass();
return superClass.getMetaClass().getSingletonClass();
}
return getSuperClass().getRealClass().getMetaClass(); // NOTE: is this correct?
}
代码示例来源:origin: org.jruby/jruby-complete
static RubyModule getModuleForAutoload(Ruby runtime, IRubyObject recv) {
RubyModule module = recv instanceof RubyModule ? (RubyModule) recv : recv.getMetaClass().getRealClass();
if (module == runtime.getKernel()) {
// special behavior if calling Kernel.autoload directly
module = runtime.getObject().getSingletonClass();
}
return module;
}
代码示例来源:origin: org.jruby/jruby-complete
protected static void initialize(final RubyClass ConcreteJavaProxy) {
ConcreteJavaProxy.addMethod("initialize", new InitializeMethod(ConcreteJavaProxy));
// We define a custom "new" method to ensure that __jcreate! is getting called,
// so that if the user doesn't call super in their subclasses, the object will
// still get set up properly. See JRUBY-4704.
RubyClass singleton = ConcreteJavaProxy.getSingletonClass();
singleton.addMethod("new", new NewMethod(singleton));
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyClass createRationalClass(Ruby runtime) {
RubyClass rationalc = runtime.defineClass("Rational", runtime.getNumeric(), RATIONAL_ALLOCATOR);
runtime.setRational(rationalc);
rationalc.setClassIndex(ClassIndex.RATIONAL);
rationalc.setReifiedClass(RubyRational.class);
rationalc.kindOf = new RubyModule.JavaClassKindOf(RubyRational.class);
rationalc.setMarshal(RATIONAL_MARSHAL);
rationalc.defineAnnotatedMethods(RubyRational.class);
rationalc.getSingletonClass().undefineMethod("allocate");
rationalc.getSingletonClass().undefineMethod("new");
return rationalc;
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyClass createJavaProxy(ThreadContext context) {
final Ruby runtime = context.runtime;
RubyClass JavaProxy = runtime.defineClass("JavaProxy", runtime.getObject(), ALLOCATOR);
JavaProxy.getSingletonClass().addReadWriteAttribute(context, "java_class");
JavaProxy.defineAnnotatedMethods(JavaProxy.class);
JavaProxy.includeModule(runtime.getModule("JavaProxyMethods"));
return JavaProxy;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static RubyClass createBindingClass(Ruby runtime) {
RubyClass bindingClass = runtime.defineClass("Binding", runtime.getObject(), BINDING_ALLOCATOR);
runtime.setBinding(bindingClass);
bindingClass.index = ClassIndex.BINDING;
bindingClass.setReifiedClass(RubyBinding.class);
bindingClass.defineAnnotatedMethods(RubyBinding.class);
bindingClass.getSingletonClass().undefineMethod("new");
return bindingClass;
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyClass createBindingClass(Ruby runtime) {
RubyClass bindingClass = runtime.defineClass("Binding", runtime.getObject(), BINDING_ALLOCATOR);
runtime.setBinding(bindingClass);
bindingClass.setClassIndex(ClassIndex.BINDING);
bindingClass.setReifiedClass(RubyBinding.class);
bindingClass.defineAnnotatedMethods(RubyBinding.class);
bindingClass.getSingletonClass().undefineMethod("new");
return bindingClass;
}
代码示例来源:origin: org.jruby/jruby-core
public static RubyClass createBindingClass(Ruby runtime) {
RubyClass bindingClass = runtime.defineClass("Binding", runtime.getObject(), BINDING_ALLOCATOR);
runtime.setBinding(bindingClass);
bindingClass.setClassIndex(ClassIndex.BINDING);
bindingClass.setReifiedClass(RubyBinding.class);
bindingClass.defineAnnotatedMethods(RubyBinding.class);
bindingClass.getSingletonClass().undefineMethod("new");
return bindingClass;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static RubyClass createEncodingClass(Ruby runtime) {
RubyClass encodingc = runtime.defineClass("Encoding", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
runtime.setEncoding(encodingc);
encodingc.index = ClassIndex.ENCODING;
encodingc.setReifiedClass(RubyEncoding.class);
encodingc.kindOf = new RubyModule.JavaClassKindOf(RubyEncoding.class);
encodingc.getSingletonClass().undefineMethod("allocate");
encodingc.defineAnnotatedMethods(RubyEncoding.class);
return encodingc;
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyClass defineUnboundMethodClass(Ruby runtime) {
RubyClass newClass =
runtime.defineClass("UnboundMethod", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
runtime.setUnboundMethod(newClass);
newClass.setClassIndex(ClassIndex.UNBOUNDMETHOD);
newClass.setReifiedClass(RubyUnboundMethod.class);
newClass.defineAnnotatedMethods(AbstractRubyMethod.class);
newClass.defineAnnotatedMethods(RubyUnboundMethod.class);
newClass.getSingletonClass().undefineMethod("new");
return newClass;
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyClass createIntegerClass(Ruby runtime) {
RubyClass integer = runtime.defineClass("Integer", runtime.getNumeric(),
ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
runtime.setInteger(integer);
integer.setClassIndex(ClassIndex.INTEGER);
integer.setReifiedClass(RubyInteger.class);
integer.kindOf = new RubyModule.JavaClassKindOf(RubyInteger.class);
integer.getSingletonClass().undefineMethod("new");
integer.defineAnnotatedMethods(RubyInteger.class);
return integer;
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyClass createArrayJavaProxy(ThreadContext context) {
Ruby runtime = context.runtime;
RubyClass arrayJavaProxy = runtime.defineClass("ArrayJavaProxy",
runtime.getJavaSupport().getJavaProxyClass(),
ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
RubyClass singleton = arrayJavaProxy.getSingletonClass();
singleton.addMethod("new", new ArrayNewMethod(singleton, Visibility.PUBLIC));
arrayJavaProxy.defineAnnotatedMethods(ArrayJavaProxy.class);
arrayJavaProxy.includeModule(runtime.getEnumerable());
return arrayJavaProxy;
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyClass createEncodingClass(Ruby runtime) {
RubyClass encodingc = runtime.defineClass("Encoding", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
runtime.setEncoding(encodingc);
encodingc.setClassIndex(ClassIndex.ENCODING);
encodingc.setReifiedClass(RubyEncoding.class);
encodingc.kindOf = new RubyModule.JavaClassKindOf(RubyEncoding.class);
encodingc.getSingletonClass().undefineMethod("allocate");
encodingc.defineAnnotatedMethods(RubyEncoding.class);
return encodingc;
}
代码示例来源:origin: org.jruby/jruby-core
public static RubyClass defineUnboundMethodClass(Ruby runtime) {
RubyClass newClass =
runtime.defineClass("UnboundMethod", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
runtime.setUnboundMethod(newClass);
newClass.setClassIndex(ClassIndex.UNBOUNDMETHOD);
newClass.setReifiedClass(RubyUnboundMethod.class);
newClass.defineAnnotatedMethods(AbstractRubyMethod.class);
newClass.defineAnnotatedMethods(RubyUnboundMethod.class);
newClass.getSingletonClass().undefineMethod("new");
return newClass;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static void createContinuation(Ruby runtime) {
RubyClass cContinuation = runtime.defineClass("Continuation",runtime.getObject(),runtime.getObject().getAllocator());
cContinuation.index = ClassIndex.CONTINUATION;
cContinuation.setReifiedClass(RubyContinuation.class);
cContinuation.defineAnnotatedMethods(RubyContinuation.class);
cContinuation.getSingletonClass().undefineMethod("new");
runtime.setContinuation(cContinuation);
}
代码示例来源:origin: org.jruby/jruby-core
public static void createContinuation(Ruby runtime) {
RubyClass cContinuation = runtime.defineClass("Continuation",runtime.getObject(),runtime.getObject().getAllocator());
cContinuation.setClassIndex(ClassIndex.CONTINUATION);
cContinuation.setReifiedClass(RubyContinuation.class);
cContinuation.defineAnnotatedMethods(RubyContinuation.class);
cContinuation.getSingletonClass().undefineMethod("new");
runtime.setContinuation(cContinuation);
}
代码示例来源:origin: org.jruby/jruby-complete
public static void createContinuation(Ruby runtime) {
RubyClass cContinuation = runtime.defineClass("Continuation",runtime.getObject(),runtime.getObject().getAllocator());
cContinuation.setClassIndex(ClassIndex.CONTINUATION);
cContinuation.setReifiedClass(RubyContinuation.class);
cContinuation.defineAnnotatedMethods(RubyContinuation.class);
cContinuation.getSingletonClass().undefineMethod("new");
runtime.setContinuation(cContinuation);
}
内容来源于网络,如有侵权,请联系作者删除!