WRAPPEDPARAM::WrappedParam(const string& fromType, const string& fromName, vector& wrappedParams, const Type* paramType, PackageList& packageList) : mFromType(fromType), mFromName(toJavaName(fromName, true, true, false)) { wrappedParams.push_back(this); if (mFromType == "NativeLong") { mToName = mFromName + "2long"; mToType = "long"; packageList.addImport("com.sun.jna.NativeLong"); mConvertCommand = " final %FROMTYPE% %TONAME% = " "new NativeLong(%FROMNAME%);\n"; } else if (mFromType.length() > 11 && mFromType.substr(mFromType.length() - 11) == "ByReference" && paramType != NULL && paramType->isStructPtr()) { mToName = mFromName + "Ref"; mToType = mFromType.substr(0, mFromType.length() - 11); packageList.addType(paramType, false); string packageName = paramType->getImport(); packageName.erase(packageName.length() - 11); packageList.addImport(packageName); mConvertCommand = " final %FROMTYPE% %TONAME% = new %FROMTYPE%();\n"; mAfterCommand = " %FROMNAME%.setFromNative(Pointer.nativeValue(%TONAME%.getValue().getPointer()));\n"; } else if (mFromType == "$Buffer") { mFromType = "ByteBuffer"; mToName = mFromName + "2ByteBuffer"; mToType = "byte[]"; packageList.addImport("java.nio.ByteBuffer"); mConvertCommand = " final %FROMTYPE% %TONAME% = " "%FROMTYPE%.wrap(%FROMNAME%);\n"; } else if (mFromType == "$BufferWithOffset") { mFromType = "ByteBuffer"; mToName = mFromName + "2ByteBuffer"; mToType = "byte[]"; packageList.addImport("java.nio.ByteBuffer"); mConvertCommand = " final %FROMTYPE% %TONAME% = " "%FROMTYPE%.wrap(%FROMNAME%, " "%FROMNAME%Offset, %FROMNAME%Length).slice();\n"; } else if (mFromType == "$Size") { mFromType = "NativeLong"; mToName = mFromName + "2NativeLong"; mToType = ""; packageList.addImport("com.sun.jna.NativeLong"); mConvertCommand = " final %FROMTYPE% %TONAME% = " "new NativeLong(%FROMNAME%.length);\n"; } else if (mFromType == "$BufferOffset") { mFromType = ""; mFromName = mFromName + "Offset"; mToName = ""; mToType = "int"; mConvertCommand = ""; } else if (mFromType == "$BufferLength") { mFromType = "NativeLong"; mFromName = mFromName + "Length"; mToName = mFromName + "2NativeLong"; mToType = "int"; packageList.addImport("com.sun.jna.NativeLong"); mConvertCommand = " final %FROMTYPE% %TONAME% = " "new NativeLong(%FROMNAME%);\n"; } else if (mFromType == "$StructureSize") { mFromType = "NativeLong"; mToName = mFromName + "Size2NativeLong"; mToType = ""; packageList.addImport("com.sun.jna.NativeLong"); mConvertCommand = " final %FROMTYPE% %TONAME% = " "new NativeLong(%FROMNAME%.size());\n"; } else { mToName = mFromName; mToType = mFromType; } stringReplace(mConvertCommand, "FROMTYPE", mFromType); stringReplace(mConvertCommand, "FROMNAME", mFromName); stringReplace(mConvertCommand, "TONAME", mToName); stringReplace(mConvertCommand, "TOTYPE", mToType); stringReplace(mAfterCommand, "FROMTYPE", mFromType); stringReplace(mAfterCommand, "FROMNAME", mFromName); stringReplace(mAfterCommand, "TONAME", mToName); stringReplace(mAfterCommand, "TOTYPE", mToType); }