The R Project SVN R

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6098 pd 1
/*
2
 *  StatConn: Connector interface between application and interpreter language
13365 ripley 3
 *  Copyright (C) 1999--2001 Thomas Baier
26207 murdoch 4
 *
6098 pd 5
 *  This library is free software; you can redistribute it and/or
6
 *  modify it under the terms of the GNU Library General Public
7
 *  License as published by the Free Software Foundation; either
8
 *  version 2 of the License, or (at your option) any later version.
26207 murdoch 9
 *
6098 pd 10
 *  This library is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 *  Library General Public License for more details.
26207 murdoch 14
 *
6098 pd 15
 *  You should have received a copy of the GNU Library General Public
16
 *  License along with this library; if not, write to the Free
17
 *  Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18
 *  MA 02111-1307, USA
6994 pd 19
 *
26207 murdoch 20
 *  $Id: SC_proxy.h,v 1.6 2003/09/13 15:14:09 murdoch Exp $
6098 pd 21
 */
22
 
23
#ifndef _STATCONN_H_
24
#define _STATCONN_H_
25
 
26
#include "bdx.h"
27
 
26207 murdoch 28
/* system-specifics should be moved to some include file */
6098 pd 29
#include <windows.h>
30
#define SYSCALL WINAPI
31
#define EXPORT
32
 
26207 murdoch 33
/* forward definition */
6098 pd 34
struct _SC_Proxy_Object;
6994 pd 35
struct _SC_CharacterDevice;
13365 ripley 36
struct _SC_GraphicsDevice;
6098 pd 37
 
26207 murdoch 38
/* error codes */
6098 pd 39
 
26207 murdoch 40
/* generic error and success codes */
6098 pd 41
#define SC_PROXY_OK                            0x00000000
42
#define SC_PROXY_ERR_UNKNOWN                   0x80000000
43
 
44
#define SC_PROXY_ERR_INVALIDARG                0x80000001
45
#define SC_PROXY_ERR_INVALIDFORMAT             0x80000002
46
#define SC_PROXY_ERR_NOTIMPL                   0x80000003
47
 
26207 murdoch 48
/* initialization and termination */
6098 pd 49
#define SC_PROXY_ERR_INITIALIZED               0x80000004
50
#define SC_PROXY_ERR_NOTINITIALIZED            0x80000005
51
 
26207 murdoch 52
/* evaluation, getting and setting symbols */
6098 pd 53
#define SC_PROXY_ERR_INVALIDSYMBOL             0x80000006
54
#define SC_PROXY_ERR_PARSE_INVALID             0x80000007
55
#define SC_PROXY_ERR_PARSE_INCOMPLETE          0x80000008
56
#define SC_PROXY_ERR_UNSUPPORTEDTYPE           0x80000009
17323 ripley 57
#define SC_PROXY_ERR_EVALUATE_STOP             0x8000000a
6098 pd 58
 
26207 murdoch 59
/* version mismatch */
6098 pd 60
#define SC_PROXY_ERR_INVALIDINTERFACEVERSION   0x80000010
61
#define SC_PROXY_ERR_INVALIDINTERPRETERVERSION 0x80000011
62
 
26207 murdoch 63
/* type mask values */
6994 pd 64
#define SC_TM_SCALAR_BOOL   (BDX_BOOL)
65
#define SC_TM_SCALAR_INT    (BDX_INT)
66
#define SC_TM_SCALAR_DOUBLE (BDX_DOUBLE)
67
#define SC_TM_SCALAR_STRING (BDX_STRING)
68
#define SC_TM_SCALAR_ALL    (SC_TM_SCALAR_BOOL     \
69
                             | SC_TM_SCALAR_INT    \
70
                             | SC_TM_SCALAR_DOUBLE \
71
                             | SC_TM_SCALAR_STRING)
72
 
73
#define SC_TM_ARRAY_BOOL    (BDX_BOOL << 8)
74
#define SC_TM_ARRAY_INT     (BDX_INT << 8)
75
#define SC_TM_ARRAY_DOUBLE  (BDX_DOUBLE << 8)
76
#define SC_TM_ARRAY_STRING  (BDX_STRING << 8)
77
#define SC_TM_ARRAY_ALL     (SC_TM_ARRAY_BOOL     \
78
                             | SC_TM_ARRAY_INT    \
79
                             | SC_TM_ARRAY_DOUBLE \
80
                             | SC_TM_ARRAY_STRING)
81
 
82
#define SC_TM_VECTOR_BOOL   (BDX_BOOL << 12)
83
#define SC_TM_VECTOR_INT    (BDX_INT << 12)
84
#define SC_TM_VECTOR_DOUBLE (BDX_DOUBLE << 12)
85
#define SC_TM_VECTOR_STRING (BDX_STRING << 12)
86
#define SC_TM_VECTOR_ALL    (SC_TM_VECTOR_BOOL     \
87
                             | SC_TM_VECTOR_INT    \
88
                             | SC_TM_VECTOR_DOUBLE \
89
                             | SC_TM_VECTOR_STRING)
90
 
26207 murdoch 91
/* information main keys */
6994 pd 92
#define SC_INFO_MAIN_CONNECTOR     1
93
#define SC_INFO_MAIN_INTERPRETER   2
94
 
26207 murdoch 95
/* information sub keys */
6994 pd 96
#define SC_INFO_SUB_NAME                  1
97
#define SC_INFO_SUB_DESCRIPTION           2
98
#define SC_INFO_SUB_COPYRIGHT             3
99
#define SC_INFO_SUB_LICENSE               4
100
#define SC_INFO_SUB_MINORVERSION          5
101
#define SC_INFO_SUB_MAJORVERSION          6
102
 
26207 murdoch 103
/* function type-defs */
6098 pd 104
typedef int (SYSCALL *SC_PROXY_GET_VERSION) (struct _SC_Proxy_Object* object,
105
					     unsigned long* version);
13365 ripley 106
typedef int (SYSCALL *SC_PROXY_INIT) (struct _SC_Proxy_Object* object,
107
				      char const* parameters);
6098 pd 108
typedef int (SYSCALL *SC_PROXY_TERMINATE) (struct _SC_Proxy_Object* object);
109
typedef int (SYSCALL *SC_PROXY_RETAIN) (struct _SC_Proxy_Object* object);
110
typedef int (SYSCALL *SC_PROXY_RELEASE) (struct _SC_Proxy_Object* object);
111
 
112
typedef int (SYSCALL *SC_PROXY_SET_SYMBOL) (struct _SC_Proxy_Object* object,
113
					    char const* symbol,
114
					    BDX_Data /* const */ * data);
115
typedef int (SYSCALL *SC_PROXY_GET_SYMBOL) (struct _SC_Proxy_Object* object,
116
					    char const* symbol,
117
					    BDX_Data** data);
118
typedef int (SYSCALL *SC_PROXY_EVALUATE) (struct _SC_Proxy_Object* object,
119
					  char const* command,
120
					  BDX_Data** data);
121
typedef int (SYSCALL *SC_PROXY_EVALUATE_NORETURN) (struct _SC_Proxy_Object* object,
122
						   char const* command);
123
typedef int (SYSCALL *SC_PROXY_FREE_DATA_BUFFER) (struct _SC_Proxy_Object* object,
124
						  BDX_Data* data);
125
typedef int (SYSCALL *SC_PROXY_QUERY_TYPES) (struct _SC_Proxy_Object* object,
126
					     long* type_mask);
127
typedef int (SYSCALL *SC_PROXY_QUERY_OPS) (struct _SC_Proxy_Object* object,
128
					   long* op_mask);
6994 pd 129
typedef int (SYSCALL *SC_PROXY_SET_CHARACTERDEVICE)
130
(
131
  struct _SC_Proxy_Object* object,
132
  struct _SC_CharacterDevice* device
133
);
134
typedef int (SYSCALL *SC_PROXY_QUERY_INFO) (struct _SC_Proxy_Object* object,
135
					    long main_key,
136
					    long sub_key,
137
					    const char** information);
13365 ripley 138
typedef int (SYSCALL *SC_PROXY_SET_GRAPHICSDEVICE)
139
(
140
  struct _SC_Proxy_Object* object,
141
  struct _SC_GraphicsDevice* device
142
);
6098 pd 143
 
26207 murdoch 144
/* character device function typedefs */
6994 pd 145
typedef int (SYSCALL *SC_CHARACTERDEVICE_GET_VERSION)
146
(
147
  struct _SC_CharacterDevice* object,
148
  unsigned long* version
149
);
6098 pd 150
 
6994 pd 151
typedef int (SYSCALL *SC_CHARACTERDEVICE_RETAIN)
152
(
153
  struct _SC_CharacterDevice* object
154
);
155
 
156
typedef int (SYSCALL *SC_CHARACTERDEVICE_RELEASE)
157
(
158
  struct _SC_CharacterDevice* object
159
);
160
 
161
typedef int (SYSCALL *SC_CHARACTERDEVICE_WRITE_STRING)
162
(
163
  struct _SC_CharacterDevice* object,
164
  char const* string
165
);
166
 
167
typedef int (SYSCALL *SC_CHARACTERDEVICE_WRITE_STRING_LEVEL)
168
(
169
  struct _SC_CharacterDevice* object,
170
  char const* string,
171
  unsigned long level
172
);
173
 
26207 murdoch 174
/* graphics device function typedefs */
13365 ripley 175
typedef int (SYSCALL *SC_GRAPHICSDEVICE_GET_VERSION)
176
(
177
  struct _SC_GraphicsDevice* object,
178
  unsigned long* version
179
);
180
 
181
typedef int (SYSCALL *SC_GRAPHICSDEVICE_RETAIN)
182
(
183
  struct _SC_GraphicsDevice* object
184
);
185
 
186
typedef int (SYSCALL *SC_GRAPHICSDEVICE_RELEASE)
187
(
188
  struct _SC_GraphicsDevice* object
189
);
190
 
26207 murdoch 191
/* really no data, should not be required */
13365 ripley 192
typedef int (SYSCALL *SC_GRAPHICSDEVICE_OPEN)
193
(
194
  struct _SC_GraphicsDevice* object,
195
  char const* display,
196
  double w,
197
  double h,
198
  double gamma,
199
  int colormodel,
200
  int maxcupe
201
);
202
 
26207 murdoch 203
/* should not be required */
13365 ripley 204
typedef void (SYSCALL *SC_GRAPHICSDEVICE_CLOSE)
205
(
206
  struct _SC_GraphicsDevice* object
207
);
208
 
209
typedef void (SYSCALL *SC_GRAPHICSDEVICE_ACTIVATE)
210
(
211
  struct _SC_GraphicsDevice* object
212
);
213
 
214
typedef void (SYSCALL *SC_GRAPHICSDEVICE_DEACTIVATE)
215
(
216
  struct _SC_GraphicsDevice* object
217
);
218
 
26207 murdoch 219
/* 00-06-22 | baier | added color, line type and width */
13365 ripley 220
typedef void (SYSCALL *SC_GRAPHICSDEVICE_LINE)
221
(
222
  struct _SC_GraphicsDevice* object,
223
  double x1,
224
  double y1,
225
  double x2,
226
  double y2,
227
  int color,
228
  int line_type,
229
  double line_width
230
);
231
 
26207 murdoch 232
/* 00-06-22 | baier | added line type and width */
13365 ripley 233
typedef void (SYSCALL *SC_GRAPHICSDEVICE_CIRCLE)
234
(
235
  struct _SC_GraphicsDevice* object,
236
  double x,
237
  double y,
238
  double r,
26207 murdoch 239
  int col,    /* border color */
240
  int border, /* fill color */
13365 ripley 241
  int line_type,
242
  double line_width
243
);
244
 
245
typedef void (SYSCALL *SC_GRAPHICSDEVICE_POLYGON)
246
(
247
  struct _SC_GraphicsDevice* object,
248
  int n,
249
  double* x,
250
  double* y,
26207 murdoch 251
  int bg,     /* border color */
252
  int fg      /* fill color */
13365 ripley 253
);
254
 
26207 murdoch 255
/* 01-01-23 | baier | added "col" parameter */
13365 ripley 256
typedef void (SYSCALL *SC_GRAPHICSDEVICE_POLYLINE)
257
(
258
  struct _SC_GraphicsDevice* object,
259
  int n,
260
  double* x,
261
  double* y,
26207 murdoch 262
  int col    /* color */
13365 ripley 263
);
264
 
26207 murdoch 265
/* 00-06-22 | baier | added line type and width */
13365 ripley 266
typedef void (SYSCALL *SC_GRAPHICSDEVICE_RECT)
267
(
268
  struct _SC_GraphicsDevice* object,
269
  double x0,
270
  double y0,
271
  double x1,
272
  double y1,
26207 murdoch 273
  int bg,     /* border color */
274
  int fg,     /* fill color */
13365 ripley 275
  int line_type,
276
  double line_width
277
);
278
 
26207 murdoch 279
/* 00-06-22 | baier | added color, font and size */
13365 ripley 280
typedef void (SYSCALL *SC_GRAPHICSDEVICE_TEXT)
281
(
282
  struct _SC_GraphicsDevice* object,
283
  double x,
284
  double y,
285
  char const* string,
26207 murdoch 286
  double rot,          /* rotation in degrees */
287
  double hadj,         /* horizontal adjustment */
13365 ripley 288
  int color,
26207 murdoch 289
  int font,            /* 0-31, one of the predefined fonts */
290
  int size             /* 8-64, point size */
13365 ripley 291
);
292
 
293
typedef void (SYSCALL *SC_GRAPHICSDEVICE_CLIP)
294
(
295
  struct _SC_GraphicsDevice* object,
296
  double x0,
297
  double x1,
298
  double y0,
299
  double y1
300
);
301
 
26207 murdoch 302
/* to be removed. refresh of width and heigth should be done on "newpage" */
13365 ripley 303
typedef void (SYSCALL *SC_GRAPHICSDEVICE_RESIZE)
304
(
305
  struct _SC_GraphicsDevice* object
306
);
307
 
26207 murdoch 308
/* to be removed */
13365 ripley 309
typedef void (SYSCALL *SC_GRAPHICSDEVICE_HOLD)
310
(
311
  struct _SC_GraphicsDevice* object
312
);
313
 
26207 murdoch 314
/* should clear display AND refresh coordinates */
13365 ripley 315
typedef void (SYSCALL *SC_GRAPHICSDEVICE_NEWPAGE)
316
(
317
  struct _SC_GraphicsDevice* object
318
);
319
 
320
typedef int (SYSCALL *SC_GRAPHICSDEVICE_LOCATOR)
321
(
322
  struct _SC_GraphicsDevice* object,
323
  double* x,
324
  double* y
325
);
326
 
327
typedef void (SYSCALL *SC_GRAPHICSDEVICE_MODE)
328
(
329
  struct _SC_GraphicsDevice* object,
26207 murdoch 330
  int mode   /* 1 when starting drawing, 0 when stopping */
13365 ripley 331
);
332
 
26207 murdoch 333
/* 00-06-22 | baier | added font and size parameters */
13365 ripley 334
typedef double (SYSCALL *SC_GRAPHICSDEVICE_STRWIDTH)
335
(
336
  struct _SC_GraphicsDevice* object,
337
  char const* string,
26207 murdoch 338
  int font,            /* 0-31, one of the predefined fonts */
339
  int size             /* 8-64, point size */
13365 ripley 340
);
341
 
26207 murdoch 342
/* 00-06-22 | baier | added font and size parameters */
13365 ripley 343
typedef void (SYSCALL *SC_GRAPHICSDEVICE_METRICINFO)
344
(
345
  struct _SC_GraphicsDevice* object,
346
  int character,
347
  double* ascent,
348
  double* descent,
349
  double* width,
26207 murdoch 350
  int font,            /* 0-31, one of the predefined fonts */
351
  int size             /* 8-64, point size */
13365 ripley 352
);
353
 
354
 
6098 pd 355
/*
356
 * interface version information:
357
 *
358
 * 1 ... obsolete first interface
359
 * 2 ... get_version, set_symbol, evaluate_noreturn, evaluate
6994 pd 360
 * 3 ... added character devices for output, errors and tracing, info strings
13365 ripley 361
 * 4 ... pass parameter string in init() function
362
 * 5 ... simple graphics device interface
6098 pd 363
 */
13365 ripley 364
#define SC_PROXY_INTERFACE_VERSION 5
365
 
366
/*
367
 * interface version information:
368
 *
369
 * 1 ... first version
370
 */
6994 pd 371
#define SC_CHARACTERDEVICE_VERSION 1
6098 pd 372
 
13365 ripley 373
/*
374
 * interface version information:
375
 *
376
 * 1 ... first version
377
 */
378
#define SC_GRAPHICSDEVICE_VERSION 1
6994 pd 379
 
26207 murdoch 380
/* used for communication between the COM/CORBA server and R */
6098 pd 381
typedef struct _SC_Proxy_Object_Vtbl
382
{
26207 murdoch 383
  /* get interpreter version */
6098 pd 384
  SC_PROXY_GET_VERSION get_version;
385
 
26207 murdoch 386
  /* initialize the interpreter */
6098 pd 387
  SC_PROXY_INIT init;
26207 murdoch 388
  /* terminate the interpreter */
6098 pd 389
  SC_PROXY_TERMINATE terminate;
390
 
26207 murdoch 391
  /* increase the reference count to this interface object */
6994 pd 392
  SC_PROXY_RETAIN retain;
26207 murdoch 393
  /* decrease the reference count to this interface object, object will be */
394
  /* freed when count reaches 0 */
6098 pd 395
  SC_PROXY_RELEASE release;
396
 
26207 murdoch 397
  /* set a symbol in the interpreter's global namespace to the BDX data passed */
6098 pd 398
  SC_PROXY_SET_SYMBOL set_symbol;
26207 murdoch 399
  /* return a symbol's value from the interpreter's global namespace */
6098 pd 400
  SC_PROXY_GET_SYMBOL get_symbol;
401
 
26207 murdoch 402
  /* evaluate an expression, return result in a BDX data buffer (synchronously) */
6098 pd 403
  SC_PROXY_EVALUATE evaluate;
26207 murdoch 404
  /* evaluate an expression, do not return a result (synchronously) */
6098 pd 405
  SC_PROXY_EVALUATE_NORETURN evaluate_noreturn;
406
 
26207 murdoch 407
  /* return information about BDX data types supported by this interface and */
408
  /* the interpreter */
6098 pd 409
  SC_PROXY_QUERY_TYPES query_supported_types;
26207 murdoch 410
  /* return information about available functionality in this interface and */
411
  /* the interpreter */
6098 pd 412
  SC_PROXY_QUERY_OPS query_supported_operations;
413
 
26207 murdoch 414
  /* free a BDX data buffer allocated by one of this interface's functions */
6098 pd 415
  SC_PROXY_FREE_DATA_BUFFER free_data_buffer;
6994 pd 416
 
26207 murdoch 417
  /* set output, error and tracing devices */
6994 pd 418
  SC_PROXY_SET_CHARACTERDEVICE set_output_device;
419
 
26207 murdoch 420
  /* retrieve information about interface and interpreter */
6994 pd 421
  SC_PROXY_QUERY_INFO query_info;
422
 
26207 murdoch 423
  /* add and remove a graphics device */
13365 ripley 424
  SC_PROXY_SET_GRAPHICSDEVICE set_graphics_device;
6098 pd 425
} SC_Proxy_Object_Vtbl;
426
 
26207 murdoch 427
/* character device used for output, (textual) error messages and traces */
13365 ripley 428
typedef struct _SC_CharacterDevice_Vtbl
429
{
26207 murdoch 430
  /* get character device version */
13365 ripley 431
  SC_CHARACTERDEVICE_GET_VERSION get_version;
432
 
26207 murdoch 433
  /* increase the reference count to this interface object */
13365 ripley 434
  SC_CHARACTERDEVICE_RETAIN retain;
26207 murdoch 435
  /* decrease the reference count to this interface object, object will be */
436
  /* freed when count reaches 0 */
13365 ripley 437
  SC_CHARACTERDEVICE_RELEASE release;
438
 
26207 murdoch 439
  /* write a string to the output device */
13365 ripley 440
  SC_CHARACTERDEVICE_WRITE_STRING write_string;
441
 
26207 murdoch 442
  /* write a string to the output device. the string is echoed if the passed */
443
  /* level is less or equal to the current output level of the device (used */
444
  /* for conditional output) */
13365 ripley 445
  SC_CHARACTERDEVICE_WRITE_STRING_LEVEL write_string_level;
446
} SC_CharacterDevice_Vtbl;
447
 
26207 murdoch 448
/* graphics device */
13365 ripley 449
typedef struct _SC_GraphicsDevice_Vtbl
450
{
26207 murdoch 451
  /* get graphics device version */
13365 ripley 452
  SC_GRAPHICSDEVICE_GET_VERSION get_version;
453
 
26207 murdoch 454
  /* increase the reference count to this interface object */
13365 ripley 455
  SC_GRAPHICSDEVICE_RETAIN retain;
26207 murdoch 456
  /* decrease the reference count to this interface object, object will be */
457
  /* freed when count reaches 0 */
13365 ripley 458
  SC_GRAPHICSDEVICE_RELEASE release;
459
 
26207 murdoch 460
  /* interface-specific functions following here! */
13365 ripley 461
  SC_GRAPHICSDEVICE_OPEN open;
462
  SC_GRAPHICSDEVICE_CLOSE close;
463
 
464
  SC_GRAPHICSDEVICE_ACTIVATE activate;
465
  SC_GRAPHICSDEVICE_DEACTIVATE deactivate;
466
 
467
  SC_GRAPHICSDEVICE_LINE line;
468
  SC_GRAPHICSDEVICE_CIRCLE circle;
469
  SC_GRAPHICSDEVICE_POLYGON polygon;
470
  SC_GRAPHICSDEVICE_POLYLINE polyline;
471
  SC_GRAPHICSDEVICE_RECT rect;
472
  SC_GRAPHICSDEVICE_TEXT text;
473
 
474
  SC_GRAPHICSDEVICE_CLIP clip;
475
  SC_GRAPHICSDEVICE_RESIZE resize;
476
 
477
  SC_GRAPHICSDEVICE_HOLD hold;
478
  SC_GRAPHICSDEVICE_NEWPAGE newpage;
479
 
480
  SC_GRAPHICSDEVICE_LOCATOR locator;
481
  SC_GRAPHICSDEVICE_MODE mode;
482
  SC_GRAPHICSDEVICE_STRWIDTH strwidth;
483
  SC_GRAPHICSDEVICE_METRICINFO metricinfo;
484
} SC_GraphicsDevice_Vtbl;
485
 
26207 murdoch 486
/* abstract data type (implementation adds data) */
6098 pd 487
typedef struct _SC_Proxy_Object
488
{
489
  SC_Proxy_Object_Vtbl* vtbl;
490
} SC_Proxy_Object;
491
 
6994 pd 492
typedef struct _SC_CharacterDevice
493
{
494
  SC_CharacterDevice_Vtbl* vtbl;
495
} SC_CharacterDevice;
496
 
13365 ripley 497
typedef struct _SC_GraphicsDevice
498
{
499
  SC_GraphicsDevice_Vtbl* vtbl;
500
} SC_GraphicsDevice;
501
 
26207 murdoch 502
/* entry point: retrieve a proxy object with a given version */
6098 pd 503
typedef int (SYSCALL* SC_PROXY_GET_OBJECT) (SC_Proxy_Object**,unsigned long);
504
 
26207 murdoch 505
/* this is valid for Windows only */
6098 pd 506
#define SC_PROXY_GET_OBJECT_FUN "SC_Proxy_get_object@8"
507
 
508
#endif