blob: 222a4b90b7d2e86a28efc521449d3ea6fcc3d422 [file] [log] [blame]
iproctor9a41a0c2007-07-16 21:59:24 +00001Library
2-------
iproctore470aa32007-08-10 20:48:12 +00003The library abstract classes, exceptions, and general use functions
4are mostly jammed in Thrift.ml (an exception being
David Reiss0c90f6f2008-02-06 22:18:40 +00005TServer).
iproctor9a41a0c2007-07-16 21:59:24 +00006
iproctore470aa32007-08-10 20:48:12 +00007Generally, classes are used, however they are often put in their own
8module along with other relevant types and functions. The classes
9often called t, exceptions are called E.
10
11Implementations live in their own files. There is TBinaryProtocol,
12TSocket, TThreadedServer, TSimpleServer, and TServerSocket.
13
14A note on making the library: Running make should create native, debug
15code libraries, and a toplevel.
iproctor9a41a0c2007-07-16 21:59:24 +000016
17
18Struct format
19-------------
iproctore470aa32007-08-10 20:48:12 +000020Structs are turned into classes. The fields are all option types and
21are initially None. Write is a method, but reading is done by a
22separate function (since there is no such thing as a static
23class). The class type is t and is in a module with the name of the
24struct.
iproctor9a41a0c2007-07-16 21:59:24 +000025
26
David Reiss0c90f6f2008-02-06 22:18:40 +000027enum format
iproctor9a41a0c2007-07-16 21:59:24 +000028-----------
iproctore470aa32007-08-10 20:48:12 +000029Enums are put in their own module along with
30functions to_i and of_i which convert the ocaml types into ints. For
31example:
iproctor9a41a0c2007-07-16 21:59:24 +000032
33enum Numberz
34{
35 ONE = 1,
36 TWO,
37 THREE,
38 FIVE = 5,
39 SIX,
40 EIGHT = 8
41}
42
43==>
44
iproctore470aa32007-08-10 20:48:12 +000045module Numberz =
iproctor9a41a0c2007-07-16 21:59:24 +000046struct
47type t =
48| ONE
49| TWO
50| THREE
51| FIVE
52| SIX
53| EIGHT
54
55let of_i = ...
56let to_i = ...
57end
58
59typedef format
60--------------
61Typedef turns into the type declaration:
62typedef i64 UserId
63
64==>
65
66type userid Int64.t
67
68exception format
69----------------
iproctore470aa32007-08-10 20:48:12 +000070The same as structs except that the module also has an exception type
71E of t that is raised/caught.
iproctor9a41a0c2007-07-16 21:59:24 +000072
iproctore470aa32007-08-10 20:48:12 +000073For example, with an exception Xception,
74raise (Xception.E (new Xception.t))
75and
76try
77 ...
78with Xception.E e -> ...
iproctor9a41a0c2007-07-16 21:59:24 +000079
80list format
81-----------
iproctore470aa32007-08-10 20:48:12 +000082Lists are turned into OCaml native lists.
iproctor9a41a0c2007-07-16 21:59:24 +000083
84Map/Set formats
85---------------
iproctore470aa32007-08-10 20:48:12 +000086These are both turned into Hashtbl.t's. Set values are bool.
iproctor9a41a0c2007-07-16 21:59:24 +000087
88Services
89--------
iproctore470aa32007-08-10 20:48:12 +000090The client is a class "client" parametrized on input and output
91protocols. The processor is a class parametrized on a handler. A
92handler is a class inheriting the iface abstract class. Unlike other
93implementations, client does not implement iface since iface functions
94must take option arguments so as to deal with the case where a client
95does not send all the arguments.