Rev 30 | Blame | Compare with Previous | Last modification | View Log | RSS feed
Thrift OCaml Software LibraryLicense=======Licensed to the Apache Software Foundation (ASF) under oneor more contributor license agreements. See the NOTICE filedistributed with this work for additional informationregarding copyright ownership. The ASF licenses this fileto you under the Apache License, Version 2.0 (the"License"); you may not use this file except in compliancewith the License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing,software distributed under the License is distributed on an"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANYKIND, either express or implied. See the License for thespecific language governing permissions and limitationsunder the License.Library=======The library abstract classes, exceptions, and general use functionsare mostly jammed in Thrift.ml (an exception beingTServer).Generally, classes are used, however they are often put in their ownmodule along with other relevant types and functions. The classesoften called t, exceptions are called E.Implementations live in their own files. There is TBinaryProtocol,TSocket, TThreadedServer, TSimpleServer, and TServerSocket.A note on making the library: Running make should create native, debugcode libraries, and a toplevel.Struct format-------------Structs are turned into classes. The fields are all option types andare initially None. Write is a method, but reading is done by aseparate function (since there is no such thing as a staticclass). The class type is t and is in a module with the name of thestruct.enum format-----------Enums are put in their own module along withfunctions to_i and of_i which convert the ocaml types into ints. Forexample:enum Numberz{ONE = 1,TWO,THREE,FIVE = 5,SIX,EIGHT = 8}==>module Numberz =structtype t =| ONE| TWO| THREE| FIVE| SIX| EIGHTlet of_i = ...let to_i = ...endtypedef format--------------Typedef turns into the type declaration:typedef i64 UserId==>type userid Int64.texception format----------------The same as structs except that the module also has an exception typeE of t that is raised/caught.For example, with an exception Xception,raise (Xception.E (new Xception.t))andtry...with Xception.E e -> ...list format-----------Lists are turned into OCaml native lists.Map/Set formats---------------These are both turned into Hashtbl.t's. Set values are bool.Services--------The client is a class "client" parametrized on input and outputprotocols. The processor is a class parametrized on a handler. Ahandler is a class inheriting the iface abstract class. Unlike otherimplementations, client does not implement iface since iface functionsmust take option arguments so as to deal with the case where a clientdoes not send all the arguments.