Wrappers now automatically 'use' modules.
[perl4caml.git] / wrappers / pl_URI.ml
1 (* Wrapper around Perl URI class.
2  * Copyright (C) 2003 Merjis Ltd.
3  * $Id: pl_URI.ml,v 1.2 2003-10-15 16:51:12 rich Exp $
4  *)
5
6 open Perl
7
8 let _ = eval "use URI"
9
10 class uri sv =
11
12 object (self)
13
14   method sv = sv
15
16   method scheme =
17     string_of_sv (call_method sv "scheme" [])
18   method set_scheme scheme =
19     call_method_void sv "scheme" [sv_of_string scheme]
20   method opaque =
21     string_of_sv (call_method sv "opaque" [])
22   method set_opaque opaque =
23     call_method_void sv "opaque" [sv_of_string opaque]
24   method path =
25     string_of_sv (call_method sv "path" [])
26   method set_path path =
27     call_method_void sv "path" [sv_of_string path]
28   method fragment =
29     string_of_sv (call_method sv "fragment" [])
30   method set_fragment fragment =
31     call_method_void sv "fragment" [sv_of_string fragment]
32   method as_string =
33     string_of_sv (call_method sv "as_string" [])
34   method canonical =
35     string_of_sv (call_method sv "canonical" [])
36   method abs base =
37     string_of_sv (call_method sv "abs" [sv_of_string base])
38   method rel base =
39     string_of_sv (call_method sv "rel" [sv_of_string base])
40
41 end
42
43 let new_ ?scheme str =
44   let args =
45     [sv_of_string str] @
46     match scheme with
47         None -> []
48       | Some scheme -> [sv_of_string scheme] in
49   let sv = call_class_method "URI" "new" args in
50   new uri sv