Examples of RubyModule


Examples of org.jruby.RubyModule

     * The arity of this function.
     */
    protected final Arity arity;
   
    public static RubyClass createInvokerClass(Ruby runtime) {
        RubyModule module = FFIProvider.getModule(runtime);
        RubyClass result = module.defineClassUnder(CLASS_NAME,
                runtime.getObject(),
                ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
        result.defineAnnotatedMethods(Invoker.class);
        result.defineAnnotatedConstants(Invoker.class);

View Full Code Here

Examples of org.jruby.RubyModule

        openFile.setPipeStream(openFile.getMainStream());
        openFile.setMode(modes.getOpenFileFlags());
        openFile.getMainStream().setSync(true);
    }
    public static RubyClass createFileDescriptorIOClass(Ruby runtime) {
        RubyModule parent = FFIProvider.getModule(runtime);
        RubyClass result = runtime.defineClassUnder(CLASS_NAME, runtime.fastGetClass("IO"),
                Allocator.INSTANCE, parent);
        result.defineAnnotatedMethods(FileDescriptorIO.class);
        result.defineAnnotatedConstants(FileDescriptorIO.class);
View Full Code Here

Examples of org.jruby.RubyModule

     */
    private static final Map<AbstractMemoryPointer, Object> pointerSet
            = new ConcurrentHashMap();
   
    public static RubyClass createMemoryPointerClass(Ruby runtime) {
        RubyModule module = FFIProvider.getModule(runtime);
        RubyClass result = module.defineClassUnder(className,
                module.getClass(AbstractMemory.ABSTRACT_MEMORY_RUBY_CLASS),
                ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
       
        result.defineAnnotatedMethods(AbstractMemoryPointer.class);
        result.defineAnnotatedConstants(AbstractMemoryPointer.class);

View Full Code Here

Examples of org.jruby.RubyModule

    protected final NativeType[] parameterTypes;
    protected final NativeType returnType;
   
    public static RubyClass createCallbackClass(Ruby runtime) {
        RubyModule module = FFIProvider.getModule(runtime);
        RubyClass result = module.defineClassUnder(CLASS_NAME,
                runtime.getObject(),
                ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
        result.defineAnnotatedMethods(Callback.class);
        result.defineAnnotatedConstants(Callback.class);
View Full Code Here

Examples of org.jruby.RubyModule

@JRubyClass(name=AbstractBuffer.ABSTRACT_BUFFER_RUBY_CLASS, parent="AbstractMemory")
abstract public class AbstractBuffer extends AbstractMemory {
    public final static String ABSTRACT_BUFFER_RUBY_CLASS = "AbstractBuffer";

    public static RubyClass createBufferClass(Ruby runtime) {
        RubyModule module = FFIProvider.getModule(runtime);
        RubyClass result = module.defineClassUnder(ABSTRACT_BUFFER_RUBY_CLASS,
                module.getClass(AbstractMemory.ABSTRACT_MEMORY_RUBY_CLASS),
                ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
       
        result.defineAnnotatedMethods(AbstractBuffer.class);
        result.defineAnnotatedConstants(AbstractBuffer.class);
View Full Code Here

Examples of org.jruby.RubyModule

        return this;
    }
   
    @JRubyMethod(name = {"to_a","to_ary"}, backtrace = true)
    public IRubyObject to_a(ThreadContext context) {
        RubyModule javaArrayUtilities = context.getRuntime().getJavaSupport().getJavaArrayUtilitiesModule();
        return RuntimeHelpers.invoke(context, javaArrayUtilities, "java_to_ruby", this);
    }
View Full Code Here

Examples of org.jruby.RubyModule

            }
            FFIProvider provider = newProvider(runtime);
            module.defineConstant("InvokerFactory", provider);
            module.defineConstant("CallbackFactory", provider);
            module.defineConstant("LastError", provider);
            RubyModule nativeType = module.defineModuleUnder("NativeType");
            for (NativeType type : NativeType.values()) {
                nativeType.defineConstant(type.name(), runtime.newFixnum(type.ordinal()));
            }
            Platform.getPlatform().init(runtime, module);
        }
    }
View Full Code Here

Examples of org.jruby.RubyModule

        public void load(final Ruby runtime, boolean wrap) throws IOException {
            if (!RubyInstanceConfig.nativeEnabled) {
                throw runtime.newLoadError("Native API access is disabled");
            }
            RubyModule ffi = runtime.defineModuleUnder("FFI", runtime.defineModule("JRuby"));
            Factory factory = Factory.getInstance();
            factory.init(runtime, ffi);
        }
View Full Code Here

Examples of org.jruby.RubyModule

@JRubyClass(name = FFIProvider.MODULE_NAME + "::" + JNAMemoryPointer.MEMORY_POINTER_NAME, parent = FFIProvider.MODULE_NAME + "::" + AbstractMemoryPointer.className)
public class JNAMemoryPointer extends AbstractMemoryPointer implements JNAMemory {
    public static final String MEMORY_POINTER_NAME = "MemoryPointer";
   
    public static RubyClass createMemoryPointerClass(Ruby runtime) {
        RubyModule module = FFIProvider.getModule(runtime);
        RubyClass result = module.defineClassUnder(MEMORY_POINTER_NAME,
                module.getClass(AbstractMemoryPointer.className),
                ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
        result.defineAnnotatedMethods(JNAMemoryPointer.class);
        result.defineAnnotatedConstants(JNAMemoryPointer.class);

        return result;
View Full Code Here

Examples of org.jruby.RubyModule

        return Node.createList(nameNode, argsNode, bodyNode);
    }
   
    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        RubyModule containingClass = context.getRubyClass();
  
        if (containingClass == runtime.getDummy()) {
            throw runtime.newTypeError("no class/module to add method");
        }
  
        String name = getName();

        if (containingClass == runtime.getObject() && name == "initialize") {
            runtime.getWarnings().warn(ID.REDEFINING_DANGEROUS, "redefining Object#initialize may cause infinite loop", "Object#initialize");
        }

        if (name == "__id__" || name == "__send__") {
            runtime.getWarnings().warn(ID.REDEFINING_DANGEROUS, "redefining `" + name + "' may cause serious problem", name);
        }

        Visibility visibility = context.getCurrentVisibility();
        if (name == "initialize" || name == "initialize_copy" || visibility == Visibility.MODULE_FUNCTION) {
            visibility = Visibility.PRIVATE;
        }
       
        scope.determineModule();
       
        // Make a nil node if no body.  Notice this is not part of AST.
        Node body = bodyNode == null ? new NilNode(getPosition()) : bodyNode;
       
        DefaultMethod newMethod = new DefaultMethod(containingClass, scope,
                body, (ArgsNode) argsNode,
                visibility, getPosition());
  
        containingClass.addMethod(name, newMethod);
  
        if (context.getCurrentVisibility() == Visibility.MODULE_FUNCTION) {
            containingClass.getSingletonClass().addMethod(name,
                    new WrapperMethod(containingClass.getSingletonClass(), newMethod, Visibility.PUBLIC));
           
            containingClass.callMethod(context, "singleton_method_added", runtime.fastNewSymbol(name));
        }
  
        // 'class << state.self' and 'class << obj' uses defn as opposed to defs
        if (containingClass.isSingleton()) {
            ((MetaClass) containingClass).getAttached().callMethod(context,
                    "singleton_method_added", runtime.fastNewSymbol(name));
        } else {
            containingClass.callMethod(context, "method_added", runtime.fastNewSymbol(name));
        }
  
        return runtime.getNil();       
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.