4 Manage per-session theory exports: compressed blobs. |
4 Manage per-session theory exports: compressed blobs. |
5 *) |
5 *) |
6 |
6 |
7 signature EXPORT = |
7 signature EXPORT = |
8 sig |
8 sig |
9 val report_export: theory -> Path.binding -> unit |
9 val report: Context.generic -> string -> Path.binding -> unit |
10 type params = |
10 type params = |
11 {theory: theory, binding: Path.binding, executable: bool, compress: bool, strict: bool} |
11 {theory_name: string, binding: Path.binding, executable: bool, compress: bool, strict: bool} |
12 val export_params: params -> XML.body -> unit |
12 val export_params: Context.generic -> params -> XML.body -> unit |
13 val export: theory -> Path.binding -> XML.body -> unit |
13 val export: theory -> Path.binding -> XML.body -> unit |
14 val export_executable: theory -> Path.binding -> XML.body -> unit |
14 val export_executable: theory -> Path.binding -> XML.body -> unit |
15 val export_file: theory -> Path.binding -> Path.T -> unit |
15 val export_file: theory -> Path.binding -> Path.T -> unit |
16 val export_executable_file: theory -> Path.binding -> Path.T -> unit |
16 val export_executable_file: theory -> Path.binding -> Path.T -> unit |
17 val markup: theory -> Path.T -> Markup.T |
17 val markup: theory -> Path.T -> Markup.T |
21 structure Export: EXPORT = |
21 structure Export: EXPORT = |
22 struct |
22 struct |
23 |
23 |
24 (* export *) |
24 (* export *) |
25 |
25 |
26 fun report_export thy binding = |
26 fun report context theory_name binding = |
27 let |
27 let |
28 val theory_name = Context.theory_long_name thy; |
|
29 val (path, pos) = Path.dest_binding binding; |
28 val (path, pos) = Path.dest_binding binding; |
30 val markup = Markup.export_path (Path.implode (Path.basic theory_name + path)); |
29 val markup = Markup.export_path (Path.implode (Path.basic theory_name + path)); |
31 in Context_Position.report_generic (Context.Theory thy) pos markup end; |
30 in Context_Position.report_generic context pos markup end; |
32 |
31 |
33 type params = |
32 type params = |
34 {theory: theory, binding: Path.binding, executable: bool, compress: bool, strict: bool}; |
33 {theory_name: string, binding: Path.binding, executable: bool, compress: bool, strict: bool}; |
35 |
34 |
36 fun export_params ({theory = thy, binding, executable, compress, strict}: params) body = |
35 fun export_params context ({theory_name, binding, executable, compress, strict}: params) body = |
37 (report_export thy binding; |
36 (report context theory_name binding; |
38 (Output.try_protocol_message o Markup.export) |
37 (Output.try_protocol_message o Markup.export) |
39 {id = Position.id_of (Position.thread_data ()), |
38 {id = Position.id_of (Position.thread_data ()), |
40 serial = serial (), |
39 serial = serial (), |
41 theory_name = Context.theory_long_name thy, |
40 theory_name = theory_name, |
42 name = Path.implode_binding (tap Path.proper_binding binding), |
41 name = Path.implode_binding (tap Path.proper_binding binding), |
43 executable = executable, |
42 executable = executable, |
44 compress = compress, |
43 compress = compress, |
45 strict = strict} [body]); |
44 strict = strict} [body]); |
46 |
45 |
47 fun export thy binding body = |
46 fun export thy binding body = |
48 export_params |
47 export_params (Context.Theory thy) |
49 {theory = thy, binding = binding, executable = false, compress = true, strict = true} body; |
48 {theory_name = Context.theory_long_name thy, binding = binding, |
|
49 executable = false, compress = true, strict = true} body; |
50 |
50 |
51 fun export_executable thy binding body = |
51 fun export_executable thy binding body = |
52 export_params |
52 export_params (Context.Theory thy) |
53 {theory = thy, binding = binding, executable = true, compress = true, strict = true} body; |
53 {theory_name = Context.theory_long_name thy, binding = binding, |
|
54 executable = true, compress = true, strict = true} body; |
54 |
55 |
55 fun export_file thy binding file = |
56 fun export_file thy binding file = |
56 export thy binding (Bytes.contents_blob (Bytes.read file)); |
57 export thy binding (Bytes.contents_blob (Bytes.read file)); |
57 |
58 |
58 fun export_executable_file thy binding file = |
59 fun export_executable_file thy binding file = |