@@ -228,9 +228,9 @@ let gen_method_return_cast message = match message.msg_result with
228228
229229let gen_method_return file cls message =
230230 if (String. lowercase_ascii cls.name) = " event" && (String. lowercase_ascii message.msg_name) = " from" then
231- fprintf file " return Types.toEventBatch(result);\n "
231+ fprintf file " return Types.toEventBatch(result);\n "
232232 else
233- fprintf file " return%s;\n " (gen_method_return_cast message)
233+ fprintf file " return%s;\n " (gen_method_return_cast message)
234234
235235let rec range = function
236236 | 0 -> []
@@ -245,41 +245,49 @@ let gen_method file cls message params async_version =
245245 let method_static = if is_method_static message then " static " else " " in
246246 let method_name = camel_case message.msg_name in
247247 let paramString = get_method_params_for_signature params in
248- let default_errors = [" BadServerResponse " ;
249- " XenAPIException " ;
250- " XmlRpcException " ] in
251- let err_string = String. concat " , \n " (default_errors @ ( List. map
252- ( fun err -> " Types. " ^ (exception_class_case err.err_name)) message.msg_errors)) in
248+ let default_errors = [
249+ ( " BadServerResponse " , " Thrown if the response from the server contains an invalid status. " ) ;
250+ ( " XenAPIException " , " Thrown if the call failed. " );
251+ ( " XmlRpcException " , " Thrown if the result of an asynchronous call could not be parsed. " )
252+ ] in
253253 let publishInfo = get_published_info_message message cls in
254254
255255 fprintf file " /**\n " ;
256- fprintf file " * %s\n " message.msg_doc;
256+ fprintf file " * %s\n " (escape_xml message.msg_doc) ;
257257 if not (publishInfo = " " ) then fprintf file " * %s\n " publishInfo;
258258 if (get_method_deprecated message) then fprintf file " * @deprecated\n " ;
259259 fprintf file " *\n " ;
260+ fprintf file " * @param c The connection the call is made on\n " ;
260261
261262 List. iter (fun x -> let paramPublishInfo = get_published_info_param message x in
262263 fprintf file " * @param %s %s%s\n "
263264 (camel_case x.param_name)
264- x.param_doc
265+ ( if x.param_doc = " " then " No description " else (escape_xml x.param_doc))
265266 (if paramPublishInfo = " " then " " else " " ^ paramPublishInfo))
266267 params;
267268
268269 if async_version then
269270 fprintf file " * @return Task\n "
270- else
271- (match message.msg_result with
272- | None -> ()
273- | Some (_ , desc ) -> fprintf file " * @return %s\n " desc);
271+ else begin
272+ match message.msg_result with
273+ | None -> ()
274+ | Some (_ , "" ) -> fprintf file " * @return %s\n " (get_java_type_or_void message.msg_result)
275+ | Some (_ , desc ) -> fprintf file " * @return %s\n " desc
276+ end ;
277+
278+ List. iter (fun x -> fprintf file " * @throws %s %s\n " (fst x) (snd x)) default_errors;
279+ List. iter (fun x -> fprintf file " * @throws Types.%s %s\n " (exception_class_case x.err_name) x.err_doc) message.msg_errors;
274280
275281 fprintf file " */\n " ;
276282
277283 if async_version then
278284 fprintf file " %s public %sTask %sAsync(%s) throws\n " deprecated_string method_static method_name paramString
279285 else
280- fprintf file " %s public %s%s %s(%s) throws\n " deprecated_string method_static return_type method_name paramString;
286+ fprintf file " %s public %s%s %s(%s) throws\n " deprecated_string method_static return_type method_name paramString;
281287
282- fprintf file " %s {\n " err_string;
288+ let all_errors = (List. map fst default_errors) @
289+ (List. map (fun x -> " Types." ^ (exception_class_case x.err_name)) message.msg_errors) in
290+ fprintf file " %s {\n " (String. concat " ,\n " all_errors);
283291
284292 if async_version then
285293 fprintf file " String method_call = \" Async.%s.%s\" ;\n " message.msg_obj_name message.msg_name
@@ -316,7 +324,7 @@ let gen_method file cls message params async_version =
316324 fprintf file " return Types.toTask(result);\n " )
317325 else (
318326 match message.msg_result with
319- | None -> fprintf file " return; \n "
327+ | None -> fprintf file " "
320328 | Some _ -> fprintf file " Object result = response.get(\" Value\" );\n " ;
321329 gen_method_return file cls message
322330 );
@@ -348,7 +356,7 @@ let gen_record_field file prefix field cls =
348356 let name = camel_case (String. concat " _" (List. rev (field.field_name :: prefix))) in
349357 let publishInfo = get_published_info_field field cls in
350358 fprintf file " /**\n " ;
351- fprintf file " * %s\n " field.field_description;
359+ fprintf file " * %s\n " (escape_xml field.field_description) ;
352360 if not (publishInfo = " " ) then fprintf file " * %s\n " publishInfo;
353361 fprintf file " */\n " ;
354362 fprintf file " public %s %s;\n " ty name
@@ -698,7 +706,7 @@ let gen_enum file name ls =
698706 fprintf file " /* This can never be reached */\n " ;
699707 fprintf file " return \" illegal enum\" ;\n " ;
700708 fprintf file " }\n " ;
701- fprintf file " \n }; \n\n "
709+ fprintf file " \n }\n\n "
702710;;
703711
704712let gen_enums file =
@@ -720,26 +728,17 @@ let gen_error file name params =
720728 (fun field -> " String " ^ field) fields) in
721729
722730 fprintf file " /**\n " ;
723- fprintf file " * %s\n " params.err_doc;
731+ fprintf file " * %s\n " (escape_xml params.err_doc) ;
724732 fprintf file " */\n " ;
725733 fprintf file " public static class %s extends XenAPIException {\n " name;
726734
727735 List. iter (gen_error_fields file) fields;
728736
729737 fprintf file " \n /**\n " ;
730738 fprintf file " * Create a new %s\n " name;
731-
732- if List. length fields > 0
733- then
734- begin
735- fprintf file " *\n " ;
736- List. iter
737- (fun s -> fprintf file " * @param %s\n " s) fields
738- end ;
739-
740739 fprintf file " */\n " ;
741740 fprintf file " public %s(%s) {\n " name constructor_params;
742- fprintf file " super(\" %s\" );\n " params.err_doc;
741+ fprintf file " super(\" %s\" );\n " (escape_xml params.err_doc) ;
743742
744743 List. iter
745744 (fun s -> fprintf file " this.%s = %s;\n " s s) fields;
0 commit comments