org.jruby.RubyClass.addMethod()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中org.jruby.RubyClass.addMethod方法的一些代码示例,展示了RubyClass.addMethod的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyClass.addMethod方法的具体详情如下:
包路径:org.jruby.RubyClass
类名称:RubyClass
方法名:addMethod

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;
}

相关文章

微信公众号

最新文章

更多

RubyClass类方法