Esempio n. 1
0
    public void populate(final RubyModule target, final Class clazz) {
      assert clazz == this.clazz : "populator for " + this.clazz + " used for " + clazz;

      // fallback on non-pregenerated logic
      final Ruby runtime = target.getRuntime();
      final MethodFactory methodFactory =
          MethodFactory.createFactory(runtime.getJRubyClassLoader());

      for (Map.Entry<String, List<JavaMethodDescriptor>> entry :
          clumper.getStaticAnnotatedMethods().entrySet()) {
        final String name = entry.getKey();
        final List<JavaMethodDescriptor> methods = entry.getValue();
        target.defineAnnotatedMethod(name, methods, methodFactory);
        addBoundMethodsUnlessOmited(runtime, name, methods);
      }

      for (Map.Entry<String, List<JavaMethodDescriptor>> entry :
          clumper.getAnnotatedMethods().entrySet()) {
        final String name = entry.getKey();
        final List<JavaMethodDescriptor> methods = entry.getValue();
        target.defineAnnotatedMethod(name, methods, methodFactory);
        addBoundMethodsUnlessOmited(runtime, name, methods);
      }
    }
Esempio n. 2
0
 public ReflectiveTypePopulator(Class clazz) {
   this.clazz = clazz;
   this.clumper = new RubyModule.MethodClumper();
   clumper.clump(clazz);
 }