org.jruby.Ruby.defineModule()方法的使用及代码示例

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

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

Ruby.defineModule介绍

[英]Define a new module under the Object namespace. Roughly equivalent to rb_define_module in MRI.
[中]在对象命名空间下定义一个新模块。大致相当于MRI中的rb_define_模块。

代码示例

代码示例来源:origin: bazelbuild/bazel

@Override
  public boolean basicLoad(Ruby ruby) throws IOException {
    ruby.defineModule("Google");
    RubyProtobuf.createProtobuf(ruby);
    RubyDescriptor.createRubyDescriptor(ruby);
    RubyBuilder.createRubyBuilder(ruby);
    RubyFieldDescriptor.createRubyFileDescriptor(ruby);
    RubyMessageBuilderContext.createRubyMessageBuilderContext(ruby);
    RubyEnumDescriptor.createRubyEnumDescriptor(ruby);
    RubyEnumBuilderContext.createRubyEnumBuilderContext(ruby);
    RubyDescriptorPool.createRubyDescriptorPool(ruby);
    RubyRepeatedField.createRubyRepeatedField(ruby);
    RubyFieldDescriptor.createRubyFileDescriptor(ruby);
    RubyMap.createRubyMap(ruby);
    RubyOneofDescriptor.createRubyOneofDescriptor(ruby);
    RubyOneofBuilderContext.createRubyOneofBuilderContext(ruby);
    return true;
  }
}

代码示例来源:origin: org.jruby/jruby-core

public static RubyModule createJavaArrayUtilitiesModule(Ruby runtime) {
  RubyModule javaArrayUtils = runtime.defineModule("JavaArrayUtilities");
  javaArrayUtils.defineAnnotatedMethods(JavaArrayUtilities.class);
  return javaArrayUtils;
}

代码示例来源:origin: org.jruby/jruby-complete

public static RubyModule createJavaProxyMethods(ThreadContext context) {
  RubyModule JavaProxyMethods = context.runtime.defineModule("JavaProxyMethods");
  JavaProxyMethods.defineAnnotatedMethods(JavaProxyMethods.class);
  return JavaProxyMethods;
}

代码示例来源:origin: org.jruby/jruby-complete

public void load(Ruby runtime, boolean wrap) {
    RubyModule coverage = runtime.defineModule("Coverage");
    
    coverage.defineAnnotatedMethods(CoverageModule.class);
  }
}

代码示例来源:origin: stackoverflow.com

import org.jruby.Ruby;
import org.jruby.RubyModule;
import org.jruby.runtime.load.BasicLibraryService;

import java.io.IOException;

public class GreeterService implements BasicLibraryService {

  @Override
  public boolean basicLoad(final Ruby runtime) throws IOException {
    RubyModule greeter = runtime.defineModule(Greeter.class.getSimpleName());
    greeter.defineAnnotatedMethods(Greeter.class);

    return true;
  }

}

代码示例来源:origin: org.jruby/jruby-core

public static RubyModule createEnumerableModule(Ruby runtime) {
  RubyModule enumModule = runtime.defineModule("Enumerable");
  runtime.setEnumerable(enumModule);
  enumModule.defineAnnotatedMethods(RubyEnumerable.class);
  return enumModule;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public static RubyModule createFileTestModule(Ruby runtime) {
  RubyModule fileTestModule = runtime.defineModule("FileTest");
  runtime.setFileTest(fileTestModule);
  fileTestModule.defineAnnotatedMethods(RubyFileTest.class);
  return fileTestModule;
}

代码示例来源:origin: org.jruby/jruby-complete

public static RubyModule createGCModule(Ruby runtime) {
  RubyModule result = runtime.defineModule("GC");
  runtime.setGC(result);
  
  result.defineAnnotatedMethods(RubyGC.class);
  
  return result;        
}

代码示例来源:origin: org.jruby/jruby-complete

public static RubyModule createEnumerableModule(Ruby runtime) {
  RubyModule enumModule = runtime.defineModule("Enumerable");
  runtime.setEnumerable(enumModule);
  enumModule.defineAnnotatedMethods(RubyEnumerable.class);
  return enumModule;
}

代码示例来源:origin: org.jruby/jruby-complete

public static RubyModule createFileTestModule(Ruby runtime) {
  RubyModule fileTestModule = runtime.defineModule("FileTest");
  runtime.setFileTest(fileTestModule);
  fileTestModule.defineAnnotatedMethods(RubyFileTest.class);
  return fileTestModule;
}

代码示例来源:origin: org.jruby/jruby-complete

public static RubyModule createComparable(Ruby runtime) {
  RubyModule comparableModule = runtime.defineModule("Comparable");
  runtime.setComparable(comparableModule);
  comparableModule.defineAnnotatedMethods(RubyComparable.class);
  return comparableModule;
}

代码示例来源:origin: org.jruby/jruby-complete

public static RubyModule createWarningModule(Ruby runtime) {
  RubyModule warning = runtime.defineModule("Warning");
  warning.defineAnnotatedMethods(RubyWarnings.class);
  warning.extend_object(warning);
  runtime.setWarning(warning);
  return warning;
}

代码示例来源:origin: org.jruby/jruby-complete

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

代码示例来源:origin: org.jruby/jruby-complete

public static RubyModule createJavaInterfaceTemplateModule(ThreadContext context) {
  final Ruby runtime = context.runtime;
  RubyModule JavaInterfaceTemplate = runtime.defineModule("JavaInterfaceTemplate");
  RubyClass singleton = JavaInterfaceTemplate.getSingletonClass();
  singleton.addReadAttribute(context, "java_class");
  singleton.defineAnnotatedMethods(JavaInterfaceTemplate.class);
  JavaInterfaceTemplate.defineAnnotatedMethods(JavaProxy.ClassMethods.class);
  return JavaInterfaceTemplate;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/** Create the ObjectSpace module and add it to the Ruby runtime.
 * 
 */
public static RubyModule createObjectSpaceModule(Ruby runtime) {
  RubyModule objectSpaceModule = runtime.defineModule("ObjectSpace");
  runtime.setObjectSpaceModule(objectSpaceModule);
  
  objectSpaceModule.defineAnnotatedMethods(RubyObjectSpace.class);
  if (runtime.is2_0()) {
    WeakMap.createWeakMap(runtime);
  }
  return objectSpaceModule;
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

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

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

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

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

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

代码示例来源:origin: org.jruby/jruby-complete

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

代码示例来源:origin: org.jruby/jruby-complete

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

相关文章

Ruby类方法