X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=wrappers%2Fpl_WWW_Mechanize.ml;h=2582b9da8aed522e47455e2f0267d22a8a420429;hb=95114635aee7abc960959ed6502d11b4dc421e1a;hp=a29a5a9fd42eff6bc5ca5caf238629a1a6110522;hpb=7f82a6f31e40e596a43939ab18d685a8f0b78d7b;p=perl4caml.git diff --git a/wrappers/pl_WWW_Mechanize.ml b/wrappers/pl_WWW_Mechanize.ml index a29a5a9..2582b9d 100644 --- a/wrappers/pl_WWW_Mechanize.ml +++ b/wrappers/pl_WWW_Mechanize.ml @@ -2,7 +2,7 @@ * * Copyright (C) 2004 Merjis Ltd. * - * $Id: pl_WWW_Mechanize.ml,v 1.1 2004-11-25 21:24:51 rich Exp $ + * $Id: pl_WWW_Mechanize.ml,v 1.2 2004-11-26 13:33:10 rich Exp $ *) open Perl @@ -49,18 +49,24 @@ object (self) add "n" sv_of_int n; call_method_void sv "follow_link" !args - (* XXX What do these next two functions return? *) + method forms = + let svlist = call_method_array sv "forms" [] in + List.map (new Pl_HTML_Form.html_form) svlist method form_number n = - call_method_void sv "form_number" [sv_of_int n] + let sv = call_method sv "form_number" [sv_of_int n] in + new Pl_HTML_Form.html_form sv method form_name name = - call_method_void sv "form_name" [sv_of_string name] + let sv = call_method sv "form_name" [sv_of_string name] in + new Pl_HTML_Form.html_form sv (* XXX There is an arrayref variant of this method, but what * it does is apparently undocumented. *) - method field name value n = - call_method_void sv "field" [sv_of_string name; sv_of_string value; - sv_of_int n] + method field ?n name value = + let args = match n with + None -> [sv_of_string name; sv_of_string value] + | Some n -> [sv_of_string name; sv_of_string value; sv_of_int n] in + call_method_void sv "field" args method set_fields fields = let args = ref [] in List.iter (fun (k, v) -> @@ -69,8 +75,11 @@ object (self) let args = List.rev !args in call_method_void sv "set_fields" args - method value name n = - let sv = call_method sv "value" [sv_of_string name; sv_of_int n] in + method value ?n name = + let args = match n with + None -> [sv_of_string name] + | Some n -> [sv_of_string name; sv_of_int n] in + let sv = call_method sv "value" args in string_of_sv sv (* XXX Doesn't support setting criteria. *) @@ -146,7 +155,6 @@ object (self) method content = let sv = call_method sv "content" [] in string_of_sv sv - (* method forms = *) (* method current_forms = *) (* method links = *) method is_html =