More filling in of method wrappers.
[perl4caml.git] / wrappers / pl_HTML_Form.ml
1 (** Wrapper around Perl [HTML::Form] class.
2   *
3   * Copyright (C) 2003 Merjis Ltd.
4   *
5   * $Id: pl_HTML_Form.ml,v 1.2 2005-01-13 10:38:54 rich Exp $
6   *)
7
8 open Perl
9
10 open Pl_HTTP_Response
11
12 let _ = eval "use HTML::Form"
13
14 class html_form (sv : sv) =
15
16 object (self)
17   method sv = sv
18
19   method attr name =
20     let sv = call_method sv "attr" [sv_of_string name] in
21     (* sv_is_undef doesn't work properly XXX *)
22     if sv_is_undef sv then None else Some (string_of_sv sv)
23   method set_attr name value =
24     call_method_void sv "attr" [sv_of_string name; sv_of_string value]
25
26 end
27
28 let parse_document html_document base_uri =
29   let svlist = call_class_method_array "HTML::Form" "parse"
30                  [sv_of_string html_document; sv_of_string base_uri] in
31   List.map (new html_form) svlist
32
33 let parse_response (res : http_response) =
34   let svlist = call_class_method_array "HTML::Form" "parse" [res#sv] in
35   List.map (new html_form) svlist