]> xenbits.xensource.com Git - xcp/xen-api-libs.git/commitdiff
[refactoring] Move SExpr from xen-api.hg to xen-api-libs.hg
authorDavid Scott <dave.scott@eu.citrix.com>
Mon, 26 Oct 2009 16:32:15 +0000 (16:32 +0000)
committerDavid Scott <dave.scott@eu.citrix.com>
Mon, 26 Oct 2009 16:32:15 +0000 (16:32 +0000)
Signed-off-by: Thomas Gazagnaire <thomas.gazagnaire@citrix.com>
sexpr/Makefile
sexpr/sexpr.ml [new file with mode: 0644]
sexpr/sexpr.mli [new file with mode: 0644]

index 69db4ee3080a1000a5b6685d97bd41b2c06bfa08..5bb73aa38966aa7b7169f929d4b87aab0073980a 100644 (file)
@@ -1,4 +1,3 @@
-IPROG=install -m 755 -o root -g root
 CC = gcc
 CFLAGS = -Wall -fPIC -O2 -I/opt/xensource/lib/ocaml
 OCAMLC = ocamlc -g
@@ -8,7 +7,7 @@ OCAMLYACC = ocamlyacc
 
 LDFLAGS = -cclib -L./
 
-LIBEXEC  = "/opt/xensource/libexec"
+DESTDIR ?= /
 VERSION := $(shell hg parents --template "{rev}" 2>/dev/null || echo 0.0)
 OCAMLOPTFLAGS = -g -dtypes
 
@@ -16,14 +15,12 @@ OCAMLABI := $(shell ocamlc -version)
 OCAMLLIBDIR := $(shell ocamlc -where)
 OCAMLDESTDIR ?= $(OCAMLLIBDIR)
 
-OBJS = sExpr sExprLexer sExprParser sExpr_TS
+OBJS = sExpr sExprLexer sExprParser sexpr
 INTF = $(foreach obj, $(OBJS),$(obj).cmi)
 LIBS = sexpr.cma sexpr.cmxa
 
 PROGRAMS = sexprpp
 
-DOCDIR = /myrepos/xen-api-libs.hg/doc
-
 all: $(INTF) $(LIBS)
 
 bins: $(PROGRAMS)
@@ -67,28 +64,12 @@ META: META.in
        sed 's/@VERSION@/$(VERSION)/g' < $< > $@
 
 .PHONY: install
-install: path = $(DESTDIR)$(shell ocamlfind printconf destdir)
 install: $(LIBS) META
-       mkdir -p $(path)
-       ocamlfind install -destdir $(path) -ldconf ignore sexpr META $(INTF) $(LIBS) *.a *.cmx
-
-.PHONY: bininstall
-bininstall: path = $(DESTDIR)$(LIBEXEC)
-bininstall: all
-       mkdir -p $(path)
-       $(IPROG) $(PROGRAMS) $(path)
+       ocamlfind install -destdir $(DESTDIR)$(shell ocamlfind printconf destdir) -ldconf ignore sexpr META $(INTF) $(LIBS) *.a *.cmx
 
 .PHONY: uninstall
 uninstall:
        ocamlfind remove sexpr
 
-.PHONY: binuninstall
-binuninstall:
-       rm -f $(DESTDIR)$(LIBEXEC)$(PROGRAMS)
-
-.PHONY: doc
-doc: $(INTF)
-       python ../doc/doc.py $(DOCDIR) "sexpr" "package" "$(OBJS)" "." "stdext" ""
-       
 clean:
-       rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot sExprLexer.ml{,i} sExprParser.ml{,i} $(LIBS) $(PROGRAMS)
+       rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot sExprLexer.ml{,i} sExprParser.ml{,i} $(LIBS) $(PROGRAMS)
\ No newline at end of file
diff --git a/sexpr/sexpr.ml b/sexpr/sexpr.ml
new file mode 100644 (file)
index 0000000..8ad57b8
--- /dev/null
@@ -0,0 +1,22 @@
+(*
+ * Copyright (C) 2006-2009 Citrix Systems Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *)
+open Threadext
+
+let lock = Mutex.create ()
+
+let of_string s =
+       Mutex.execute lock
+               (fun () -> SExprParser.expr SExprLexer.token (Lexing.from_string s))
+
+let string_of = SExpr.string_of
diff --git a/sexpr/sexpr.mli b/sexpr/sexpr.mli
new file mode 100644 (file)
index 0000000..3fca789
--- /dev/null
@@ -0,0 +1,19 @@
+(*
+ * Copyright (C) 2006-2009 Citrix Systems Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *)
+
+(** Thread-safe marshaller and unmarshaller for sexpr *)
+
+val of_string : string -> SExpr.t
+
+val string_of : SExpr.t -> string