From: David Scott Date: Mon, 26 Oct 2009 16:32:15 +0000 (+0000) Subject: [refactoring] Move SExpr from xen-api.hg to xen-api-libs.hg X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=9e54534491265af80eda47d357452fa4d9116c3f;p=xcp%2Fxen-api-libs.git [refactoring] Move SExpr from xen-api.hg to xen-api-libs.hg Signed-off-by: Thomas Gazagnaire --- diff --git a/sexpr/Makefile b/sexpr/Makefile index 69db4ee..5bb73aa 100644 --- a/sexpr/Makefile +++ b/sexpr/Makefile @@ -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 index 0000000..8ad57b8 --- /dev/null +++ b/sexpr/sexpr.ml @@ -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 index 0000000..3fca789 --- /dev/null +++ b/sexpr/sexpr.mli @@ -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