File: 0002-Fix-calls-to-caml_-functions.patch

package info (click to toggle)
labltk 8.06.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,084 kB
  • ctags: 2,334
  • sloc: ml: 12,266; ansic: 1,014; makefile: 567; sh: 279; tcl: 2
file content (405 lines) | stat: -rw-r--r-- 13,912 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
From: Stephane Glondu <steph@glondu.net>
Date: Sun, 16 Jul 2017 08:18:09 +0000
Subject: Fix calls to caml_* functions

---
 support/cltkCaml.c  |  6 +++---
 support/cltkDMain.c |  8 ++++----
 support/cltkEval.c  | 20 ++++++++++----------
 support/cltkEvent.c |  2 +-
 support/cltkFile.c  |  2 +-
 support/cltkImg.c   |  2 +-
 support/cltkMain.c  | 14 +++++++-------
 support/cltkMisc.c  |  8 ++++----
 support/cltkTimer.c |  2 +-
 support/cltkUtf.c   |  6 +++---
 support/cltkVar.c   | 14 +++++++-------
 support/cltkWait.c  | 12 ++++++------
 12 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/support/cltkCaml.c b/support/cltkCaml.c
index 4234dde..9c2928a 100644
--- a/support/cltkCaml.c
+++ b/support/cltkCaml.c
@@ -39,7 +39,7 @@ int CamlCBCmd(ClientData clientdata, Tcl_Interp *interp,
     int id;
     if (Tcl_GetInt(interp, argv[1], &id) != TCL_OK)
       return TCL_ERROR;
-    callback2(*handler_code,Val_int(id),
+    caml_callback2(*handler_code,Val_int(id),
               copy_string_list(argc - 2,(char **)&argv[2]));
     /* Never fails (OCaml would have raised an exception) */
     /* but result may have been set by callback */
@@ -62,10 +62,10 @@ CAMLprim value camltk_return (value v)
   return Val_unit;
 }
 
-/* Note: raise_with_string WILL copy the error message */
+/* Note: caml_raise_with_string WILL copy the error message */
 CAMLprim void tk_error(const char *errmsg)
 {
-  raise_with_string(*tkerror_exn, errmsg);
+  caml_raise_with_string(*tkerror_exn, errmsg);
 }
 
 
diff --git a/support/cltkDMain.c b/support/cltkDMain.c
index 58374d8..3edcb34 100644
--- a/support/cltkDMain.c
+++ b/support/cltkDMain.c
@@ -52,11 +52,11 @@ void invoke_pending_caml_signals (clientdata)
      ClientData clientdata;
 {
   signal_events = 0;
-  enter_blocking_section(); /* triggers signal handling */
+  caml_enter_blocking_section(); /* triggers signal handling */
   /* Rearm timer */
   Tk_CreateTimerHandler(SIGNAL_INTERVAL, invoke_pending_caml_signals, NULL);
   signal_events = 1;
-  leave_blocking_section();
+  caml_leave_blocking_section();
 }
 /* The following is taken from byterun/startup.c */
 header_t atom_table[256];
@@ -222,10 +222,10 @@ int Caml_Init(interp)
       strcat(f, RCNAME);
       if (0 == access(f,R_OK))
         if (TCL_OK != Tcl_EvalFile(cltclinterp,f)) {
-          stat_free(f);
+          caml_stat_free(f);
           tk_error(Tcl_GetStringResult(cltclinterp));
         };
-      stat_free(f);
+      caml_stat_free(f);
     }
   }
 
diff --git a/support/cltkEval.c b/support/cltkEval.c
index c7a4348..87291e5 100644
--- a/support/cltkEval.c
+++ b/support/cltkEval.c
@@ -45,7 +45,7 @@ value copy_string_list(int argc, char **argv)
   for (i = argc-1; i >= 0; i--) {
     oldres = res;
     str = tcl_string_to_caml(argv[i]);
-    res = alloc(2, 0);
+    res = caml_alloc(2, 0);
     Field(res, 0) = str;
     Field(res, 1) = oldres;
   }
@@ -71,7 +71,7 @@ CAMLprim value camltk_tcl_eval(value str)
   Tcl_ResetResult(cltclinterp);
   cmd = caml_string_to_tcl(str);
   code = Tcl_Eval(cltclinterp, cmd);
-  stat_free(cmd);
+  caml_stat_free(cmd);
 
   switch (code) {
   case TCL_OK:
@@ -128,7 +128,7 @@ int fill_args (char **argv, int where, value v)
 
   switch (Tag_val(v)) {
   case 0:
-    argv[where] = caml_string_to_tcl(Field(v,0)); /* must free by stat_free */
+    argv[where] = caml_string_to_tcl(Field(v,0)); /* must free by caml_stat_free */
     return (where + 1);
   case 1:
     for (l=Field(v,0); Is_block(l); l=Field(l,1))
@@ -143,9 +143,9 @@ int fill_args (char **argv, int where, value v)
       fill_args(tmpargv,0,Field(v,0));
       tmpargv[size] = NULL;
       merged = Tcl_Merge(size,(const char *const*)tmpargv);
-      for(i = 0; i<size; i++){ stat_free(tmpargv[i]); }
-      stat_free((char *)tmpargv);
-      /* must be freed by stat_free */
+      for(i = 0; i<size; i++){ caml_stat_free(tmpargv[i]); }
+      caml_stat_free((char *)tmpargv);
+      /* must be freed by caml_stat_free */
       argv[where] = (char*)caml_stat_alloc(strlen(merged)+1);
       strcpy(argv[where], merged);
       Tcl_Free(merged);
@@ -176,7 +176,7 @@ CAMLprim value camltk_tcl_direct_eval(value v)
   argv = (char **)caml_stat_alloc((size + 2) * sizeof(char *));
   allocated = (char **)caml_stat_alloc(size * sizeof(char *));
 
-  /* Copy -- argv[i] must be freed by stat_free */
+  /* Copy -- argv[i] must be freed by caml_stat_free */
   {
     int where;
     for(i=0, where=0; i<Wosize_val(v); i++){
@@ -227,10 +227,10 @@ CAMLprim value camltk_tcl_direct_eval(value v)
 
   /* Free the various things we allocated */
   for(i=0; i< size; i ++){
-    stat_free((char *) allocated[i]);
+    caml_stat_free((char *) allocated[i]);
   }
-  stat_free((char *)argv);
-  stat_free((char *)allocated);
+  caml_stat_free((char *)argv);
+  caml_stat_free((char *)allocated);
 
   switch (result) {
   case TCL_OK:
diff --git a/support/cltkEvent.c b/support/cltkEvent.c
index c9d0662..6ab2e6c 100644
--- a/support/cltkEvent.c
+++ b/support/cltkEvent.c
@@ -49,6 +49,6 @@ CAMLprim value camltk_dooneevent(value flags)
 
   CheckInit();
 
-  ret = Tk_DoOneEvent(convert_flag_list(flags, event_flag_table));
+  ret = Tk_DoOneEvent(caml_convert_flag_list(flags, event_flag_table));
   return Val_int(ret);
 }
diff --git a/support/cltkFile.c b/support/cltkFile.c
index c01f395..47b1bcf 100644
--- a/support/cltkFile.c
+++ b/support/cltkFile.c
@@ -33,7 +33,7 @@
 
 void FileProc(ClientData clientdata, int mask)
 {
-  callback2(*handler_code,Val_int(clientdata),Val_int(0));
+  caml_callback2(*handler_code,Val_int(clientdata),Val_int(0));
 }
 
 /* Map Unix.file_descr values to Tcl file handles */
diff --git a/support/cltkImg.c b/support/cltkImg.c
index 310cb27..0537516 100644
--- a/support/cltkImg.c
+++ b/support/cltkImg.c
@@ -47,7 +47,7 @@ CAMLprim value camltk_getimgdata (value imgname) /* ML */
 
   code = Tk_PhotoGetImage(ph,&pib); /* never fails ? */
   size = pib.width * pib.height * pib.pixelSize;
-  res = alloc_string(size);
+  res = caml_alloc_string(size);
 
   /* no holes, default format ? */
   if ((pib.pixelSize == 3) &&
diff --git a/support/cltkMain.c b/support/cltkMain.c
index 871a47a..9d65e11 100644
--- a/support/cltkMain.c
+++ b/support/cltkMain.c
@@ -51,11 +51,11 @@ int signal_events = 0; /* do we have a pending timer */
 void invoke_pending_caml_signals (ClientData clientdata)
 {
   signal_events = 0;
-  enter_blocking_section(); /* triggers signal handling */
+  caml_enter_blocking_section(); /* triggers signal handling */
   /* Rearm timer */
   Tk_CreateTimerHandler(SIGNAL_INTERVAL, invoke_pending_caml_signals, NULL);
   signal_events = 1;
-  leave_blocking_section();
+  caml_leave_blocking_section();
 }
 
 /* Now the real Tk stuff */
@@ -77,7 +77,7 @@ CAMLprim value camltk_opentk(value argv)
   tmp = Val_unit;
 
   if ( argv == Val_int(0) ){
-    failwith("camltk_opentk: argv is empty");
+    caml_failwith("camltk_opentk: argv is empty");
   }
   argv0 = String_val( Field( argv, 0 ) );
 
@@ -91,7 +91,7 @@ CAMLprim value camltk_opentk(value argv)
       /* Register cltclinterp for use in other related extensions */
       value *interp = caml_named_value("cltclinterp");
       if (interp != NULL)
-        Store_field(*interp,0,copy_nativeint((intnat)cltclinterp));
+        Store_field(*interp,0,caml_copy_nativeint((intnat)cltclinterp));
     }
 
     if (Tcl_Init(cltclinterp) != TCL_OK)
@@ -128,7 +128,7 @@ CAMLprim value camltk_opentk(value argv)
         args = Tcl_Merge(argc, (const char *const*)tkargv); /* args must be freed by Tcl_Free */
         Tcl_SetVar(cltclinterp, "argv", args, TCL_GLOBAL_ONLY);
         Tcl_Free(args);
-        stat_free( tkargv );
+        caml_stat_free( tkargv );
       }
     }
     if (Tk_Init(cltclinterp) != TCL_OK)
@@ -164,10 +164,10 @@ CAMLprim value camltk_opentk(value argv)
       strcat(f, RCNAME);
       if (0 == access(f,R_OK))
         if (TCL_OK != Tcl_EvalFile(cltclinterp,f)) {
-          stat_free(f);
+          caml_stat_free(f);
           tk_error(Tcl_GetStringResult(cltclinterp));
         };
-      stat_free(f);
+      caml_stat_free(f);
     }
   }
 
diff --git a/support/cltkMisc.c b/support/cltkMisc.c
index 52c5d48..8d6b5f2 100644
--- a/support/cltkMisc.c
+++ b/support/cltkMisc.c
@@ -41,20 +41,20 @@ CAMLprim value camltk_splitlist (value v)
    { value res = copy_string_list(argc,argv);
      Tcl_Free((char *)argv);    /* only one large block was allocated */
      /* argv points into utf: utf must be freed after argv are freed */
-     stat_free( utf );
+     caml_stat_free( utf );
      return res;
    }
   case TCL_ERROR:
   default:
-    stat_free( utf );
+    caml_stat_free( utf );
     tk_error(Tcl_GetStringResult(cltclinterp));
   }
 }
 
-/* Copy an OCaml string to the C heap. Should deallocate with stat_free */
+/* Copy an OCaml string to the C heap. Should deallocate with caml_stat_free */
 char *string_to_c(value s)
 {
-  int l = string_length(s);
+  int l = caml_string_length(s);
   char *res = caml_stat_alloc(l + 1);
   memmove (res, String_val (s), l);
   res[l] = '\0';
diff --git a/support/cltkTimer.c b/support/cltkTimer.c
index afebef8..2022d78 100644
--- a/support/cltkTimer.c
+++ b/support/cltkTimer.c
@@ -26,7 +26,7 @@
 /* Basically the same thing as FileProc */
 void TimerProc (ClientData clientdata)
 {
-  callback2(*handler_code,Val_long(clientdata),Val_int(0));
+  caml_callback2(*handler_code,Val_long(clientdata),Val_int(0));
 }
 
 CAMLprim value camltk_add_timer(value milli, value cbid)
diff --git a/support/cltkUtf.c b/support/cltkUtf.c
index eb33500..d4f86c1 100644
--- a/support/cltkUtf.c
+++ b/support/cltkUtf.c
@@ -76,14 +76,14 @@ value tcl_string_to_caml( const char *s )
   char *str;
 
   str = utf_to_external( s );
-  res = copy_string(str);
-  stat_free(str);
+  res = caml_copy_string(str);
+  caml_stat_free(str);
   CAMLreturn(res);
 }
 
 #else
 
 char *caml_string_to_tcl(value s){ return string_to_c(s); }
-value tcl_string_to_caml(char *s){ return copy_string(s); }
+value tcl_string_to_caml(char *s){ return caml_copy_string(s); }
 
 #endif
diff --git a/support/cltkVar.c b/support/cltkVar.c
index e647d9d..09276fe 100644
--- a/support/cltkVar.c
+++ b/support/cltkVar.c
@@ -35,7 +35,7 @@ CAMLprim value camltk_getvar(value var)
   stable_var = string_to_c(var);
   s = (char *)Tcl_GetVar(cltclinterp,stable_var,
                          TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG);
-  stat_free(stable_var);
+  caml_stat_free(stable_var);
 
   if (s == NULL)
     tk_error(Tcl_GetStringResult(cltclinterp));
@@ -57,11 +57,11 @@ CAMLprim value camltk_setvar(value var, value contents)
   utf_contents = caml_string_to_tcl(contents);
   s = (char *)Tcl_SetVar(cltclinterp,stable_var, utf_contents,
                          TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG);
-  stat_free(stable_var);
+  caml_stat_free(stable_var);
   if( s == utf_contents ){
     tk_error("camltk_setvar: Tcl_SetVar returned strange result. Call the author of mlTk!");
   }
-  stat_free(utf_contents);
+  caml_stat_free(utf_contents);
 
   if (s == NULL)
     tk_error(Tcl_GetStringResult(cltclinterp));
@@ -84,7 +84,7 @@ static char * tracevar(clientdata, interp, name1, name2, flags)
   Tcl_UntraceVar2(interp, name1, name2,
                 TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
                 tracevar, clientdata);
-  callback2(*handler_code,Val_int(clientdata),Val_unit);
+  caml_callback2(*handler_code,Val_int(clientdata),Val_unit);
   return (char *)NULL;
 }
 
@@ -103,10 +103,10 @@ CAMLprim value camltk_trace_var(value var, value cbid)
                    tracevar,
                    (ClientData) (Long_val(cbid)))
                    != TCL_OK) {
-    stat_free(cvar);
+    caml_stat_free(cvar);
     tk_error(Tcl_GetStringResult(cltclinterp));
   };
-  stat_free(cvar);
+  caml_stat_free(cvar);
   return Val_unit;
 }
 
@@ -123,6 +123,6 @@ CAMLprim value camltk_untrace_var(value var, value cbid)
                  TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
                  tracevar,
                  (ClientData) (Long_val(cbid)));
-  stat_free(cvar);
+  caml_stat_free(cvar);
   return Val_unit;
 }
diff --git a/support/cltkWait.c b/support/cltkWait.c
index e13091f..1258bd8 100644
--- a/support/cltkWait.c
+++ b/support/cltkWait.c
@@ -54,8 +54,8 @@ static void WaitVisibilityProc(clientData, eventPtr)
   Tk_DeleteEventHandler(vis->win, VisibilityChangeMask,
             WaitVisibilityProc, clientData);
 
-  stat_free((char *)vis);
-  callback2(*handler_code,cbid,Val_int(0));
+  caml_stat_free((char *)vis);
+  caml_callback2(*handler_code,cbid,Val_int(0));
 }
 
 /* Sets up a callback upon Visibility of a window */
@@ -65,7 +65,7 @@ CAMLprim value camltk_wait_vis(value win, value cbid)
     (struct WinCBData *)caml_stat_alloc(sizeof(struct WinCBData));
   vis->win = Tk_NameToWindow(cltclinterp, String_val(win), cltk_mainWindow);
   if (vis -> win == NULL) {
-    stat_free((char *)vis);
+    caml_stat_free((char *)vis);
     tk_error(Tcl_GetStringResult(cltclinterp));
   };
   vis->cbid = Int_val(cbid);
@@ -79,9 +79,9 @@ static void WaitWindowProc(ClientData clientData, XEvent *eventPtr)
   if (eventPtr->type == DestroyNotify) {
     struct WinCBData *vis = clientData;
     value cbid = Val_int(vis->cbid);
-    stat_free((char *)clientData);
+    caml_stat_free((char *)clientData);
     /* The handler is destroyed by Tk itself */
-    callback2(*handler_code,cbid,Val_int(0));
+    caml_callback2(*handler_code,cbid,Val_int(0));
   }
 }
 
@@ -92,7 +92,7 @@ CAMLprim value camltk_wait_des(value win, value cbid)
     (struct WinCBData *)caml_stat_alloc(sizeof(struct WinCBData));
   vis->win = Tk_NameToWindow(cltclinterp, String_val(win), cltk_mainWindow);
   if (vis -> win == NULL) {
-    stat_free((char *)vis);
+    caml_stat_free((char *)vis);
     tk_error(Tcl_GetStringResult(cltclinterp));
   };
   vis->cbid = Int_val(cbid);