本文整理了Java中org.jruby.RubyClass.addMethod
方法的一些代码示例,展示了RubyClass.addMethod
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyClass.addMethod
方法的具体详情如下:
包路径:org.jruby.RubyClass
类名称:RubyClass
方法名:addMethod
暂无
代码示例来源:origin: org.jruby/jruby-complete
@Override void install(final RubyModule proxy) {
if ( Modifier.isPublic(field.getModifiers()) ) {
proxy.getSingletonClass().addMethod(name, new StaticFieldGetter(name, proxy, field));
}
}
}
代码示例来源:origin: org.jruby/jruby-complete
@Override void install(final RubyModule proxy) {
if ( Modifier.isPublic(field.getModifiers()) ) {
proxy.getSingletonClass().addMethod(name, new StaticFieldSetter(name, proxy, field));
}
}
}
代码示例来源: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-core
@Override void install(final RubyModule proxy) {
if ( Modifier.isPublic(field.getModifiers()) ) {
proxy.getSingletonClass().addMethod(name, new StaticFieldGetter(name, proxy, field));
}
}
}
代码示例来源:origin: org.jruby/jruby-core
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
private static boolean bindJavaPackageOrClassMethod(final RubyModule parentPackage,
final String name, final RubyModule packageOrClass) {
if ( parentPackage.getMetaClass().isMethodBound(name, false) ) {
return false;
}
final RubyClass singleton = parentPackage.getSingletonClass();
singleton.addMethod(name.intern(), new JavaAccessor(singleton, packageOrClass, parentPackage, name));
return true;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
void install(RubyModule proxy) {
// we don't check haveLocalMethod() here because it's not local and we know
// that we always want to go ahead and install it
RubyClass rubySingleton = proxy.getSingletonClass();
DynamicMethod method = new SingletonMethodInvoker(this.singleton, rubySingleton, methods);
rubySingleton.addMethod(name, method);
if (aliases != null && isPublic()) {
rubySingleton.defineAliases(aliases, this.name);
aliases = null;
}
}
}
代码示例来源:origin: org.jruby/jruby-complete
Function(Ruby runtime, RubyClass klass, MemoryIO address,
NativeFunctionInfo functionInfo, IRubyObject enums) {
super(runtime, klass, functionInfo.parameterTypes.length, address);
this.functionInfo = functionInfo;
function = new com.kenai.jffi.Function(address.address(),
functionInfo.jffiReturnType, functionInfo.jffiParameterTypes, functionInfo.convention);
this.enums = enums;
this.saveError = true;
// Wire up Function#call(*args) to use the super-fast native invokers
getSingletonClass().addMethod("call", createDynamicMethod(getSingletonClass()));
}
代码示例来源:origin: org.jruby/jruby-core
Function(Ruby runtime, RubyClass klass, MemoryIO address,
NativeFunctionInfo functionInfo, IRubyObject enums) {
super(runtime, klass, functionInfo.parameterTypes.length, address);
this.functionInfo = functionInfo;
function = new com.kenai.jffi.Function(address.address(),
functionInfo.jffiReturnType, functionInfo.jffiParameterTypes, functionInfo.convention);
this.enums = enums;
this.saveError = true;
// Wire up Function#call(*args) to use the super-fast native invokers
getSingletonClass().addMethod("call", createDynamicMethod(getSingletonClass()));
}
代码示例来源:origin: org.jruby/jruby-complete
Function(Ruby runtime, RubyClass klass, MemoryIO address,
Type returnType, Type[] parameterTypes, CallingConvention convention,
IRubyObject enums, boolean saveError) {
super(runtime, klass, parameterTypes.length, address);
this.functionInfo = new NativeFunctionInfo(runtime, returnType, parameterTypes, convention);
function = new com.kenai.jffi.Function(address.address(),
functionInfo.jffiReturnType, functionInfo.jffiParameterTypes, functionInfo.convention, saveError);
this.enums = enums;
this.saveError = saveError;
// Wire up Function#call(*args) to use the super-fast native invokers
getSingletonClass().addMethod("call", createDynamicMethod(getSingletonClass()));
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
Function(Ruby runtime, RubyClass klass, MemoryIO address,
Type returnType, Type[] parameterTypes, CallingConvention convention,
IRubyObject enums, boolean saveError) {
super(runtime, klass, parameterTypes.length, address);
this.functionInfo = new NativeFunctionInfo(runtime, returnType, parameterTypes, convention);
function = new com.kenai.jffi.Function(address.address(),
functionInfo.jffiReturnType, functionInfo.jffiParameterTypes, functionInfo.convention, saveError);
this.enums = enums;
this.saveError = saveError;
// Wire up Function#call(*args) to use the super-fast native invokers
getSingletonClass().addMethod("call", createDynamicMethod(getSingletonClass()));
}
代码示例来源:origin: org.jruby/jruby-core
Function(Ruby runtime, RubyClass klass, MemoryIO address,
Type returnType, Type[] parameterTypes, CallingConvention convention,
IRubyObject enums, boolean saveError) {
super(runtime, klass, parameterTypes.length, address);
this.functionInfo = new NativeFunctionInfo(runtime, returnType, parameterTypes, convention);
function = new com.kenai.jffi.Function(address.address(),
functionInfo.jffiReturnType, functionInfo.jffiParameterTypes, functionInfo.convention, saveError);
this.enums = enums;
this.saveError = saveError;
// Wire up Function#call(*args) to use the super-fast native invokers
getSingletonClass().addMethod("call", createDynamicMethod(getSingletonClass()));
}
代码示例来源:origin: org.jruby/jruby-core
@JIT
public static void defCompiledClassMethod(ThreadContext context, MethodHandle handle, IRScope method, IRubyObject obj) {
RubySymbol methodName = method.getName();
RubyClass rubyClass = checkClassForDef(context, method, obj);
// FIXME: needs checkID and proper encoding to force hard symbol
rubyClass.addMethod(methodName.idString(), new CompiledIRMethod(handle, method, Visibility.PUBLIC, rubyClass));
if (!rubyClass.isRefinement()) {
// FIXME: needs checkID and proper encoding to force hard symbol
obj.callMethod(context, "singleton_method_added", methodName);
}
}
代码示例来源:origin: org.jruby/jruby-core
@JIT
public static void defCompiledClassMethod(ThreadContext context, MethodHandle variable, MethodHandle specific, int specificArity, IRScope method, IRubyObject obj) {
RubyClass rubyClass = checkClassForDef(context, method, obj);
rubyClass.addMethod(method.getId(), new CompiledIRMethod(variable, specific, specificArity, method, Visibility.PUBLIC, rubyClass));
if (!rubyClass.isRefinement()) obj.callMethod(context, "singleton_method_added", method.getName());
}
代码示例来源:origin: org.jruby/jruby-complete
private static void addModuleMethod(RubyModule containingClass, DynamicMethod method, ThreadContext context, RubySymbol sym) {
DynamicMethod singletonMethod = method.dup();
singletonMethod.setImplementationClass(containingClass.getSingletonClass());
singletonMethod.setVisibility(Visibility.PUBLIC);
containingClass.getSingletonClass().addMethod(sym.idString(), singletonMethod);
containingClass.callMethod(context, "singleton_method_added", sym);
}
代码示例来源:origin: org.jruby/jruby-complete
@JIT
public static void defCompiledClassMethod(ThreadContext context, MethodHandle handle, IRScope method, IRubyObject obj) {
RubySymbol methodName = method.getName();
RubyClass rubyClass = checkClassForDef(context, method, obj);
// FIXME: needs checkID and proper encoding to force hard symbol
rubyClass.addMethod(methodName.idString(), new CompiledIRMethod(handle, method, Visibility.PUBLIC, rubyClass));
if (!rubyClass.isRefinement()) {
// FIXME: needs checkID and proper encoding to force hard symbol
obj.callMethod(context, "singleton_method_added", methodName);
}
}
代码示例来源:origin: org.jruby/jruby-complete
@JIT
public static void defCompiledClassMethod(ThreadContext context, MethodHandle variable, MethodHandle specific, int specificArity, IRScope method, IRubyObject obj) {
RubyClass rubyClass = checkClassForDef(context, method, obj);
rubyClass.addMethod(method.getId(), new CompiledIRMethod(variable, specific, specificArity, method, Visibility.PUBLIC, rubyClass));
if (!rubyClass.isRefinement()) obj.callMethod(context, "singleton_method_added", method.getName());
}
代码示例来源:origin: org.jruby/jruby-core
private static void addModuleMethod(RubyModule containingClass, DynamicMethod method, ThreadContext context, RubySymbol sym) {
DynamicMethod singletonMethod = method.dup();
singletonMethod.setImplementationClass(containingClass.getSingletonClass());
singletonMethod.setVisibility(Visibility.PUBLIC);
containingClass.getSingletonClass().addMethod(sym.idString(), singletonMethod);
containingClass.callMethod(context, "singleton_method_added", sym);
}
代码示例来源: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-core
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;
}
内容来源于网络,如有侵权,请联系作者删除!