Permalink
Browse files

[feature] compiler, database, dropbox: introducing a new db backend b…

…ased on Dropbox API
  • Loading branch information...
1 parent 7c838dc commit 7acaaf1ee9483be0710e1719e570b5f2bc09aa78 @cedricss cedricss committed Apr 6, 2012
@@ -74,15 +74,15 @@ struct
let stringmap_empty = "stringmap_empty"
let stringmap_add = "stringmap_add"
let stringmap_fold = "stringmap_fold"
- let dbset_empty = Opacapi.DbSet.empty
+ let dbset_empty = Opacapi.DbMongoSet.empty
let ref_to_ref = Opacapi.Db3.ref_to_ref
let make_virtual_val = "make_virtual_val"
let make_virtual_ref = "make_virtual_ref"
let val_to_val = Opacapi.Db3.val_to_val
let ref_to_ref = Opacapi.Db3.ref_to_ref
- let dbset_genbuild = Opacapi.DbSet.genbuild
+ let dbset_genbuild = Opacapi.DbMongoSet.genbuild
let db3set_iterator = Opacapi.Db3Set.iterator
end
@@ -223,16 +223,17 @@ struct
let stringmap_empty = Opacapi.StringMap.empty
let stringmap_add = Opacapi.StringMap.add
let stringmap_fold = Opacapi.StringMap.fold
- let dbset_empty = Opacapi.DbSet.empty
+ let dbset_empty = Opacapi.DbMongoSet.empty
let make_virtual_val = Opacapi.DbVirtual.make_val
let make_virtual_ref = Opacapi.DbVirtual.make_ref
let val_to_val = Opacapi.Db3.val_to_val
let ref_to_ref = Opacapi.Db3.ref_to_ref
- let dbset_genbuild = Opacapi.DbSet.genbuild
+ let dbset_genbuild = Opacapi.DbMongoSet.genbuild
let db3set_iterator = Opacapi.Db3Set.iterator
end
+(* Add dropbox opa interface here *)
module BSLDbGenAlphaOpa = MakeS ( DbOpaInterface ) ( I_Alpha )
@@ -59,7 +59,7 @@ type schema_node = {
plain : bool;
}
-type engine = [ `db3 | `mongo]
+type engine = [ `db3 | `mongo | `dropbox]
module Args = struct
@@ -74,15 +74,16 @@ module Args = struct
let descr = function
| `db3 -> "Db3"
| `mongo -> "Mongo"
+ | `dropbox -> "Dropbox"
- let assoc = [("mongo", `mongo); ("db3"), `db3]
+ let assoc = [("mongo", `mongo); ("db3", `db3); ("dropbox", `dropbox)]
let r = ref None
let options = [
("--database", Arg.spec_fun_of_assoc
(fun s -> r := Some {engine=s}) assoc,
- "Select kind of database (db3|mongo)");
+ "Select kind of database (db3|mongo|dropbox)");
]
let get_engine () = Option.map (fun r -> r.engine) !r
@@ -162,6 +163,7 @@ module Db = struct
match engine with
| `db3 -> Opacapi.Types.Db3.t
| `mongo -> Opacapi.Types.DbMongo.t
+ | `dropbox -> Opacapi.Types.DbDropbox.t
in
QmlAst.TypeName ([], typ ident)
@@ -170,17 +172,22 @@ module Db = struct
match engine with
| `db3 -> Opacapi.Types.db3set
| `mongo -> Opacapi.Types.dbmongoset
+ | `dropbox -> Opacapi.Types.dbdropboxset
in
QmlAst.TypeName ([ty], typ ident)
let mongo_engine () =
QmlAst.TypeName ([], typ Opacapi.Types.DbMongo.engine)
+ let dropbox_engine () =
+ QmlAst.TypeName ([], typ Opacapi.Types.DbDropbox.engine)
+
let ref_path_ty tydata =
let tyengine =
match get_engine() with
| `db3 -> ref_path_ty tydata
- | `mongo -> mongo_engine ()
+ | `dropbox -> dropbox_engine ()
+ | `mongo -> mongo_engine ()
in
QmlAst.TypeName ([tydata; tyengine],
(* typ don't use typ with type defined inside stdlib.core*)
@@ -190,6 +197,7 @@ module Db = struct
let tyengine =
match get_engine() with
| `db3 -> val_path_ty tydata
+ | `dropbox -> dropbox_engine ()
| `mongo -> mongo_engine ()
in
QmlAst.TypeName ([tydata; tyengine],
@@ -231,6 +231,7 @@ struct
type engine = [
|`db3
|`mongo
+ |`dropbox
]
type options = {
@@ -399,6 +400,7 @@ struct
let options_to_string opt = match opt.backend with
| `db3 -> "@db3"
| `mongo -> "@mongo"
+ | `dropbox -> "@dropbox"
let path_decl_key_to_string = function
| Decl_fld s -> "/"^s
@@ -32,7 +32,7 @@ module DbAst = QmlAst.Db
module C = DbGen_common
-type engine = [`db3 | `mongo]
+type engine = [`db3 | `mongo | `dropbox]
let settyp = DbGen_common.settyp
@@ -19,7 +19,7 @@
(** {6 Command line arguments } *)
(** Describes different backend that dbgen handle. *)
-type engine = [`db3 | `mongo]
+type engine = [`db3 | `mongo | `dropbox]
(** Command line specification provides necessary options for switch
database backend. *)
@@ -37,6 +37,7 @@ struct
let aux = function
|`db3 -> "db3"
|`mongo -> "mongo"
+ |`dropbox -> "dropbox"
in
List.iter (fun x -> Format.fprintf f "%s;" (aux x)) l
end
@@ -55,7 +56,9 @@ let import_packages engines =
List.map
(function
| `db3 -> "stdlib.database.db3"
- | `mongo -> "stdlib.database.mongo")
+ | `mongo -> "stdlib.database.mongo"
+ | `dropbox -> "stdlib.database.dropbox"
+ )
engines
in
ObjectFiles.add_compiler_packages packages
@@ -27,7 +27,7 @@ module Api = struct
module Db = Opacapi.DbMongo
- module DbSet = Opacapi.DbSet
+ module DbSet = Opacapi.DbMongoSet
end
module DbAst = QmlAst.Db
@@ -149,23 +149,46 @@ struct
let iterator = !! "iterator"
end
-module DbMongo =
-struct
- let (!!) s = !! ("DbMongo_" ^ s)
- let open_ = !! "open"
- let path_to_path = !! "path_to_path"
- let build_vpath = !! "build_vpath"
- let build_rpath = !! "build_rpath"
- let update_path = !! "update_path"
- let build_vpath_sub = !! "build_vpath_sub"
- let build_rpath_sub = !! "build_rpath_sub"
- let build_rpath_compose = !! "build_rpath_compose"
- let build_vpath_compose = !! "build_vpath_compose"
- let option = !! "option"
- let read = !! "read"
- let write = !! "write"
- let expr_to_field = !! "expr_to_field"
-end
+module type DB =
+ sig
+ val ( !! ) : string -> string
+ val open_ : string
+ val path_to_path : string
+ val build_vpath : string
+ val build_rpath : string
+ val update_path : string
+ val build_vpath_sub : string
+ val build_rpath_sub : string
+ val build_rpath_compose : string
+ val build_vpath_compose : string
+ val option : string
+ val read : string
+ val write : string
+ val expr_to_field : string
+ end
+
+let make_db(x) =
+ let module Db =
+ struct
+ let (!!) s = !! (x ^ "_" ^ s)
+ let open_ = !! "open"
+ let path_to_path = !! "path_to_path"
+ let build_vpath = !! "build_vpath"
+ let build_rpath = !! "build_rpath"
+ let update_path = !! "update_path"
+ let build_vpath_sub = !! "build_vpath_sub"
+ let build_rpath_sub = !! "build_rpath_sub"
+ let build_rpath_compose = !! "build_rpath_compose"
+ let build_vpath_compose = !! "build_vpath_compose"
+ let option = !! "option"
+ let read = !! "read"
+ let write = !! "write"
+ let expr_to_field = !! "expr_to_field"
+ end
+ in (module Db : DB)
+
+module DbMongo = (val make_db "DbMongo" : DB)
+module DbDropbox = (val make_db "DbDropbox" : DB)
module DbSet =
struct
@@ -372,6 +395,7 @@ struct
let dbset = !! "dbset"
let db3set = !! "Db3Set.t"
let dbmongoset = !! "DbMongoSet.t"
+ let dbdropboxset = !! "DbDropboxSet.t"
let dom = !! "dom"
let finite_single_thread_lazy = !! "finite_single_thread_lazy"
let float = !! "float"
@@ -441,6 +465,12 @@ struct
let engine = !! "engine"
end
+ module DbDropboxSet =
+ struct
+ let (!!) s = !! ("DbDropboxSet." ^ s)
+ let engine = !! "engine"
+ end
+
module DbMongo =
struct
let (!!) s = !! ("DbMongo." ^ s)
@@ -450,6 +480,15 @@ struct
let ref_path = !! "private.ref_path"
end
+ module DbDropbox =
+ struct
+ let (!!) s = !! ("DbDropbox." ^ s)
+ let t = !! "t"
+ let engine = !! "engine"
+ let val_path = !! "private.val_path"
+ let ref_path = !! "private.ref_path"
+ end
+
module Cell =
struct
let (!!) s = !! ("Cell." ^ s)
@@ -247,7 +247,8 @@ db_options <-
/ "@" "meta" {{ {QmlAst.Db.backend = `db3} }}
/ "@" "db3" {{ {QmlAst.Db.backend = `db3} }}
/ "@" "mongo" {{ {QmlAst.Db.backend = `mongo} }}
-
+ / "@" "dropbox" {{ {QmlAst.Db.backend = `dropbox} }}
+
(**
{6 Bindings}
Bindings or assimilated (like do)
@@ -484,7 +484,7 @@ db_virtual <-
db_options <-
/ "@" "db3" {{ {QmlAst.Db.backend = `db3} }}
/ "@" "mongo" {{ {QmlAst.Db.backend = `mongo} }}
-
+ / "@" "dropbox" {{ {QmlAst.Db.backend = `dropbox} }}
@@ -30,4 +30,5 @@ DbSet = {{
}}
-@opacapi DbSet_genbuild = DbSet.build
+@opacapi DbMongoSet_genbuild = DbSet.build
+@opacapi DbDropboxSet_genbuild = error("Set not yet supported on Dropbox db backend")
Oops, something went wrong.

0 comments on commit 7acaaf1

Please sign in to comment.