~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to routines/graphics/Xcall.c

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* C code produced by gperf version 2.7.1 (19981006 egcs) */
 
2
/* Command-line: gperf -C -t -k 2,3,4,$ Xcall.gperf  */
 
3
 
 
4
/*------------------------------------------------------------------------
 
5
    Graphic library for 2D and 3D plotting 
 
6
    Copyright (C) 1998 Chancelier Jean-Philippe
 
7
    jpc@cergrene.enpc.fr 
 
8
 --------------------------------------------------------------------------*/
 
9
#include <string.h>
 
10
#include <stdio.h>
 
11
 
 
12
#ifdef MAC
 
13
#include "../machine.h"
 
14
#include "periMac.h"
 
15
#else 
 
16
#ifdef WIN32
 
17
#include "Math.h"
 
18
#include "periWin.h"
 
19
#else
 
20
#include "Math.h"
 
21
#include "periX11.h"
 
22
#endif
 
23
#endif 
 
24
 
 
25
#include "periPos.h"
 
26
#include "periFig.h"
 
27
#include "periGif.h"
 
28
 
 
29
#define const 
 
30
 
 
31
/*---------------------------------------------------------------
 
32
 * The basic graphic driver is X11 
 
33
 *    The name is X11 due to historical reasons 
 
34
 *    but according to architecture X11 can be an Xwindow driver 
 
35
 *    a driver for Macintosh 
 
36
 *    or a Windows driver 
 
37
 * Other drivers are Postscript Fig ( xfig ) and Rec ( Rec= X11 + Recording capabilities) 
 
38
 *    xfig is only meaningfull when using Unix machine 
 
39
 * ----------------------------------------------------------------*/
 
40
 
 
41
static void C2F(all)();
 
42
 
 
43
static void C2F(vide)(v1, v2, v3, v4, v5, v6, v7, dv1, dv2, dv3, dv4)
 
44
     char *v1;
 
45
     integer *v2;
 
46
     integer *v3;
 
47
     integer *v4;
 
48
     integer *v5;
 
49
     integer *v6;
 
50
     integer *v7;
 
51
     double *dv1;
 
52
     double *dv2;
 
53
     double *dv3;
 
54
     double *dv4;
 
55
{}
 
56
typedef void (*func)();
 
57
typedef void (function)() ;
 
58
struct funreplace { char *name; func action[4]; };
 
59
 
 
60
#define TOTAL_KEYWORDS 40
 
61
#define MIN_WORD_LENGTH 4
 
62
#define MAX_WORD_LENGTH 9
 
63
#define MIN_HASH_VALUE 4
 
64
#define MAX_HASH_VALUE 141
 
65
/* maximum key range = 138, duplicates = 0 */
 
66
 
 
67
#ifdef __GNUC__
 
68
__inline
 
69
#endif
 
70
static unsigned int
 
71
hash (str, len)
 
72
     char *str;
 
73
     unsigned int len;
 
74
{
 
75
  static const unsigned char asso_values[] =
 
76
    {
 
77
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
78
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
79
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
80
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
81
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
82
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
83
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
84
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
85
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
86
      142, 142, 142, 142, 142, 142, 142,  35, 142,   5,
 
87
       15,   0,  25,  33,  20,   0, 142,   5,  10,  40,
 
88
       42,  30,   0, 142,   0,   0,   0,  15, 142,  10,
 
89
       10,   0, 142, 142, 142, 142, 142, 142, 142, 142,
 
90
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
91
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
92
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
93
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
94
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
95
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
96
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
97
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
98
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
99
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
100
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
101
      142, 142, 142, 142, 142, 142, 142, 142, 142, 142,
 
102
      142, 142, 142, 142, 142, 142
 
103
    };
 
104
  return len + asso_values[(unsigned char)str[3]] + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[1]] + asso_values[(unsigned char)str[len - 1]];
 
105
}
 
106
 
 
107
#ifdef __GNUC__
 
108
__inline
 
109
#endif
 
110
const struct funreplace *
 
111
xcall_in_word_set (str, len)
 
112
     register const char *str;
 
113
     register unsigned int len;
 
114
{
 
115
  static const struct funreplace wordlist[] =
 
116
    {
 
117
      {""}, {""}, {""}, {""},
 
118
      {"xset",    {C2F(MissileGCset),C2F(scilabgcsetPos),C2F(scilabgcsetXfig),C2F(scilabgcsetGif)}},
 
119
      {""},
 
120
      {"xsetdr",    {C2F(SetDriver),C2F(SetDriver),C2F(SetDriver),C2F(SetDriver)}},
 
121
      {"xreplay",    {Tape_Replay,Tape_Replay,Tape_Replay,Tape_Replay}},
 
122
      {""}, {""},
 
123
      {"xrect",    {C2F(drawrectangle),C2F(drawrectanglePos),C2F(drawrectangleXfig),C2F(drawrectangleGif)}},
 
124
      {"xrects",    {C2F(drawrectangles),C2F(drawrectanglesPos),C2F(drawrectanglesXfig),C2F(drawrectanglesGif)}},
 
125
      {""}, {""},
 
126
      {"xreplaysc",    {Tape_ReplayNewScale,Tape_ReplayNewScale,Tape_ReplayNewScale,Tape_ReplayNewScale}},
 
127
      {""}, {""},
 
128
      {"xselect",    {C2F(xselgraphic),C2F(xselgraphicPos),C2F(xselgraphicXfig),C2F(xselgraphicGif)}},
 
129
      {"xstringl",    {C2F(boundingbox),C2F(boundingboxPos),C2F(boundingboxXfig),C2F(boundingboxGif),}},
 
130
      {""}, {""},
 
131
      {"xclear",    {C2F(clearwindow),C2F(clearwindowPos),C2F(clearwindowXfig),C2F(clearwindowGif)}},
 
132
      {""}, {""},
 
133
      {"xclickany",    {C2F(xclick_any),C2F(xclick_anyPos),C2F(xclick_anyXfig),C2F(xclick_anyGif)}},
 
134
      {""},
 
135
      {"xclick",    {C2F(xclick),C2F(xclickPos),C2F(xclickXfig),C2F(xclickGif)}},
 
136
      {""}, {""},
 
137
      {"xreplaysh",    {Tape_Replay_Show,Tape_Replay_Show,Tape_Replay_Show,Tape_Replay_Show}},
 
138
      {""},
 
139
      {"xfrect",    {C2F(fillrectangle),C2F(fillrectanglePos),C2F(fillrectangleXfig),C2F(fillrectangleGif)}},
 
140
      {""}, {""}, {""}, {""}, {""},
 
141
      {"xget",    {C2F(MissileGCget),C2F(scilabgcgetPos),C2F(scilabgcgetXfig),C2F(scilabgcgetGif)}},
 
142
      {"xsegs",    {C2F(drawsegments),C2F(drawsegmentsPos),C2F(drawsegmentsXfig),C2F(drawsegmentsGif)}},
 
143
      {"xgetdr",    {GetDriver1,GetDriver1,GetDriver1,GetDriver1}},
 
144
      {"xstring",    {C2F(displaystring),C2F(displaystringPos),C2F(displaystringXfig),C2F(displaystringGif)}},
 
145
      {"xstart",    {CleanPlots,CleanPlots,CleanPlots,CleanPlots}},
 
146
      {"xgetmouse",    {C2F(xgetmouse),C2F(xgetmousePos),C2F(xgetmouseXfig),C2F(xgetmouseGif)}},
 
147
      {""},
 
148
      {"xreplayna",    {Tape_ReplayNewAngle,Tape_ReplayNewAngle,Tape_ReplayNewAngle,Tape_ReplayNewAngle}},
 
149
      {"xarcs",    {C2F(drawarcs),C2F(drawarcsPos),C2F(drawarcsXfig),C2F(drawarcsGif)}},
 
150
      {"xpolys",    {C2F(drawpolylines),C2F(drawpolylinesPos),C2F(drawpolylinesXfig),C2F(drawpolylinesGif)}},
 
151
      {"xinit",    {C2F(initgraphic),C2F(initgraphicPos),C2F(initgraphicXfig),C2F(initgraphicGif)}},
 
152
      {""},
 
153
      {"xarc",    {C2F(drawarc),C2F(drawarcPos),C2F(drawarcXfig),C2F(drawarcGif)}},
 
154
      {"xaxis",    {C2F(drawaxis),C2F(drawaxisPos),C2F(drawaxisXfig),C2F(drawaxisGif)}},
 
155
      {"xarrow",    {C2F(drawarrows),C2F(drawarrowsPos),C2F(drawarrowsXfig),C2F(drawarrowsGif)}},
 
156
      {""}, {""}, {""},
 
157
      {"xclea",    {C2F(cleararea),C2F(clearareaPos),C2F(clearareaXfig),C2F(clearareaGif)}},
 
158
      {"xpause",    {C2F(xpause),C2F(xpausePos),C2F(xpauseXfig),C2F(xpauseGif)}},
 
159
      {""},
 
160
      {"xlines",    {C2F(drawpolyline),C2F(drawpolylinePos),C2F(drawpolylineXfig),C2F(drawpolylineGif)}},
 
161
      {"xliness",    {C2F(fillpolylines),C2F(fillpolylinesPos),C2F(fillpolylinesXfig),C2F(fillpolylinesGif)}},
 
162
      {""}, {""}, {""}, {""}, {""}, {""},
 
163
      {"xfarcs",    {C2F(fillarcs),C2F(fillarcsPos),C2F(fillarcsXfig),C2F(fillarcsGif)}},
 
164
      {""}, {""}, {""},
 
165
      {"xfarc",    {C2F(fillarc),C2F(fillarcPos),C2F(fillarcXfig),C2F(fillarcGif)}},
 
166
      {"xlfont",    {C2F(loadfamily),C2F(loadfamilyPos),C2F(loadfamilyXfig),C2F(loadfamilyGif)}},
 
167
      {""}, {""}, {""},
 
168
      {"xarea",    {C2F(fillpolyline),C2F(fillpolylinePos),C2F(fillpolylineXfig),C2F(fillpolylineGif)}},
 
169
      {"xend",    {C2F(xend),C2F(xendPos),C2F(xendXfig),C2F(xendGif)}},
 
170
      {""}, {""}, {""}, {""},
 
171
      {"xmarks",    {C2F(drawpolymark),C2F(drawpolymarkPos),C2F(drawpolymarkXfig),C2F(drawpolymarkGif)}},
 
172
      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
 
173
      {""}, {""}, {""},
 
174
      {"xgfont",    {C2F(queryfamily),C2F(queryfamilyPos),C2F(queryfamilyXfig),C2F(queryfamilyGif)}},
 
175
      {""}, {""}, {""}, {""}, {""}, {""}, {""},
 
176
      {"xinfo",    {C2F(xinfo),C2F(vide),C2F(vide),C2F(vide)}},
 
177
      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
 
178
      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
 
179
      {""},
 
180
      {"xname",    {C2F(setpopupname),C2F(vide),C2F(vide),C2F(vide)}},
 
181
      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
 
182
      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
 
183
      {"xnum",    {C2F(displaynumbers),C2F(displaynumbersPos),C2F(displaynumbersXfig),C2F(displaynumbersGif)}}
 
184
    };
 
185
 
 
186
  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
 
187
    {
 
188
      register int key = hash (str, len);
 
189
 
 
190
      if (key <= MAX_HASH_VALUE && key >= 0)
 
191
        {
 
192
          register const char *s = wordlist[key].name;
 
193
 
 
194
          if (*str == *s && !strcmp (str + 1, s + 1))
 
195
            return &wordlist[key];
 
196
        }
 
197
    }
 
198
  return 0;
 
199
}
 
200
 
 
201
static char DriverName[]= "Rec";
 
202
static int  DriverId = 0;
 
203
 
 
204
void C2F(SetDriver)(x0, v2, v3, v4, v5, v6, v7, dv1, dv2, dv3, dv4)
 
205
     char *x0;
 
206
     integer *v2,*v3,*v4,*v5,*v6,*v7;
 
207
     double *dv1,*dv2,*dv3,*dv4;
 
208
{
 
209
  switch (x0[0])
 
210
    {
 
211
    case 'I':
 
212
      /** special driver for windows : used when hdc is fixed elsewhere */
 
213
      strcpy(DriverName,"Int"); /* internal : for Win32 */
 
214
      DriverId = 0;
 
215
      break;
 
216
    case 'G':
 
217
      if (x0[1] == 'I') {
 
218
          strcpy(DriverName,"GIF");
 
219
          DriverId = 3;
 
220
          break;
 
221
      }
 
222
    case 'X':
 
223
    case 'W':
 
224
      strcpy(DriverName,"X11");
 
225
      DriverId = 0;
 
226
      break;
 
227
    case 'P'  :
 
228
      strcpy(DriverName,"Pos");
 
229
      DriverId = 1;
 
230
      break;
 
231
    case 'F'  :
 
232
      strcpy(DriverName,"Fig");
 
233
      DriverId = 2;
 
234
      break;
 
235
    case 'R'  :
 
236
      strcpy(DriverName,"Rec");
 
237
      DriverId = 0;
 
238
      break;
 
239
    default:
 
240
      Scistring("\n Wrong driver name I'll use X11");
 
241
      strcpy(DriverName,"X11");
 
242
      DriverId = 0;
 
243
      break;
 
244
    }
 
245
}
 
246
 
 
247
void GetDriver1(str, v2, v3, v4, v5, v6, v7, dv1, dv2, dv3, dv4)
 
248
     char *str;
 
249
     integer *v2,*v3,*v4,*v5,*v6,*v7;
 
250
     double *dv1,*dv2,*dv3,*dv4;
 
251
{
 
252
  strcpy(str,DriverName);
 
253
}
 
254
 
 
255
char GetDriver() {return(DriverName[0]);}
 
256
 
 
257
int GetDriverId() { return DriverId;}
 
258
 
 
259
/* The following function can be called by fortran so we 
 
260
   use the Sun C-fortran interface conventions 
 
261
   dr has 2 last extra parametres to deal with the size of
 
262
   x0 and x1 */
 
263
 
 
264
 
 
265
int C2F(dr)(x0,x1,x2,x3,x4,x5,x6,x7,dx1,dx2,dx3,dx4,lx0,lx1)
 
266
     char x0[],x1[];
 
267
     integer *x2,*x3,*x4,*x5,*x6,*x7;
 
268
     integer lx0,lx1;
 
269
     double *dx1,*dx2,*dx3,*dx4;
 
270
 
271
#ifdef WIN32
 
272
  if ( DriverId == 0 && DriverName[0] != 'I' ) 
 
273
    {
 
274
      SetWinhdc();
 
275
      C2F(all)(x0,x1,x2,x3,x4,x5,x6,x7,dx1,dx2,dx3,dx4);
 
276
      ReleaseWinHdc();
 
277
    }
 
278
  else 
 
279
    {
 
280
      C2F(all)(x0,x1,x2,x3,x4,x5,x6,x7,dx1,dx2,dx3,dx4);
 
281
    }
 
282
#else
 
283
      C2F(all)(x0,x1,x2,x3,x4,x5,x6,x7,dx1,dx2,dx3,dx4);
 
284
#endif
 
285
        return 0;
 
286
}
 
287
 
 
288
static void C2F(all)(x0,x1,x2,x3,x4,x5,x6,x7,dx1,dx2,dx3,dx4)
 
289
     char x0[],x1[];
 
290
     integer *x2,*x3,*x4,*x5,*x6,*x7;
 
291
     double *dx1,*dx2,*dx3,*dx4;
 
292
 
293
  const struct funreplace *fr;
 
294
  fr=xcall_in_word_set(x0,strlen(x0));
 
295
  if ( fr != NULL ) 
 
296
    {
 
297
      (*(fr->action[DriverId]))(x1,x2,x3,x4,x5,x6,x7,dx1,dx2,dx3,dx4);
 
298
    }
 
299
  else 
 
300
    {
 
301
      sciprint("\n Unknow X operator <%s>\r\n",x0);
 
302
    }
 
303
}
 
304
 
 
305
int C2F(foo_inttest)(x1)
 
306
     int *x1;
 
307
{
 
308
  sciprint("Value  of x1 = <%d>\r\n",*x1);
 
309
  return(0);
 
310
}
 
311
 
 
312
/*----------------------------------END---------------------------*/
 
313
 
 
314
 
 
315