| 1317 | } |
| 1318 | |
| 1319 | void write_native_operation(UTL_ScopedName *name, const char *javaStub, |
| 1320 | AST_Operation *op, bool local) |
| 1321 | { |
| 1322 | const char *opname = op->local_name()->get_string(); |
| 1323 | string ret = "void", |
| 1324 | cxx = idl_mapping_jni::scoped(name), |
| 1325 | fnName = jni_function_name(javaStub, opname), |
| 1326 | retval, retconv, ret_exception; |
| 1327 | // for the JavaPeer (local interfaces only) |
| 1328 | string ret_jsig = "V", jniFn = "Void", tao_ret = "void", |
| 1329 | tao_retval, tao_retconv, array_cast; |
| 1330 | AST_Type* op_return_type = op->return_type(); |
| 1331 | |
| 1332 | if (!op->void_return_type()) { |
| 1333 | ret = idl_mapping_jni::type(op_return_type); |
| 1334 | retval = idl_mapping_jni::taoType(op_return_type); |
| 1335 | tao_ret = idl_mapping_jni::taoParam(op_return_type, |
| 1336 | AST_Argument::dir_IN /*ignored*/, true); |
| 1337 | tao_retval = ret; |
| 1338 | jniFn = idl_mapping_jni::jniFnName(op_return_type); |
| 1339 | ret_jsig = idl_mapping_jni::jvmSignature(op_return_type); |
| 1340 | string suffix, extra_type, extra_init, extra_retn; |
| 1341 | bool is_array = isArray(op_return_type), |
| 1342 | is_objref = isObjref(op_return_type); |
| 1343 | |
| 1344 | if (is_array || op_return_type->size_type() != AST_Type::FIXED) { |
| 1345 | if (!is_array && !is_objref) suffix = ".in ()"; |
| 1346 | |
| 1347 | if (is_array) { |
| 1348 | extra_type = "_forany"; |
| 1349 | retval = append_forany(retval); |
| 1350 | } else if (isSSU(op_return_type)) { |
| 1351 | extra_type = "_var"; |
| 1352 | extra_init = " = new " + retval; |
| 1353 | retval = append_var(retval); |
| 1354 | } |
| 1355 | |
| 1356 | extra_retn = "._retn ()"; |
| 1357 | } |
| 1358 | |
| 1359 | if (ret.size() > 5 && ret.substr(ret.size() - 5) == "Array") { |
| 1360 | array_cast = "static_cast<" + ret + "> ("; |
| 1361 | } |
| 1362 | |
| 1363 | retval += " _c_ret = "; |
| 1364 | tao_retval += " _j_ret = "; |
| 1365 | retconv = " return _c_ret;\n"; |
| 1366 | tao_retconv = " return _j_ret;\n"; |
| 1367 | ret_exception = " return 0;\n"; |
| 1368 | |
| 1369 | if (!isPrimitive(op_return_type)) { |
| 1370 | retconv = |
| 1371 | " " + ret + " _j_ret = 0;\n" |
| 1372 | " copyToJava (_jni, _j_ret, _c_ret" + suffix + ", true);\n" |
| 1373 | " return _j_ret;\n"; |
| 1374 | tao_retconv = |
| 1375 | " " + idl_mapping_jni::taoType(op_return_type) + extra_type |
| 1376 | + " _c_ret" + extra_init + ";\n" |
no test coverage detected