File: gstpub.c

package info (click to toggle)
gnu-smalltalk 3.2.4-2.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 32,688 kB
  • ctags: 14,104
  • sloc: ansic: 87,424; sh: 22,729; asm: 8,465; perl: 4,513; cpp: 3,548; xml: 1,669; awk: 1,581; yacc: 1,357; makefile: 1,237; lisp: 855; lex: 843; sed: 258; objc: 124
file content (591 lines) | stat: -rw-r--r-- 11,489 bytes parent folder | download | duplicates (2)
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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
/******************************** -*- C -*- ****************************
 *
 *	Public entry points
 *
 *	This module provides public routines with a "gst_" prefix.
 *	These are exported by the dynamic library.
 *
 *
 ***********************************************************************/


/***********************************************************************
 *
 * Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
 * Written by Steve Byrne.
 *
 * This file is part of GNU Smalltalk.
 *
 * GNU Smalltalk is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2, or (at your option) any later 
 * version.
 * 
 * Linking GNU Smalltalk statically or dynamically with other modules is
 * making a combined work based on GNU Smalltalk.  Thus, the terms and
 * conditions of the GNU General Public License cover the whole
 * combination.
 *
 * In addition, as a special exception, the Free Software Foundation
 * give you permission to combine GNU Smalltalk with free software
 * programs or libraries that are released under the GNU LGPL and with
 * independent programs running under the GNU Smalltalk virtual machine.
 *
 * You may copy and distribute such a system following the terms of the
 * GNU GPL for GNU Smalltalk and the licenses of the other code
 * concerned, provided that you include the source code of that other
 * code when and as the GNU GPL requires distribution of source code.
 *
 * Note that people who make modified versions of GNU Smalltalk are not
 * obligated to grant this special exception for their modified
 * versions; it is their choice whether to do so.  The GNU General
 * Public License gives permission to release a modified version without
 * this exception; this exception also makes it possible to release a
 * modified version which carries forward this exception.
 *
 * GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  
 *
 return ***********************************************************************/

#include "gstpriv.h"

/* By not including this file anywhere else, we make sure that _gst functions
   are always called, and don't create unnecessary PLA entries.  */
#include "gstpub.h"

VMProxy gst_interpreter_proxy = {
  NULL, NULL, NULL,

  _gst_msg_send, _gst_vmsg_send, _gst_nvmsg_send, _gst_str_msg_send,
  _gst_msg_sendf,
  _gst_eval_expr, _gst_eval_code,

  _gst_object_alloc, _gst_basic_size,

  _gst_define_cfunc, _gst_register_oop, _gst_unregister_oop,

/* Convert C datatypes to Smalltalk types */

  _gst_id_to_oop, _gst_int_to_oop, _gst_float_to_oop, _gst_bool_to_oop,
  _gst_char_to_oop, _gst_class_name_to_oop,
  _gst_string_to_oop, _gst_byte_array_to_oop, _gst_symbol_to_oop,
  _gst_c_object_to_oop, _gst_type_name_to_oop, _gst_set_c_object,

/* Convert Smalltalk datatypes to C data types */

  _gst_oop_to_c, _gst_oop_to_id, _gst_oop_to_int, _gst_oop_to_float,
  _gst_oop_to_bool, _gst_oop_to_char,
  _gst_oop_to_string, _gst_oop_to_byte_array, _gst_oop_to_c_object,

/* Smalltalk process support */
  _gst_async_signal, _gst_sync_wait, _gst_async_signal_and_unregister,

  _gst_register_oop_array, _gst_unregister_oop_array,

/* Convert Smalltalk datatypes to C data types (2) */
  _gst_oop_to_long_double, _gst_long_double_to_oop,

  _gst_get_object_class, _gst_get_superclass,
  _gst_class_is_kind_of, _gst_object_is_kind_of,
  _gst_perform, _gst_perform_with, _gst_class_implements_selector,
  _gst_class_can_understand, _gst_responds_to,
  _gst_oop_size, _gst_oop_at, _gst_oop_at_put,

  /* System objects.  */
  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,

  /* New in 2.3.  */
  _gst_wchar_to_oop, _gst_wstring_to_oop,
  _gst_oop_to_wchar, _gst_oop_to_wstring,

  /* New in 3.0.  */
  _gst_process_stdin,
  _gst_process_file,
  _gst_get_var, _gst_set_var,
  _gst_invoke_hook,

  /* New in 3.1.  */
  _gst_relocate_path,
  _gst_oop_indexed_base,
  _gst_oop_indexed_kind,
  _gst_async_call,
  _gst_sync_signal,
  _gst_show_backtrace,

  /* New in 3.2.  */
  _gst_dlopen,
  _gst_dladdsearchdir,
  _gst_dlpushsearchpath,
  _gst_dlpopsearchpath,
  _gst_wakeup
};

/* Functions in comp.h.  */
void
gst_invoke_hook (enum gst_vm_hook hook)
{
  _gst_invoke_hook (hook);
}

void
gst_smalltalk_args (int argc,
		    const char **argv)
{
  _gst_smalltalk_args (argc, argv);
}

int
gst_initialize (const char *kernel_dir,
		const char *image_file,
		int flags)
{
  return _gst_initialize (kernel_dir, image_file, flags);
}

void gst_process_stdin (const char *prompt)
{
  _gst_process_stdin (prompt);
}

mst_Boolean
gst_process_file (const char *fileName, enum gst_file_dir dir)
{
  return _gst_process_file (fileName, dir);
}

int
gst_get_var (enum gst_var_index index)
{
  return _gst_get_var (index);
}

int
gst_set_var (enum gst_var_index index, int value)
{
  return _gst_set_var (index, value);
}

OOP
gst_msg_send (OOP receiver, OOP selector, ...)
{
  va_list ap; 
  va_start (ap, selector);
  return _gst_va_msg_send (receiver, selector, ap);
}

OOP
gst_vmsg_send (OOP receiver, OOP selector, OOP * args)
{
  return _gst_vmsg_send (receiver, selector, args);
}

OOP
gst_nvmsg_send (OOP receiver, OOP selector, OOP * args, int nargs)
{
  return _gst_nvmsg_send (receiver, selector, args, nargs);
}

OOP
gst_str_msg_send (OOP receiver, const char *sel, ...)
{
  va_list ap; 
  OOP selector = _gst_symbol_to_oop (sel);
  va_start (ap, sel);
  return _gst_va_msg_send (receiver, selector, ap);
}

void
gst_msg_sendf (PTR result_ptr, const char *fmt, ...)
{
  va_list ap;
  va_start (ap, fmt);
  _gst_va_msg_sendf (result_ptr, fmt, ap);
}

OOP
gst_eval_expr (const char *str)
{
  return _gst_eval_expr (str);
}

void
gst_eval_code (const char *str)
{
  _gst_eval_code (str);
}

OOP
gst_object_alloc (OOP class_oop, int size)
{
  return _gst_object_alloc (class_oop, size);
}

int
gst_basic_size (OOP oop)
{
  return _gst_basic_size (oop);
}

void
gst_define_cfunc (const char *func_name, PTR func_addr)
{
  _gst_define_cfunc (func_name, func_addr);
}

OOP
gst_register_oop (OOP oop)
{
  return _gst_register_oop (oop);
}

void
gst_unregister_oop (OOP oop)
{
  _gst_unregister_oop (oop);
}

OOP
gst_id_to_oop (long i)
{
  return _gst_id_to_oop (i);
}

OOP
gst_int_to_oop (long i)
{
  return _gst_int_to_oop (i);
}

OOP
gst_float_to_oop (double f)
{
  return _gst_float_to_oop (f);
}

OOP
gst_bool_to_oop (int b)
{
  return _gst_bool_to_oop (b);
}

OOP
gst_char_to_oop (char c)
{
  return _gst_char_to_oop (c);
}

OOP
gst_class_name_to_oop (const char *name)
{
  return _gst_class_name_to_oop (name);
}

OOP
gst_string_to_oop (const char *str)
{
  return _gst_string_to_oop (str);
}

OOP
gst_byte_array_to_oop (const char *str, int n)
{
  return _gst_byte_array_to_oop (str, n);
}

OOP
gst_symbol_to_oop (const char *str)
{
  return _gst_symbol_to_oop (str);
}

OOP
gst_c_object_to_oop (PTR co)
{
  return _gst_c_object_to_oop (co);
}

OOP
gst_type_name_to_oop (const char *name)
{
  return _gst_type_name_to_oop (name);
}

void
gst_set_c_object (OOP oop, PTR co)
{
  _gst_set_c_object (oop, co);
}

long
gst_oop_to_c (OOP oop)
{
  return _gst_oop_to_c (oop);
}				/*sometimes answers a PTR */

long
gst_oop_to_id (OOP oop)
{
  return _gst_oop_to_id (oop);
}

long
gst_oop_to_int (OOP oop)
{
  return _gst_oop_to_int (oop);
}

double
gst_oop_to_float (OOP oop)
{
  return _gst_oop_to_float (oop);
}

int
gst_oop_to_bool (OOP oop)
{
  return _gst_oop_to_bool (oop);
}

char
gst_oop_to_char (OOP oop)
{
  return _gst_oop_to_char (oop);
}

char *
gst_oop_to_string (OOP oop)
{
  return _gst_oop_to_string (oop);
}

char *
gst_oop_to_byte_array (OOP oop)
{
  return _gst_oop_to_byte_array (oop);
}

PTR
gst_oop_to_c_object (OOP oop)
{
  return _gst_oop_to_c_object (oop);
}

void
gst_async_signal (OOP semaphore_oop)
{
  _gst_async_signal (semaphore_oop);
}

void
gst_sync_wait (OOP semaphore_oop)
{
  _gst_sync_wait (semaphore_oop);
}

void
gst_async_signal_and_unregister (OOP semaphore_oop)
{
  _gst_async_signal_and_unregister (semaphore_oop);
}

mst_Boolean
gst_sync_signal (OOP semaphore_oop, mst_Boolean incr_if_empty)
{
  return _gst_sync_signal (semaphore_oop, incr_if_empty);
}

void
gst_async_call (void (*func) (OOP), OOP semaphore_oop)
{
  _gst_async_call (func, semaphore_oop);
}

void
gst_show_backtrace (FILE *fp)
{
  _gst_show_backtrace (fp);
}

mst_Boolean
gst_dlopen (const char *filename, mst_Boolean module)
{
  return _gst_dlopen (filename, module);
}

void
gst_dladdsearchdir (const char *dir)
{
  _gst_dladdsearchdir (dir);
}

void
gst_dlpushsearchpath (void)
{
  _gst_dlpushsearchpath ();
}

void
gst_dlpopsearchpath (void)
{
  _gst_dlpopsearchpath ();
}

void
gst_wakeup ()
{
  _gst_wakeup ();
}

void
gst_register_oop_array (OOP **first, OOP **last)
{
  _gst_register_oop_array (first, last);
}

void
gst_unregister_oop_array (OOP **first)
{
  _gst_unregister_oop_array (first);
}

long double
gst_oop_to_long_double (OOP oop)
{
  return _gst_oop_to_long_double (oop);
}

OOP
gst_long_double_to_oop (long double f)
{
  return _gst_long_double_to_oop (f);
}

OOP
gst_wchar_to_oop (wchar_t c)
{
  return _gst_wchar_to_oop (c);
}

OOP
gst_wstring_to_oop (const wchar_t *str)
{
  return _gst_wstring_to_oop (str);
}

wchar_t
gst_oop_to_wchar (OOP oop)
{
  return _gst_oop_to_wchar (oop);
}

wchar_t *
gst_oop_to_wstring (OOP oop)
{
  return _gst_oop_to_wstring (oop);
}

OOP
gst_get_object_class (OOP oop)
{
  return _gst_get_object_class (oop);
}

OOP
gst_get_superclass (OOP oop)
{
  return _gst_get_superclass (oop);
}

mst_Boolean
gst_class_is_kind_of (OOP oop, OOP candidate)
{
  return _gst_class_is_kind_of (oop, candidate);
}

mst_Boolean
gst_object_is_kind_of (OOP oop, OOP candidate)
{
  return _gst_object_is_kind_of (oop, candidate);
}

OOP
gst_perform (OOP oop, OOP selector)
{
  return _gst_perform (oop, selector);
}

OOP
gst_perform_with (OOP oop, OOP selector, OOP arg)
{
  return _gst_perform_with (oop, selector, arg);
}

mst_Boolean
gst_class_implements_selector (OOP class_oop, OOP selector)
{
  return _gst_class_implements_selector (class_oop, selector);
}

mst_Boolean gst_class_can_understand (OOP class_oop, OOP selector)
{
  return _gst_class_can_understand (class_oop, selector);
}

mst_Boolean
gst_responds_to (OOP oop, OOP selector)
{
  return _gst_responds_to (oop, selector);
}

size_t
gst_oop_size (OOP oop)
{
  return _gst_oop_size (oop);
}

OOP
gst_oop_at (OOP oop, size_t index)
{
  return _gst_oop_at (oop, index);
}

OOP
gst_oop_at_put (OOP oop, size_t index, OOP new_oop)
{
  return _gst_oop_at_put (oop, index, new_oop);
}

enum gst_indexed_kind
gst_oop_indexed_kind (OOP oop)
{
  return _gst_oop_indexed_kind (oop);
}

void *
gst_oop_indexed_base (OOP oop)
{
  return _gst_oop_indexed_base (oop);
}


/* Functions in sysdep.h.  */
void
gst_set_executable_path (const char *argv0)
{
  _gst_set_executable_path (argv0);
}

char *
gst_relocate_path (const char *path)
{
  return _gst_relocate_path (path);
}