| 154 | } |
| 155 | |
| 156 | bool gen_helper(const JavaName &jn, const char *repoid, bool narrow = false) |
| 157 | { |
| 158 | JavaName jn_help(jn, "Helper"); |
| 159 | |
| 160 | string body = |
| 161 | " // Any and TypeCode operations not currently implemented\n" |
| 162 | " public static String id() { return \"" + string(repoid) + "\"; }\n"; |
| 163 | |
| 164 | if (narrow) { |
| 165 | body += |
| 166 | " public static " + jn.clazz_ |
| 167 | + " narrow(org.omg.CORBA.Object obj) {\n" |
| 168 | " if (obj == null)\n" |
| 169 | " return null;\n" |
| 170 | " else if (obj instanceof " + jn.clazz_ + ")\n" |
| 171 | " return (" + jn.clazz_ + ")obj;\n" |
| 172 | " else if (!obj._is_a (id ()))\n" |
| 173 | " throw new org.omg.CORBA.BAD_PARAM ();\n" |
| 174 | " else\n" |
| 175 | " return native_unarrow(obj);\n" |
| 176 | " }\n\n" |
| 177 | " public static " + jn.clazz_ |
| 178 | + " unchecked_narrow(org.omg.CORBA.Object obj) {\n" |
| 179 | " if (obj == null)\n" |
| 180 | " return null;\n" |
| 181 | " else if (obj instanceof " + jn.clazz_ + ")\n" |
| 182 | " return (" + jn.clazz_ + ")obj;\n" |
| 183 | " else\n" |
| 184 | " return native_unarrow(obj);\n" |
| 185 | " }\n\n" |
| 186 | " private native static " + jn.clazz_ |
| 187 | + " native_unarrow(org.omg.CORBA.Object obj);\n"; |
| 188 | } |
| 189 | |
| 190 | return java_class_gen(jn_help, JABSTRACT_CLASS, body.c_str()); |
| 191 | } |
| 192 | |
| 193 | bool gen_holder(const JavaName &jn, const char *held = "") |
| 194 | { |
no test coverage detected