Package org.jruby.ext.ffi

Examples of org.jruby.ext.ffi.Type$Builtin


    /**
     * Initialises the internal Javascript engine factory.
     */
    public JSEvaluator() {
        factory = new ScriptEngineManager();
        factory.put("_builtin", new Builtin());
    }
View Full Code Here


        //
        FastIntMethodFactory fastIntFactory = FastIntMethodFactory.getFactory();
        boolean canBeFastInt = parameterTypes.length <= 3
                && fastIntFactory.isFastIntResult(returnType) && convention == CallingConvention.DEFAULT;
        for (int i = 0; canBeFastInt && i < parameterTypes.length; ++i) {
            Type t = parameterTypes[i] instanceof MappedType
                    ? ((MappedType) parameterTypes[i]).getRealType()
                    : parameterTypes[i];

            if (!(t instanceof Type.Builtin) || marshallers[i].requiresPostInvoke()) {
                canBeFastInt = false;
            } else {
                switch (t.getNativeType()) {
                    case POINTER:
                    case BUFFER_IN:
                    case BUFFER_OUT:
                    case BUFFER_INOUT:
                        canBeFastInt = Platform.getPlatform().addressSize() == 32;
View Full Code Here

        if (!(args[2] instanceof Type)) {
            throw context.getRuntime().newTypeError("Invalid return type " + args[2]);
        }
        Pointer ptr = (Pointer) args[0];
        RubyArray paramTypes = (RubyArray) args[1];
        Type returnType = (Type) args[2];

        // Get the convention from the options hash
        String convention = "default";
        IRubyObject enums = null;
        if (args[3] instanceof RubyHash) {
View Full Code Here

        DirectMemoryIO fptr = null;
        RubyHash options = null;
        Object proc = null;
        int optionsIndex = 2;

        Type returnType = FFIUtil.resolveType(context, args[0]);

        if (!(args[1] instanceof RubyArray)) {
            throw context.getRuntime().newTypeError("Invalid parameter array "
                    + args[1].getMetaClass().getName() + " (expected Array)");
        }
View Full Code Here

       
        if (!(args[1] instanceof Type)) {
            throw context.getRuntime().newTypeError("invalid return type");
        }
       
        final Type returnType = (Type) args[1];
        final CallingConvention conv = "stdcall".equals(args[2].toString())
                ? CallingConvention.STDCALL : CallingConvention.DEFAULT;

        FunctionInvoker functionInvoker = DefaultMethodFactory.getFunctionInvoker(returnType);
        return new VariadicInvoker(context.getRuntime(), klass, address,
View Full Code Here

        IRubyObject[] params = ((RubyArray) paramsArg).toJavaArrayMaybeUnsafe();
        com.kenai.jffi.Type[] ffiParamTypes = new com.kenai.jffi.Type[types.length];
        ParameterMarshaller[] marshallers = new ParameterMarshaller[types.length];

        for (int i = 0; i < types.length; ++i) {
            Type type = (Type) types[i];
            switch (NativeType.valueOf(type)) {
                case CHAR:
                case SHORT:
                case INT:
                    ffiParamTypes[i] = com.kenai.jffi.Type.SINT32;
View Full Code Here

    private static ObjectParameterInfo getParameterInfo(Signature signature, int i) {
        if (signature.getParameterCount() <= i) {
            return null;
        }

        Type type = signature.getParameterType(i);
        int flags = 0;
        NativeType nativeType  = type instanceof MappedType
                ? ((MappedType) type).getRealType().getNativeType() : type.getNativeType();

        switch (nativeType) {
            case BUFFER_IN:
            case STRING:
            case TRANSIENT_STRING:
View Full Code Here

   
    JITHandle getHandle(Signature signature) {
       
        boolean hasResultConverter = !(signature.getResultType() instanceof Type.Builtin);
        NativeType nativeResultType;
        Type resultType = signature.getResultType();
       
        if (resultType instanceof Type.Builtin || resultType instanceof CallbackInfo) {
            nativeResultType = resultType.getNativeType();
       
        } else if (resultType instanceof MappedType) {
            nativeResultType = ((MappedType) resultType).getRealType().getNativeType();
       
        } else {
            return failedHandle;
        }

        NativeType[] nativeParameterTypes = new NativeType[signature.getParameterCount()];
        boolean[] hasParameterConverter = new boolean[signature.getParameterCount()];
       
        for (int i = 0; i < hasParameterConverter.length; i++) {
            Type parameterType = signature.getParameterType(i);
            if (parameterType instanceof Type.Builtin || parameterType instanceof CallbackInfo) {
                nativeParameterTypes[i] = parameterType.getNativeType();
       
            } else if (parameterType instanceof MappedType) {
                nativeParameterTypes[i] = ((MappedType) parameterType).getRealType().getNativeType();
       
            } else {
View Full Code Here

        if (!(args[2] instanceof Type)) {
            throw context.runtime.newTypeError("Invalid return type " + args[2]);
        }
        Pointer ptr = (Pointer) args[0];
        RubyArray paramTypes = (RubyArray) args[1];
        Type returnType = (Type) args[2];

        // Get the convention from the options hash
        String convention = "default";
        IRubyObject enums = null;
        if (args[3] instanceof RubyHash) {
View Full Code Here

        DirectMemoryIO fptr = null;
        RubyHash options = null;
        Object proc = null;
        int optionsIndex = 2;

        Type returnType = org.jruby.ext.ffi.Util.findType(context, args[0]);

        if (!(args[1] instanceof RubyArray)) {
            throw context.runtime.newTypeError("Invalid parameter array "
                    + args[1].getMetaClass().getName() + " (expected Array)");
        }
View Full Code Here

TOP

Related Classes of org.jruby.ext.ffi.Type$Builtin

Copyright © 2018 www.massapicom. 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.