summaryrefslogtreecommitdiffstats
path: root/test/Moretest/callbackprim.c
blob: 98a131b2c3e7c733203169856193147c90b0d0f0 (plain)
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
#include "../byterun/mlvalues.h"
#include "../byterun/memory.h"

value mycallback1(fun, arg)
     value fun, arg;
{
  value res;
  Push_roots(r, 2);
  r[0] = fun;
  r[1] = arg;
  res = callback(fun, arg);
  Pop_roots();
  return res;
}

value mycallback2(fun, arg1, arg2)
     value fun, arg1, arg2;
{
  value res;
  Push_roots(r, 3);
  r[0] = fun;
  r[1] = arg1;
  r[2] = arg2;
  res = callback2(fun, arg1, arg2);
  Pop_roots();
  return res;
}

value mycallback3(fun, arg1, arg2, arg3)
     value fun, arg1, arg2, arg3;
{
  value res;
  Push_roots(r, 4);
  r[0] = fun;
  r[1] = arg1;
  r[2] = arg2;
  r[3] = arg3;
  res = callback3(fun, arg1, arg2, arg3);
  Pop_roots();
  return res;
}

value mypushroot(v, fun, arg)
     value v, fun, arg;
{
  Push_roots(r, 1);
  r[0] = v;
  callback(fun, arg);
  v = r[0];
  Pop_roots();
  return v;
}