Skip to content
This repository
Newer
Older
100644 43 lines (37 sloc) 1.597 kb
fccc6851 » MLstate
2011-06-21 Initial open-source release
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 module Q = QmlAst
19
20 let register_css_ident css_ident =
21 try
22 let css = QmlAstCons.UntypedExpr.ident css_ident in
23 let reg_ident = OpaMapToIdent.val_ Opacapi.Client_code.register_css_declaration in
24 let reg = QmlAstCons.UntypedExpr.ident reg_ident in
25 let reg_apply = QmlAstCons.UntypedExpr.apply reg [css] in
26 let reg_ident = Ident.next "css_registering" in
27 let label = Annot.nolabel "Opa_AddCSS.perform" in
28 QmlAst.NewVal (label, [(reg_ident, reg_apply)])
29 with Not_found ->
30 OManager.i_error
31 "Value register_css_declaration is not found. Can't generate the css file..."
32
33 let perform code =
34 let acc =
35 List.fold_left (
36 fun acc -> function
37 | Q.NewVal (_a,iel)
38 | Q.NewValRec (_a,iel) ->
39 List.fold_left (fun acc (i,_) -> if Ident.original_name i = "css" then i :: acc else acc) acc iel
40 | _ -> acc
41 ) [] code in
42 let decs = List.rev_map register_css_ident acc in
43 code @ decs
Something went wrong with that request. Please try again.