• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

src/11-Mar-2024-948821

DEVELOPMENTD11-Mar-20242 KiB7751

README.mdD11-Mar-20242.8 KiB12093

TODOD11-Mar-2024114 63

_oasisD11-Mar-2024556 2017

coding_standards.mdD11-Mar-202467 21

descrD11-Mar-202448 21

opamD11-Mar-2024163 98

urlD11-Mar-202473 32

README.md

1Thrift OCaml Software Library
2
3License
4=======
5
6Licensed to the Apache Software Foundation (ASF) under one
7or more contributor license agreements. See the NOTICE file
8distributed with this work for additional information
9regarding copyright ownership. The ASF licenses this file
10to you under the Apache License, Version 2.0 (the
11"License"); you may not use this file except in compliance
12with the License. You may obtain a copy of the License at
13
14  http://www.apache.org/licenses/LICENSE-2.0
15
16Unless required by applicable law or agreed to in writing,
17software distributed under the License is distributed on an
18"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19KIND, either express or implied. See the License for the
20specific language governing permissions and limitations
21under the License.
22
23
24Library
25=======
26
27The library abstract classes, exceptions, and general use functions
28are mostly jammed in Thrift.ml (an exception being
29TServer).
30
31Generally, classes are used, however they are often put in their own
32module along with other relevant types and functions. The classes
33often called t, exceptions are called E.
34
35Implementations live in their own files. There is TBinaryProtocol,
36TSocket, TThreadedServer, TSimpleServer, and TServerSocket.
37
38A note on making the library: Running make should create native, debug
39code libraries, and a toplevel.
40
41
42Struct format
43-------------
44Structs are turned into classes. The fields are all option types and
45are initially None. Write is a method, but reading is done by a
46separate function (since there is no such thing as a static
47class). The class type is t and is in a module with the name of the
48struct.
49
50
51enum format
52-----------
53Enums are put in their own module along with
54functions to_i and of_i which convert the ocaml types into ints. For
55example:
56
57enum Numberz
58{
59  ONE = 1,
60  TWO,
61  THREE,
62  FIVE = 5,
63  SIX,
64  EIGHT = 8
65}
66
67==>
68
69module Numberz =
70struct
71type t =
72| ONE
73| TWO
74| THREE
75| FIVE
76| SIX
77| EIGHT
78
79let of_i = ...
80let to_i = ...
81end
82
83typedef format
84--------------
85Typedef turns into the type declaration:
86typedef i64 UserId
87
88==>
89
90type userid Int64.t
91
92exception format
93----------------
94The same as structs except that the module also has an exception type
95E of t that is raised/caught.
96
97For example, with an exception Xception,
98raise (Xception.E (new Xception.t))
99and
100try
101  ...
102with Xception.E e -> ...
103
104list format
105-----------
106Lists are turned into OCaml native lists.
107
108Map/Set formats
109---------------
110These are both turned into Hashtbl.t's. Set values are bool.
111
112Services
113--------
114The client is a class "client" parametrized on input and output
115protocols. The processor is a class parametrized on a handler. A
116handler is a class inheriting the iface abstract class. Unlike other
117implementations, client does not implement iface since iface functions
118must take option arguments so as to deal with the case where a client
119does not send all the arguments.
120