public static void createRubyMessageBuilderContext(Ruby runtime) { RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf"); RubyClass cMessageBuilderContext = protobuf.defineClassUnder("MessageBuilderContext", runtime.getObject(), new ObjectAllocator() { @Override public IRubyObject allocate(Ruby runtime, RubyClass klazz) { return new RubyMessageBuilderContext(runtime, klazz); } }); cMessageBuilderContext.defineAnnotatedMethods(RubyMessageBuilderContext.class); }
public static void createRubyFileDescriptor(Ruby runtime) { RubyModule mProtobuf = runtime.getClassFromPath("Google::Protobuf"); RubyClass cFieldDescriptor = mProtobuf.defineClassUnder("FieldDescriptor", runtime.getObject(), new ObjectAllocator() { @Override public IRubyObject allocate(Ruby runtime, RubyClass klazz) { return new RubyFieldDescriptor(runtime, klazz); } }); cFieldDescriptor.defineAnnotatedMethods(RubyFieldDescriptor.class); }
public static void createRubyEnumBuilderContext(Ruby runtime) { RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf"); RubyClass cMessageBuilderContext = protobuf.defineClassUnder("EnumBuilderContext", runtime.getObject(), new ObjectAllocator() { @Override public IRubyObject allocate(Ruby runtime, RubyClass klazz) { return new RubyEnumBuilderContext(runtime, klazz); } }); cMessageBuilderContext.defineAnnotatedMethods(RubyEnumBuilderContext.class); }
public static void createRubyBuilder(Ruby runtime) { RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf"); RubyClass cBuilder = protobuf.defineClassUnder("Builder", runtime.getObject(), new ObjectAllocator() { @Override public IRubyObject allocate(Ruby runtime, RubyClass klazz) { return new RubyBuilder(runtime, klazz); } }); cBuilder.defineAnnotatedMethods(RubyBuilder.class); }
public static void createRubyOneofBuilderContext(Ruby runtime) { RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf"); RubyModule internal = protobuf.defineModuleUnder("Internal"); RubyClass cRubyOneofBuidlerContext = internal.defineClassUnder("OneofBuilderContext", runtime.getObject(), new ObjectAllocator() { @Override public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) { return new RubyOneofBuilderContext(ruby, rubyClass); } }); cRubyOneofBuidlerContext.defineAnnotatedMethods(RubyOneofBuilderContext.class); }
public static void createRubyDescriptorPool(Ruby runtime) { RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf"); RubyClass cDescriptorPool = protobuf.defineClassUnder("DescriptorPool", runtime.getObject(), new ObjectAllocator() { @Override public IRubyObject allocate(Ruby runtime, RubyClass klazz) { return new RubyDescriptorPool(runtime, klazz); } }); cDescriptorPool.defineAnnotatedMethods(RubyDescriptorPool.class); descriptorPool = (RubyDescriptorPool) cDescriptorPool.newInstance(runtime.getCurrentContext(), Block.NULL_BLOCK); }
public static void createRubyOneofDescriptor(Ruby runtime) { RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf"); RubyClass cRubyOneofDescriptor = protobuf.defineClassUnder("OneofDescriptor", runtime.getObject(), new ObjectAllocator() { @Override public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) { return new RubyOneofDescriptor(ruby, rubyClass); } }); cRubyOneofDescriptor.defineAnnotatedMethods(RubyOneofDescriptor.class); cRubyOneofDescriptor.includeModule(runtime.getEnumerable()); }
public static void createRubyDescriptor(Ruby runtime) { RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf"); RubyClass cDescriptor = protobuf.defineClassUnder("Descriptor", runtime.getObject(), new ObjectAllocator() { @Override public IRubyObject allocate(Ruby runtime, RubyClass klazz) { return new RubyDescriptor(runtime, klazz); } }); cDescriptor.includeModule(runtime.getEnumerable()); cDescriptor.defineAnnotatedMethods(RubyDescriptor.class); }
public static void createRubyEnumDescriptor(Ruby runtime) { RubyModule mProtobuf = runtime.getClassFromPath("Google::Protobuf"); RubyClass cEnumDescriptor = mProtobuf.defineClassUnder("EnumDescriptor", runtime.getObject(), new ObjectAllocator() { @Override public IRubyObject allocate(Ruby runtime, RubyClass klazz) { return new RubyEnumDescriptor(runtime, klazz); } }); cEnumDescriptor.includeModule(runtime.getEnumerable()); cEnumDescriptor.defineAnnotatedMethods(RubyEnumDescriptor.class); }
public static void createRubyRepeatedField(Ruby runtime) { RubyModule mProtobuf = runtime.getClassFromPath("Google::Protobuf"); RubyClass cRepeatedField = mProtobuf.defineClassUnder("RepeatedField", runtime.getObject(), new ObjectAllocator() { @Override public IRubyObject allocate(Ruby runtime, RubyClass klazz) { return new RubyRepeatedField(runtime, klazz); } }); cRepeatedField.defineAnnotatedMethods(RubyRepeatedField.class); cRepeatedField.includeModule(runtime.getEnumerable()); }
public static void createRubyMap(Ruby runtime) { RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf"); RubyClass cMap = protobuf.defineClassUnder("Map", runtime.getObject(), new ObjectAllocator() { @Override public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) { return new RubyMap(ruby, rubyClass); } }); cMap.includeModule(runtime.getEnumerable()); cMap.defineAnnotatedMethods(RubyMap.class); }
public static RubyClass defineProcessorClass(Ruby rubyRuntime, String baseClassName, JRubyAsciidoctorObjectAllocator objectAllocator) { RubyClass baseClass = getExtensionBaseClass(rubyRuntime, baseClassName); final String rubyClassName = "JavaExtensionProxy_" + extensionCounter.getAndIncrement(); return getExtensionsModule(baseClass.getRuntime()).defineClassUnder(rubyClassName, baseClass, objectAllocator); }
public static RubyClass createVariadicInvokerClass(Ruby runtime, RubyModule module) { RubyClass result = module.defineClassUnder("VariadicInvoker", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); result.defineAnnotatedMethods(VariadicInvoker.class); result.defineAnnotatedConstants(VariadicInvoker.class); return result; }
public static RubyClass createJavaProxyMethodClass(Ruby runtime, RubyModule Java) { RubyClass JavaProxyMethod = Java.defineClassUnder("JavaProxyMethod", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); JavaProxyReflectionObject.registerRubyMethods(runtime, JavaProxyMethod); JavaProxyMethod.defineAnnotatedMethods(ProxyMethodImpl.class); return JavaProxyMethod; }
static void createWeakMap(Ruby runtime) { RubyClass weakMap = runtime.getObjectSpaceModule().defineClassUnder("WeakMap", runtime.getObject(), new ObjectAllocator() { public IRubyObject allocate(Ruby runtime, RubyClass klazz) { return new WeakMap(runtime, klazz); } }); weakMap.defineAnnotatedMethods(WeakMap.class); }
public static RubyClass createStructByValueClass(Ruby runtime, RubyModule ffiModule) { final RubyClass Type = ffiModule.getClass("Type"); RubyClass sbvClass = ffiModule.defineClassUnder("StructByValue", Type, ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); sbvClass.defineAnnotatedMethods(StructByValue.class); sbvClass.defineAnnotatedConstants(StructByValue.class); Type.setConstant("Struct", sbvClass); return sbvClass; }
public static RubyClass createInvokerClass(Ruby runtime, RubyModule module) { RubyClass result = module.defineClassUnder("Invoker", module.getClass("AbstractInvoker"), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); result.defineAnnotatedMethods(AbstractInvoker.class); result.defineAnnotatedMethods(JFFIInvoker.class); result.defineAnnotatedConstants(JFFIInvoker.class); return result; }
public static RubyClass createEnumsClass(Ruby runtime, RubyModule ffiModule) { RubyClass enumsClass = ffiModule.defineClassUnder("Enums", runtime.getObject(), Allocator.INSTANCE); enumsClass.defineAnnotatedMethods(Enums.class); enumsClass.defineAnnotatedConstants(Enums.class); enumsClass.includeModule(ffiModule.getConstant("DataConverter")); return enumsClass; }
public static RubyClass createStructByReferenceClass(Ruby runtime, RubyModule ffiModule) { RubyClass sbrClass = ffiModule.defineClassUnder("StructByReference", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); sbrClass.defineAnnotatedMethods(StructByReference.class); sbrClass.defineAnnotatedConstants(StructByReference.class); sbrClass.includeModule(ffiModule.getConstant("DataConverter")); return sbrClass; }
public static void createDigestRMD160(Ruby runtime) { runtime.getLoadService().require("digest"); if(provider == null) { throw runtime.newLoadError("RMD160 not supported without BouncyCastle"); } RubyModule Digest = runtime.getModule("Digest"); RubyClass Base = Digest.getClass("Base"); RubyClass RMD160 = Digest.defineClassUnder("RMD160", Base, Base.getAllocator()); RMD160.setInternalVariable("metadata", new Metadata("RIPEMD160", 64)); }