Commit | Line | Data |
---|---|---|
feec80c3 C |
1 | (****************************************************************************** |
2 | * Sexplib * | |
3 | * * | |
4 | * Copyright (C) 2005- Jane Street Holding, LLC * | |
5 | * Contact: opensource@janestreet.com * | |
6 | * WWW: http://www.janestreet.com/ocaml * | |
7 | * Author: Markus Mottl * | |
8 | * * | |
9 | * This library is free software; you can redistribute it and/or * | |
10 | * modify it under the terms of the GNU Lesser General Public * | |
11 | * License as published by the Free Software Foundation; either * | |
12 | * version 2 of the License, or (at your option) any later version. * | |
13 | * * | |
14 | * This library is distributed in the hope that it will be useful, * | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * | |
17 | * Lesser General Public License for more details. * | |
18 | * * | |
19 | * You should have received a copy of the GNU Lesser General Public * | |
20 | * License along with this library; if not, write to the Free Software * | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
22 | * * | |
23 | ******************************************************************************) | |
24 | ||
25 | let register exc exc_name = | |
26 | Conv.Exn_converter.add_auto exc (fun _exc -> Sexp.Atom exc_name) | |
27 | ||
28 | let magic_field repr n = Obj.magic (Obj.field repr n) | |
29 | ||
30 | let register1 make_exc exc_name | |
31 | sexp_of_arg1 = | |
32 | let exc = | |
33 | make_exc | |
34 | (Obj.magic 0) | |
35 | in | |
36 | Conv.Exn_converter.add_auto exc (fun exc -> | |
37 | let repr = Obj.repr exc in | |
38 | let sexp1 = sexp_of_arg1 (magic_field repr 1) in | |
39 | Sexp.List [ | |
40 | Sexp.Atom exc_name; | |
41 | sexp1; | |
42 | ]) | |
43 | ||
44 | let register2 make_exc exc_name | |
45 | sexp_of_arg1 sexp_of_arg2 = | |
46 | let exc = | |
47 | make_exc | |
48 | (Obj.magic 0) (Obj.magic 0) | |
49 | in | |
50 | Conv.Exn_converter.add_auto exc (fun exc -> | |
51 | let repr = Obj.repr exc in | |
52 | let sexp1 = sexp_of_arg1 (magic_field repr 1) in | |
53 | let sexp2 = sexp_of_arg2 (magic_field repr 2) in | |
54 | Sexp.List [ | |
55 | Sexp.Atom exc_name; | |
56 | sexp1; sexp2; | |
57 | ]) | |
58 | ||
59 | let register3 make_exc exc_name | |
60 | sexp_of_arg1 sexp_of_arg2 sexp_of_arg3 = | |
61 | let exc = | |
62 | make_exc | |
63 | (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) | |
64 | in | |
65 | Conv.Exn_converter.add_auto exc (fun exc -> | |
66 | let repr = Obj.repr exc in | |
67 | let sexp1 = sexp_of_arg1 (magic_field repr 1) in | |
68 | let sexp2 = sexp_of_arg2 (magic_field repr 2) in | |
69 | let sexp3 = sexp_of_arg3 (magic_field repr 3) in | |
70 | Sexp.List [ | |
71 | Sexp.Atom exc_name; | |
72 | sexp1; sexp2; sexp3; | |
73 | ]) | |
74 | ||
75 | let register4 make_exc exc_name | |
76 | sexp_of_arg1 sexp_of_arg2 sexp_of_arg3 sexp_of_arg4 = | |
77 | let exc = | |
78 | make_exc | |
79 | (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) | |
80 | in | |
81 | Conv.Exn_converter.add_auto exc (fun exc -> | |
82 | let repr = Obj.repr exc in | |
83 | let sexp1 = sexp_of_arg1 (magic_field repr 1) in | |
84 | let sexp2 = sexp_of_arg2 (magic_field repr 2) in | |
85 | let sexp3 = sexp_of_arg3 (magic_field repr 3) in | |
86 | let sexp4 = sexp_of_arg4 (magic_field repr 4) in | |
87 | Sexp.List [ | |
88 | Sexp.Atom exc_name; | |
89 | sexp1; sexp2; sexp3; sexp4; | |
90 | ]) | |
91 | ||
92 | let register5 make_exc exc_name | |
93 | sexp_of_arg1 sexp_of_arg2 sexp_of_arg3 sexp_of_arg4 sexp_of_arg5 = | |
94 | let exc = | |
95 | make_exc | |
96 | (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) | |
97 | in | |
98 | Conv.Exn_converter.add_auto exc (fun exc -> | |
99 | let repr = Obj.repr exc in | |
100 | let sexp1 = sexp_of_arg1 (magic_field repr 1) in | |
101 | let sexp2 = sexp_of_arg2 (magic_field repr 2) in | |
102 | let sexp3 = sexp_of_arg3 (magic_field repr 3) in | |
103 | let sexp4 = sexp_of_arg4 (magic_field repr 4) in | |
104 | let sexp5 = sexp_of_arg5 (magic_field repr 5) in | |
105 | Sexp.List [ | |
106 | Sexp.Atom exc_name; | |
107 | sexp1; sexp2; sexp3; sexp4; sexp5; | |
108 | ]) | |
109 | ||
110 | let register6 make_exc exc_name | |
111 | sexp_of_arg1 sexp_of_arg2 sexp_of_arg3 sexp_of_arg4 sexp_of_arg5 | |
112 | sexp_of_arg6 = | |
113 | let exc = | |
114 | make_exc | |
115 | (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) | |
116 | (Obj.magic 0) | |
117 | in | |
118 | Conv.Exn_converter.add_auto exc (fun exc -> | |
119 | let repr = Obj.repr exc in | |
120 | let sexp1 = sexp_of_arg1 (magic_field repr 1) in | |
121 | let sexp2 = sexp_of_arg2 (magic_field repr 2) in | |
122 | let sexp3 = sexp_of_arg3 (magic_field repr 3) in | |
123 | let sexp4 = sexp_of_arg4 (magic_field repr 4) in | |
124 | let sexp5 = sexp_of_arg5 (magic_field repr 5) in | |
125 | let sexp6 = sexp_of_arg6 (magic_field repr 6) in | |
126 | Sexp.List [ | |
127 | Sexp.Atom exc_name; | |
128 | sexp1; sexp2; sexp3; sexp4; sexp5; sexp6; | |
129 | ]) | |
130 | ||
131 | let register7 make_exc exc_name | |
132 | sexp_of_arg1 sexp_of_arg2 sexp_of_arg3 sexp_of_arg4 sexp_of_arg5 | |
133 | sexp_of_arg6 sexp_of_arg7 = | |
134 | let exc = | |
135 | make_exc | |
136 | (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) | |
137 | (Obj.magic 0) (Obj.magic 0) | |
138 | in | |
139 | Conv.Exn_converter.add_auto exc (fun exc -> | |
140 | let repr = Obj.repr exc in | |
141 | let sexp1 = sexp_of_arg1 (magic_field repr 1) in | |
142 | let sexp2 = sexp_of_arg2 (magic_field repr 2) in | |
143 | let sexp3 = sexp_of_arg3 (magic_field repr 3) in | |
144 | let sexp4 = sexp_of_arg4 (magic_field repr 4) in | |
145 | let sexp5 = sexp_of_arg5 (magic_field repr 5) in | |
146 | let sexp6 = sexp_of_arg6 (magic_field repr 6) in | |
147 | let sexp7 = sexp_of_arg7 (magic_field repr 7) in | |
148 | Sexp.List [ | |
149 | Sexp.Atom exc_name; | |
150 | sexp1; sexp2; sexp3; sexp4; sexp5; sexp6; sexp7; | |
151 | ]) | |
152 | ||
153 | let register8 make_exc exc_name | |
154 | sexp_of_arg1 sexp_of_arg2 sexp_of_arg3 sexp_of_arg4 sexp_of_arg5 | |
155 | sexp_of_arg6 sexp_of_arg7 sexp_of_arg8 = | |
156 | let exc = | |
157 | make_exc | |
158 | (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) | |
159 | (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) | |
160 | in | |
161 | Conv.Exn_converter.add_auto exc (fun exc -> | |
162 | let repr = Obj.repr exc in | |
163 | let sexp1 = sexp_of_arg1 (magic_field repr 1) in | |
164 | let sexp2 = sexp_of_arg2 (magic_field repr 2) in | |
165 | let sexp3 = sexp_of_arg3 (magic_field repr 3) in | |
166 | let sexp4 = sexp_of_arg4 (magic_field repr 4) in | |
167 | let sexp5 = sexp_of_arg5 (magic_field repr 5) in | |
168 | let sexp6 = sexp_of_arg6 (magic_field repr 6) in | |
169 | let sexp7 = sexp_of_arg7 (magic_field repr 7) in | |
170 | let sexp8 = sexp_of_arg8 (magic_field repr 8) in | |
171 | Sexp.List [ | |
172 | Sexp.Atom exc_name; | |
173 | sexp1; sexp2; sexp3; sexp4; sexp5; sexp6; sexp7; sexp8; | |
174 | ]) | |
175 | ||
176 | let register9 make_exc exc_name | |
177 | sexp_of_arg1 sexp_of_arg2 sexp_of_arg3 sexp_of_arg4 sexp_of_arg5 | |
178 | sexp_of_arg6 sexp_of_arg7 sexp_of_arg8 sexp_of_arg9 = | |
179 | let exc = | |
180 | make_exc | |
181 | (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) | |
182 | (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) | |
183 | in | |
184 | Conv.Exn_converter.add_auto exc (fun exc -> | |
185 | let repr = Obj.repr exc in | |
186 | let sexp1 = sexp_of_arg1 (magic_field repr 1) in | |
187 | let sexp2 = sexp_of_arg2 (magic_field repr 2) in | |
188 | let sexp3 = sexp_of_arg3 (magic_field repr 3) in | |
189 | let sexp4 = sexp_of_arg4 (magic_field repr 4) in | |
190 | let sexp5 = sexp_of_arg5 (magic_field repr 5) in | |
191 | let sexp6 = sexp_of_arg6 (magic_field repr 6) in | |
192 | let sexp7 = sexp_of_arg7 (magic_field repr 7) in | |
193 | let sexp8 = sexp_of_arg8 (magic_field repr 8) in | |
194 | let sexp9 = sexp_of_arg9 (magic_field repr 9) in | |
195 | Sexp.List [ | |
196 | Sexp.Atom exc_name; | |
197 | sexp1; sexp2; sexp3; sexp4; sexp5; sexp6; sexp7; sexp8; sexp9; | |
198 | ]) | |
199 | ||
200 | let register10 make_exc exc_name | |
201 | sexp_of_arg1 sexp_of_arg2 sexp_of_arg3 sexp_of_arg4 sexp_of_arg5 | |
202 | sexp_of_arg6 sexp_of_arg7 sexp_of_arg8 sexp_of_arg9 sexp_of_arg10 = | |
203 | let exc = | |
204 | make_exc | |
205 | (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) | |
206 | (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) (Obj.magic 0) | |
207 | in | |
208 | Conv.Exn_converter.add_auto exc (fun exc -> | |
209 | let repr = Obj.repr exc in | |
210 | let sexp1 = sexp_of_arg1 (magic_field repr 1) in | |
211 | let sexp2 = sexp_of_arg2 (magic_field repr 2) in | |
212 | let sexp3 = sexp_of_arg3 (magic_field repr 3) in | |
213 | let sexp4 = sexp_of_arg4 (magic_field repr 4) in | |
214 | let sexp5 = sexp_of_arg5 (magic_field repr 5) in | |
215 | let sexp6 = sexp_of_arg6 (magic_field repr 6) in | |
216 | let sexp7 = sexp_of_arg7 (magic_field repr 7) in | |
217 | let sexp8 = sexp_of_arg8 (magic_field repr 8) in | |
218 | let sexp9 = sexp_of_arg9 (magic_field repr 9) in | |
219 | let sexp10 = sexp_of_arg10 (magic_field repr 10) in | |
220 | Sexp.List [ | |
221 | Sexp.Atom exc_name; | |
222 | sexp1; sexp2; sexp3; sexp4; sexp5; sexp6; sexp7; sexp8; sexp9; sexp10; | |
223 | ]) |