From eb1a25213bb17cf009aebd75b5222ba20a01ea9b Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Fri, 17 Jan 2003 15:12:35 +0000 Subject: [PATCH] - removed useless thread stuff - fixed copyright notice --- helm/uwobo/src/ocaml/uwobo_styles.ml | 147 ++++++++++++-------------- helm/uwobo/src/ocaml/uwobo_styles.mli | 48 +++++---- 2 files changed, 90 insertions(+), 105 deletions(-) diff --git a/helm/uwobo/src/ocaml/uwobo_styles.ml b/helm/uwobo/src/ocaml/uwobo_styles.ml index 218da1786..9f954f63d 100644 --- a/helm/uwobo/src/ocaml/uwobo_styles.ml +++ b/helm/uwobo/src/ocaml/uwobo_styles.ml @@ -1,27 +1,29 @@ - -(* Copyright (C) 2002, HELM Team. - * - * This file is part of HELM, an Hypertextual, Electronic - * Library of Mathematics, developed at the Computer Science - * Department, University of Bologna, Italy. - * - * HELM is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * HELM 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 General Public License for more details. +(* + * Copyright (C) 2003: + * Stefano Zacchiroli + * for the HELM Team http://helm.cs.unibo.it/ + * + * This file is part of HELM, an Hypertextual, Electronic + * Library of Mathematics, developed at the Computer Science + * Department, University of Bologna, Italy. + * + * HELM is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * HELM 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with HELM; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. * - * You should have received a copy of the GNU General Public License - * along with HELM; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - * For details, see the HELM World-Wide-Web page, - * http://cs.unibo.it/helm/. + * For details, see the HELM World-Wide-Web page, + * http://helm.cs.unibo.it/ *) open Printf;; @@ -33,8 +35,6 @@ class styles = object (self) (* INVARIANT: 'stylesheets' and 'uris' are in sync *) - inherit Uwobo_common.threadSafe - val mutable stylesheets = [] val mutable uris = [] val domImpl = Gdome.domImplementation () @@ -43,76 +43,59 @@ class styles = method private process uri = domImpl#createDocumentFromURI ~uri () method get keys = - self#doReader (lazy ( - let rev_keys = List.rev keys in - let last_key = List.hd rev_keys in - let p_stylesheets = - List.fold_left - (fun collected_styles key -> - let (key, stylesheet) = - try - List.find (fun (k, _) -> k = key) stylesheets - with Not_found -> raise (Stylesheet_not_found key) - in - (key, Gdome_xslt.processStylesheet stylesheet)::collected_styles) - [] - rev_keys - in - let last_stylesheet = - snd (List.find (fun (k, _) -> k = last_key) stylesheets) - in - (p_stylesheets, last_stylesheet) - )) + let rev_keys = List.rev keys in + let last_key = List.hd rev_keys in + let p_stylesheets = + List.fold_left + (fun collected_styles key -> + let (key, stylesheet) = + try + List.find (fun (k, _) -> k = key) stylesheets + with Not_found -> raise (Stylesheet_not_found key) + in + (key, Gdome_xslt.processStylesheet stylesheet)::collected_styles) + [] + rev_keys + in + let last_stylesheet = + snd (List.find (fun (k, _) -> k = last_key) stylesheets) + in + (p_stylesheets, last_stylesheet) method add key uri = - self#doWriter (lazy ( - if (List.mem_assoc key uris) then - raise (Stylesheet_already_in key) - else begin - uris <- (key, uri) :: uris; - stylesheets <- (key, self#process uri) :: stylesheets - end - )) + if (List.mem_assoc key uris) then + raise (Stylesheet_already_in key) + else begin + uris <- (key, uri) :: uris; + stylesheets <- (key, self#process uri) :: stylesheets + end method remove key = - self#doWriter (lazy ( - if not (List.mem_assoc key uris) then - raise (Stylesheet_not_found key) - else begin - uris <- List.remove_assoc key uris; - stylesheets <- List.remove_assoc key stylesheets - end - )) + if not (List.mem_assoc key uris) then + raise (Stylesheet_not_found key) + else begin + uris <- List.remove_assoc key uris; + stylesheets <- List.remove_assoc key stylesheets + end - method removeAll = - self#doWriter (lazy ( - uris <- []; - stylesheets <- [] - )) + method removeAll = uris <- []; stylesheets <- [] method list = - let uris = self#doReader (lazy ( - uris - )) - in List.map - (fun (key, uri) -> sprintf "key = %s, uri = %s" key (List.assoc key uris)) + (fun (key, uri) -> + sprintf "key = %s, uri = %s" key (List.assoc key uris)) uris method reload key = - self#doWriter (lazy ( - (try - let uri = List.assoc key uris in - stylesheets <- - (key, self#process uri) :: (List.remove_assoc key stylesheets) - with Not_found -> - raise (Stylesheet_not_found key)) - )) + (try + let uri = List.assoc key uris in + stylesheets <- + (key, self#process uri) :: (List.remove_assoc key stylesheets) + with Not_found -> + raise (Stylesheet_not_found key)) method reloadAll = - self#doWriter (lazy ( - stylesheets <- List.map (fun (key, uri) -> (key, self#process uri)) uris - )) + stylesheets <- List.map (fun (key, uri) -> (key, self#process uri)) uris end diff --git a/helm/uwobo/src/ocaml/uwobo_styles.mli b/helm/uwobo/src/ocaml/uwobo_styles.mli index 0ff5f1fb5..5a0722f03 100644 --- a/helm/uwobo/src/ocaml/uwobo_styles.mli +++ b/helm/uwobo/src/ocaml/uwobo_styles.mli @@ -1,27 +1,29 @@ - -(* Copyright (C) 2002, HELM Team. - * - * This file is part of HELM, an Hypertextual, Electronic - * Library of Mathematics, developed at the Computer Science - * Department, University of Bologna, Italy. - * - * HELM is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * HELM 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 General Public License for more details. +(* + * Copyright (C) 2003: + * Stefano Zacchiroli + * for the HELM Team http://helm.cs.unibo.it/ + * + * This file is part of HELM, an Hypertextual, Electronic + * Library of Mathematics, developed at the Computer Science + * Department, University of Bologna, Italy. + * + * HELM is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * HELM 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with HELM; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. * - * You should have received a copy of the GNU General Public License - * along with HELM; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. - * - * For details, see the HELM World-Wide-Web page, - * http://cs.unibo.it/helm/. + * For details, see the HELM World-Wide-Web page, + * http://helm.cs.unibo.it/ *) exception Stylesheet_not_found of string;; -- 2.39.2