Examples of JNIType


Examples of org.fusesource.hawtjni.generator.model.JNIType

        outputln("_##func");
        outputln();
    }

    boolean generateGetParameter(JNIMethod method, JNIParameter param, boolean critical, int indent) {
        JNIType paramType = param.getType32(), paramType64 = param.getType64();
        if (paramType.isPrimitive() || isSystemClass(paramType))
            return false;
        String iStr = String.valueOf(param.getParameter());
        for (int j = 0; j < indent; j++)
            output("\t");
        output("if (arg");
        output(iStr);
        output(") if ((lparg");
        output(iStr);
        output(" = ");
        if (paramType.isArray()) {
            JNIType componentType = paramType.getComponentType();
            if (componentType.isPrimitive()) {
                if( "long".equals( componentType.getName() ) && param.isPointer() ) {
                    // This case is special as we may need to do pointer conversions..
                    // if your on a 32 bit system but are keeping track of the pointers in a 64 bit long
                    output("hawtjni_malloc_pointer_array(env, arg");
                    output(iStr);
                    output(")");
                } else if (critical) {
                    if (isCPP) {
                        output("(");
                        output(componentType.getTypeSignature2(!paramType.equals(paramType64)));
                        output("*)");
                        output("env->GetPrimitiveArrayCritical(arg");
                    } else {
                        output("(*env)->GetPrimitiveArrayCritical(env, arg");
                    }
                    output(iStr);
                    output(", NULL)");
                } else {
                    if (isCPP) {
                        output("env->Get");
                    } else {
                        output("(*env)->Get");
                    }
                    output(componentType.getTypeSignature1(!paramType.equals(paramType64)));
                    if (isCPP) {
                        output("ArrayElements(arg");
                    } else {
                        output("ArrayElements(env, arg");
                    }
View Full Code Here

Examples of org.fusesource.hawtjni.generator.model.JNIType

        outputln(") == NULL) goto fail;");
        return true;
    }

    void generateSetParameter(JNIParameter param, boolean critical) {
        JNIType paramType = param.getType32(), paramType64 = param.getType64();
        if (paramType.isPrimitive() || isSystemClass(paramType))
            return;
        String iStr = String.valueOf(param.getParameter());
        if (paramType.isArray()) {
            output("\tif (arg");
            output(iStr);
            output(" && lparg");
            output(iStr);
            output(") ");
            JNIType componentType = paramType.getComponentType();
            if (componentType.isPrimitive()) {
                if( "long".equals( componentType.getName() ) && param.isPointer() ) {
                    // This case is special as we may need to do pointer conversions..
                    // if your on a 32 bit system but are keeping track of the pointers in a 64 bit long
                    output("hawtjni_free_pointer_array(env, arg");
                    output(iStr);
                } else if (critical) {
                    if (isCPP) {
                        output("env->ReleasePrimitiveArrayCritical(arg");
                    } else {
                        output("(*env)->ReleasePrimitiveArrayCritical(env, arg");
                    }
                    output(iStr);
                } else {
                    if (isCPP) {
                        output("env->Release");
                    } else {
                        output("(*env)->Release");
                    }
                    output(componentType.getTypeSignature1(!paramType.equals(paramType64)));
                    if (isCPP) {
                        output("ArrayElements(arg");
                    } else {
                        output("ArrayElements(env, arg");
                    }
View Full Code Here

Examples of org.fusesource.hawtjni.generator.model.JNIType

    boolean generateLocalVars(JNIMethod method, List<JNIParameter> params, JNIType returnType, JNIType returnType64) {
        boolean needsReturn = enterExitMacro;
        for (int i = 0; i < params.size(); i++) {
            JNIParameter param = params.get(i);
            JNIType paramType = param.getType32(), paramType64 = param.getType64();
            if (paramType.isPrimitive() || isSystemClass(paramType))
                continue;
            output("\t");
            if (paramType.isArray()) {
                JNIType componentType = paramType.getComponentType();
                if( "long".equals( componentType.getName() ) && param.isPointer() ) {
                    output("void **lparg" + i+"=NULL;");
                } else if (componentType.isPrimitive()) {
                    output(componentType.getTypeSignature2(!paramType.equals(paramType64)));
                    output(" *lparg" + i);
                    output("=NULL;");
                } else {
                    throw new Error("not done");
                }
View Full Code Here

Examples of org.fusesource.hawtjni.generator.model.JNIType

                    if (index != -1)
                        cast = cast.substring(0, index).trim();
                }
                output(cast);
            } else {
                JNIType paramType = param.getType32(), paramType64 = param.getType64();
                output(paramType.getTypeSignature4(!paramType.equals(paramType64), isStruct));
            }
        }
        output("))");
        output("fp");
        output(")");
View Full Code Here

Examples of org.fusesource.hawtjni.generator.model.JNIType

                    output("NULL");
                } else {
                    if( "org.fusesource.hawtjni.runtime.JNIEnv".equals(param.getTypeClass().getName()) ) {
                        output("env");
                    } else {
                        JNIType paramType = param.getType32();
                        if (!paramType.isPrimitive() && !isSystemClass(paramType))
                            output("lp");
                        output("arg" + i);
                    }
                }
                if (param.getFlag(ArgFlag.CS_OBJECT))
View Full Code Here

Examples of org.fusesource.hawtjni.generator.model.JNIType

            output(" (STDMETHODCALLTYPE *)(");
            for (int i = 1; i < params.size(); i++) {
                if (i != 1)
                    output(", ");
                JNIParameter param = params.get(i);
                JNIType paramType = param.getType32(), paramType64 = param.getType64();
                output(paramType.getTypeSignature4(!paramType.equals(paramType64), false));
            }
            output("))(*(");
            JNIType paramType = params.get(1).getType32(), paramType64 = params.get(1).getType64();
            output(paramType.getTypeSignature4(!paramType.equals(paramType64), false));
            output(" **)arg1)[arg0])");
            paramStart = 1;
        } else if (method.getFlag(MethodFlag.CPP_METHOD) || method.getFlag(MethodFlag.SETTER) || method.getFlag(MethodFlag.GETTER) || method.getFlag(MethodFlag.ADDER)) {

            String[] parts = getNativeNameParts(method);
            String className = parts[0];
            String methodName = parts[1];

            if (method.getFlag(MethodFlag.CS_OBJECT)) {
                output("TO_HANDLE(");
            }
            output("(");
            if( params.isEmpty() ) {
                throw new Error(String.format("C++ bound method '%s' missing the 'this' parameter", method.getDeclaringClass().getSimpleName()+"."+method.getName()));
            }
            JNIParameter param = params.get(0);
            if (param.getFlag(ArgFlag.BY_VALUE))
                output("*");
            String cast = param.getCast();
            if (cast.length() != 0 && !cast.equals("()")) {
                output(cast);
                if( param.isPointer() ) {
                    output("(intptr_t)");
                }
            } else {
                output("("+className+" *)(intptr_t)");
            }
            if (param.getFlag(ArgFlag.CS_OBJECT)) {
                output("TO_OBJECT(");
            }
            output("arg0");
            if (param.getFlag(ArgFlag.CS_OBJECT)) {
                output(")");
            }
            output(")->");
            output(methodName);
            paramStart = 1;
        } else if (method.getFlag(MethodFlag.CS_NEW)) {
            output("TO_HANDLE(gcnew ");
            String accessor = method.getAccessor();
            if (accessor.length() != 0) {
                output(accessor);
            } else {
                JNIClass dc = method.getDeclaringClass();
                if( dc.getFlag(ClassFlag.CPP) || dc.getFlag(ClassFlag.STRUCT) ) {
                    output(dc.getNativeName());
                } else {
                    int index = -1;
                    if ((index = name.indexOf('_')) != -1) {
                        output(name.substring(index + 1));
                    } else {
                        output(name);
                    }
                }
            }
        } else if (method.getFlag(MethodFlag.CPP_NEW)) {
            if (method.getFlag(MethodFlag.CS_OBJECT)) {
                output("TO_HANDLE(");
            }
            output("new ");
            String accessor = method.getAccessor();
            if (accessor.length() != 0) {
                output(accessor);
            } else {

                JNIClass dc = method.getDeclaringClass();
                if( dc.getFlag(ClassFlag.CPP) ) {
                    output(method.getDeclaringClass().getNativeName());
                } else {
                    int index = -1;
                    if ((index = name.indexOf('_')) != -1) {
                        output(name.substring(index+1));
                    } else {
                        output(name);
                    }
                }

            }
        } else if (method.getFlag(MethodFlag.CPP_DELETE)) {
            String[] parts = getNativeNameParts(method);
            String className = parts[0];

            output("delete ");
            JNIParameter param = params.get(0);
            String cast = param.getCast();
            if (cast.length() != 0 && !cast.equals("()")) {
                output(cast);
                if( param.isPointer() ) {
                    output("(intptr_t)");
                }
            } else {
                output("("+className+" *)(intptr_t)");
            }
            outputln("arg0;");
            return;
        } else {
            if (method.getFlag(MethodFlag.CS_OBJECT)) {
                output("TO_HANDLE(");
            }
            if (method.getFlag(MethodFlag.CAST)) {
                output("((");
                String returnCast = returnType.getTypeSignature2(!returnType.equals(returnType64));
                if (name.equals("objc_msgSend_bool") && returnCast.equals("jboolean")) {
                    returnCast = "BOOL";
                }
                output(returnCast);
                output(" (*)(");
                for (int i = 0; i < params.size(); i++) {
                    if (i != 0)
                        output(", ");
                    JNIParameter param = params.get(i);
                    String cast = param.getCast();
                    if (cast.length() != 0 && !cast.equals("()") ) {
                        if (cast.startsWith("("))
                            cast = cast.substring(1);
                        if (cast.endsWith(")"))
                            cast = cast.substring(0, cast.length() - 1);
                        output(cast);
                    } else {
                        JNIType paramType = param.getType32(), paramType64 = param.getType64();
                        if (!(paramType.isPrimitive() || paramType.isArray())) {
                            if (param.getTypeClass().getFlag(ClassFlag.STRUCT) && !param.getTypeClass().getFlag(ClassFlag.TYPEDEF)) {
                                output("struct ");
                            }
                        }
                        output(paramType.getTypeSignature4(!paramType.equals(paramType64), param.getFlag(ArgFlag.BY_VALUE)));
                    }
                }
                output("))");
            }
            String accessor = method.getAccessor();
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.