1
/*===========================================================================
2
* FileName : sigschemetype.h
3
* About : scheme object type definition
5
* Copyright (C) 2005 by Kazuki Ohta (mover@hct.zaq.ne.jp)
9
* Redistribution and use in source and binary forms, with or without
10
* modification, are permitted provided that the following conditions
13
* 1. Redistributions of source code must retain the above copyright
14
* notice, this list of conditions and the following disclaimer.
15
* 2. Redistributions in binary form must reproduce the above copyright
16
* notice, this list of conditions and the following disclaimer in the
17
* documentation and/or other materials provided with the distribution.
18
* 3. Neither the name of authors nor the names of its contributors
19
* may be used to endorse or promote products derived from this software
20
* without specific prior written permission.
22
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
23
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
26
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
28
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33
===========================================================================*/
34
#ifndef __SIGSCMTYPE_H
35
#define __SIGSCMTYPE_H
37
/*=======================================
39
=======================================*/
42
/*=======================================
44
=======================================*/
46
/*=======================================
48
=======================================*/
49
typedef struct ScmCell_ ScmCell;
50
typedef ScmCell *ScmObj;
51
typedef ScmObj *ScmRef;
52
typedef struct _ScmPortInfo ScmPortInfo;
53
typedef struct ScmEvalState_ ScmEvalState;
54
typedef ScmObj (*ScmFuncType)();
56
/*=======================================
58
=======================================*/
60
* Internal representation of these types MUST NOT directly touched by libsscm
61
* users. What libsscm users allowed is referring the types and constant values
62
* in declarations and definitions.
64
* All operations touching the internal representation such as accessing a
65
* member of a struct must be performed through the accessor macros defined in
66
* the section "Accessors For Scheme Objects" below. Otherwise the client code
67
* of libsscm will be broken when SigScheme has change internal object
68
* representations. The macros abstract the difference.
71
/* Scheme Object Type */
91
/* ScmPort direction */
92
enum ScmPortDirection {
104
struct _ScmPortInfo {
105
enum ScmPortType port_type; /* (PORT_FILE | PORT_STRING) */
116
const char *str_currentpos;
120
int (*getc_func) (ScmObj port);
121
void (*print_func) (ScmObj port, const char* str);
128
* Function objects must tag themselves with proper information so
129
* that the evaluator can correctly invoke them. See doc/invocation
132
enum ScmFuncTypeCode {
133
SCM_FUNCTYPE_MAND_BITS = 4,
134
SCM_FUNCTYPE_MAND_MASK = (1 << SCM_FUNCTYPE_MAND_BITS)-1,
135
#define SCM_FUNCTYPE_MAND_MAX 5
136
/* SCM_FUNCTYPE_MAND_MAX = 5, */
137
SCM_FUNCTYPE_SYNTAX = 1 << SCM_FUNCTYPE_MAND_BITS,
139
SCM_FUNCTYPE_FIXED = 0 << (SCM_FUNCTYPE_MAND_BITS+1),
140
SCM_FUNCTYPE_VARIADIC = 1 << (SCM_FUNCTYPE_MAND_BITS+1),
141
SCM_FUNCTYPE_TAIL_REC = 1 << (SCM_FUNCTYPE_MAND_BITS+2),
143
SCM_FUNCTYPE_ODDBALL = 1 << (SCM_FUNCTYPE_MAND_BITS+10),
145
/* Compound types. */
146
SCM_PROCEDURE_FIXED = SCM_FUNCTYPE_FIXED,
147
SCM_PROCEDURE_FIXED_TAIL_REC = SCM_FUNCTYPE_TAIL_REC,
148
SCM_PROCEDURE_VARIADIC = SCM_FUNCTYPE_VARIADIC,
149
SCM_PROCEDURE_VARIADIC_TAIL_REC = SCM_FUNCTYPE_VARIADIC | SCM_FUNCTYPE_TAIL_REC,
151
SCM_SYNTAX_FIXED = SCM_PROCEDURE_FIXED | SCM_FUNCTYPE_SYNTAX,
152
SCM_SYNTAX_FIXED_TAIL_REC = SCM_PROCEDURE_FIXED_TAIL_REC | SCM_FUNCTYPE_SYNTAX,
153
SCM_SYNTAX_VARIADIC = SCM_PROCEDURE_VARIADIC | SCM_FUNCTYPE_SYNTAX,
154
SCM_SYNTAX_VARIADIC_TAIL_REC = SCM_PROCEDURE_VARIADIC_TAIL_REC | SCM_FUNCTYPE_SYNTAX,
157
SCM_REDUCTION_OPERATOR = SCM_FUNCTYPE_ODDBALL
160
/* Where we are in a reduction process. */
161
enum ScmReductionState {
162
SCM_REDUCE_0, /* No argument was given. */
163
SCM_REDUCE_1, /* Only 1 argument was given. */
164
SCM_REDUCE_PARTWAY, /* We have more arguments pending. */
165
SCM_REDUCE_LAST, /* The callee must finalize. */
166
SCM_REDUCE_STOP /* Callee wants to stop. */
170
SCM_RETTYPE_AS_IS = 0,
171
SCM_RETTYPE_NEED_EVAL = 1
174
/* The evaluator's state */
175
struct ScmEvalState_ {
177
enum ScmReturnType ret_type;
182
enum ScmObjType type;
210
enum ScmFuncTypeCode type;
225
enum ScmPortDirection port_direction; /* (PORT_INPUT | PORT_OUTPUT) */
226
ScmPortInfo *port_info;
229
struct ScmContinuation {
234
#if !SCM_USE_VALUECONS
235
struct ScmValuePacket {
244
struct ScmCFuncPointer {
250
/*=======================================
251
Multibyte encoding support
252
=======================================*/
254
/* This type will actually contain some encoding-dependent enum value.
255
* It might as well be defined as mbstate_t if we're using libc. */
256
typedef int ScmMultibyteState;
258
/* Metadata of a multibyte character. These are usually allocated on
259
stack or register, so we'll make liberal use of space. */
265
#if SCM_USE_STATEFUL_ENCODING
266
/* Shift state at the *end* of the described character. */
267
ScmMultibyteState state;
269
} ScmMultibyteCharInfo;
274
/* Only the size is stored because ScmObj caches the length, and
275
* we'll have to traverse from the beginning all the time
278
#if SCM_USE_STATEFUL_ENCODING
279
ScmMultibyteState state;
281
} ScmMultibyteString;
283
#define SCM_MBS_SET_STR(mbs, s) ((mbs).str = (s))
284
#define SCM_MBS_GET_STR(mbs) ((mbs).str)
285
#define SCM_MBS_SET_SIZE(mbs, siz) ((mbs).size = (siz))
286
#define SCM_MBS_GET_SIZE(mbs) ((mbs).size)
288
#define SCM_MBCINFO_SET_SIZE SCM_MBS_SET_SIZE
289
#define SCM_MBCINFO_GET_SIZE SCM_MBS_GET_SIZE
290
#define SCM_MBCINFO_CLEAR_STATE SCM_MBS_CLEAR_STATE
291
#define SCM_MBCINFO_SET_STATE SCM_MBS_SET_STATE
292
#define SCM_MBCINFO_GET_STATE SCM_MBS_GET_STATE
293
#define SCM_MBCINFO_CLEAR_FLAG(inf) ((inf).flag = 0)
294
#define SCM_MBCINFO_SET_ERROR(inf) ((inf).flag |= 1)
295
#define SCM_MBCINFO_SET_INCOMPLETE(inf) ((inf).flag |= 2)
296
#define SCM_MBCINFO_ERRORP(inf) ((inf).flag & 1)
297
#define SCM_MBCINFO_INCOMPLETEP(inf) ((inf).flag & 2)
298
#define SCM_MBCINFO_INIT(inf) (SCM_MBCINFO_SET_SIZE((inf), 0), \
299
SCM_MBCINFO_CLEAR_STATE(inf), \
300
SCM_MBCINFO_CLEAR_FLAG(inf))
303
#if SCM_USE_STATEFUL_ENCODING
304
#define SCM_MBS_GET_STATE(mbs) ((mbs).state)
305
#define SCM_MBS_SET_STATE(mbs, stat) ((mbs).state = (stat))
306
#define SCM_MBS_CLEAR_STATE(mbs) ((mbs).state = 0)
308
#define SCM_MBS_GET_STATE(mbs) 0
309
#define SCM_MBS_SET_STATE(mbs, stat) 0
310
#define SCM_MBS_CLEAR_STATE(mbs) 0
312
#define SCM_MBS_INIT(mbs) (SCM_MBS_SET_STR((mbs), NULL), \
313
SCM_MBS_SET_SIZE((mbs), 0), \
314
SCM_MBS_CLEAR_STATE(mbs))
315
#define SCM_MBS_SKIP_CHAR(mbs, inf) \
316
(SCM_MBS_SET_STR((mbs), SCM_MBS_GET_STR(mbs) + SCM_MBCINFO_GET_SIZE(inf)),\
317
SCM_MBS_SET_SIZE((mbs), \
318
SCM_MBS_GET_SIZE(mbs) - SCM_MBCINFO_GET_SIZE(inf)), \
319
SCM_MBS_SET_STATE((mbs), SCM_MBCINFO_GET_STATE(inf)))
323
/*=======================================
324
Accessors For Scheme Objects
325
=======================================*/
326
/* ScmObj Global Attribute */
327
#define SCM_TYPE(a) ((a)->type)
328
#define SCM_ENTYPE(a, objtype) ((a)->type = (objtype))
329
#define SCM_MARK(a) ((a)->gcmark)
331
/* Type Confirmation */
332
#if SCM_ACCESSOR_ASSERT
333
#define SCM_ASSERT_TYPE(cond, x) (SCM_ASSERT(cond), (x))
335
#define SCM_ASSERT_TYPE(cond, x) (x)
336
#endif /* SCM_ACCESSOR_ASSERT */
337
#define SCM_AS_INT(a) (SCM_ASSERT_TYPE(SCM_INTP(a), (a)))
338
#define SCM_AS_CONS(a) (SCM_ASSERT_TYPE(SCM_CONSP(a), (a)))
339
#define SCM_AS_SYMBOL(a) (SCM_ASSERT_TYPE(SCM_SYMBOLP(a), (a)))
340
#define SCM_AS_CHAR(a) (SCM_ASSERT_TYPE(SCM_CHARP(a), (a)))
341
#define SCM_AS_STRING(a) (SCM_ASSERT_TYPE(SCM_STRINGP(a), (a)))
342
#define SCM_AS_FUNC(a) (SCM_ASSERT_TYPE(SCM_FUNCP(a), (a)))
343
#define SCM_AS_CLOSURE(a) (SCM_ASSERT_TYPE(SCM_CLOSUREP(a), (a)))
344
#define SCM_AS_VECTOR(a) (SCM_ASSERT_TYPE(SCM_VECTORP(a), (a)))
345
#define SCM_AS_PORT(a) (SCM_ASSERT_TYPE(SCM_PORTP(a), (a)))
346
#define SCM_AS_CONTINUATION(a) (SCM_ASSERT_TYPE(SCM_CONTINUATIONP(a), (a)))
347
#define SCM_AS_VALUEPACKET(a) (SCM_ASSERT_TYPE(SCM_VALUEPACKETP(a), (a)))
348
#define SCM_AS_C_POINTER(a) (SCM_ASSERT_TYPE(SCM_C_POINTERP(a), (a)))
349
#define SCM_AS_C_FUNCPOINTER(a) (SCM_ASSERT_TYPE(SCM_C_FUNCPOINTERP(a), (a)))
352
#define SCM_INTP(a) (SCM_TYPE(a) == ScmInt)
353
#define SCM_ENTYPE_INT(a) (SCM_ENTYPE((a), ScmInt))
354
#define SCM_INT_VALUE(a) (SCM_AS_INT(a)->obj.int_value.value)
355
#define SCM_INT_SET_VALUE(a, val) (SCM_INT_VALUE(a) = (val))
357
#define SCM_CONSP(a) (SCM_TYPE(a) == ScmCons)
358
#define SCM_ENTYPE_CONS(a) (SCM_ENTYPE((a), ScmCons))
359
#define SCM_CAR(a) (SCM_AS_CONS(a)->obj.cons.car)
360
#define SCM_CONS_SET_CAR(a,car) (SCM_CAR(a) = car)
361
#define SCM_CDR(a) (SCM_AS_CONS(a)->obj.cons.cdr)
362
#define SCM_CONS_SET_CDR(a,cdr) (SCM_CDR(a) = cdr)
363
#define SCM_CAAR(a) (SCM_CAR(SCM_CAR(a)))
364
#define SCM_CADR(a) (SCM_CAR(SCM_CDR(a)))
365
#define SCM_CDAR(a) (SCM_CDR(SCM_CAR(a)))
366
#define SCM_CDDR(a) (SCM_CDR(SCM_CDR(a)))
368
#define SCM_SYMBOLP(a) (SCM_TYPE(a) == ScmSymbol)
369
#define SCM_ENTYPE_SYMBOL(a) (SCM_ENTYPE((a), ScmSymbol))
370
#define SCM_SYMBOL_NAME(a) (SCM_AS_SYMBOL(a)->obj.symbol.sym_name)
371
#define SCM_SYMBOL_SET_NAME(a, name) (SCM_SYMBOL_NAME(a) = (name))
372
#define SCM_SYMBOL_VCELL(a) (SCM_AS_SYMBOL(a)->obj.symbol.v_cell)
373
#define SCM_SYMBOL_SET_VCELL(a, vcell) (SCM_SYMBOL_VCELL(a) = (vcell))
375
#define SCM_CHARP(a) (SCM_TYPE(a) == ScmChar)
376
#define SCM_ENTYPE_CHAR(a) (SCM_ENTYPE((a), ScmChar))
377
#define SCM_CHAR_VALUE(a) (SCM_AS_CHAR(a)->obj.ch.ch)
378
#define SCM_CHAR_SET_VALUE(a, chr) (SCM_CHAR_VALUE(a) = (chr))
380
#define SCM_STRINGP(a) (SCM_TYPE(a) == ScmString)
381
#define SCM_ENTYPE_STRING(a) (SCM_ENTYPE((a), ScmString))
382
#define SCM_STRING_STR(a) (SCM_AS_STRING(a)->obj.string.str)
383
#define SCM_STRING_SET_STR(a, str) (SCM_STRING_STR(a) = (str))
384
#define SCM_STRING_LEN(a) (SCM_AS_STRING(a)->obj.string.len)
385
#define SCM_STRING_SET_LEN(a, len) (SCM_STRING_LEN(a) = (len))
387
#define SCM_FUNCP(a) (SCM_TYPE(a) == ScmFunc)
388
#define SCM_ENTYPE_FUNC(a) (SCM_ENTYPE((a), ScmFunc))
389
#define SCM_FUNC_TYPECODE(a) (SCM_AS_FUNC(a)->obj.func.type)
390
#define SCM_FUNC_SET_TYPECODE(a, type) (SCM_FUNC_TYPECODE(a) = (type))
391
#define SCM_FUNC_CFUNC(a) (SCM_AS_FUNC(a)->obj.func.func)
392
#define SCM_FUNC_SET_CFUNC(a, func) (SCM_FUNC_CFUNC(a) = (ScmFuncType)(func))
393
#define SCM_SYNTAXP(a) (SCM_FUNCP(a) \
394
&& (SCM_FUNC_TYPECODE(a) & SCM_FUNCTYPE_SYNTAX))
395
#define SCM_PROCEDUREP(a) ((SCM_FUNCP(a) \
396
&& !(SCM_FUNC_TYPECODE(a) & SCM_FUNCTYPE_SYNTAX)) \
398
|| SCM_CONTINUATIONP(a))
400
#define SCM_CLOSUREP(a) (SCM_TYPE(a) == ScmClosure)
401
#define SCM_ENTYPE_CLOSURE(a) (SCM_ENTYPE((a), ScmClosure))
402
#define SCM_CLOSURE_EXP(a) (SCM_AS_CLOSURE(a)->obj.closure.exp)
403
#define SCM_CLOSURE_SET_EXP(a, exp) (SCM_CLOSURE_EXP(a) = exp)
404
#define SCM_CLOSURE_ENV(a) (SCM_AS_CLOSURE(a)->obj.closure.env)
405
#define SCM_CLOSURE_SET_ENV(a, env) (SCM_CLOSURE_ENV(a) = env)
407
#define SCM_VECTORP(a) (SCM_TYPE(a) == ScmVector)
408
#define SCM_ENTYPE_VECTOR(a) (SCM_ENTYPE((a), ScmVector))
409
#define SCM_VECTOR_VEC(a) (SCM_AS_VECTOR(a)->obj.vector.vec)
410
#define SCM_VECTOR_SET_VEC(a, vec) (SCM_VECTOR_VEC(a) = (vec))
411
#define SCM_VECTOR_LEN(a) (SCM_AS_VECTOR(a)->obj.vector.len)
412
#define SCM_VECTOR_SET_LEN(a, len) (SCM_VECTOR_LEN(a) = (len))
413
#define SCM_VECTOR_CREF(a, idx) (SCM_VECTOR_VEC(a)[idx])
414
#define SCM_VECTOR_SET_CREF(a, idx, b) (SCM_VECTOR_CREF((a), (idx)) = (b))
415
#define SCM_VECTOR_REF(a, idx) (SCM_VECTOR_CREF((a), SCM_INT_VALUE(idx)))
416
#define SCM_VECTOR_SET_REF(a, idx, b) (SCM_VECTOR_REF((a), (idx)) = (b))
417
#define SCM_VECTOR_CHECK_IDX(a, idx) ()
419
#define SCM_PORTP(a) (SCM_TYPE(a) == ScmPort)
420
#define SCM_ENTYPE_PORT(a) (SCM_ENTYPE((a), ScmPort))
421
#define SCM_PORT_PORTDIRECTION(a) (SCM_AS_PORT(a)->obj.port.port_direction)
422
#define SCM_PORT_SET_PORTDIRECTION(a, pdirection) (SCM_PORT_PORTDIRECTION(a) = pdirection)
423
#define SCM_PORT_PORTINFO(a) (SCM_AS_PORT(a)->obj.port.port_info)
424
#define SCM_PORT_SET_PORTINFO(a, pinfo) (SCM_PORT_PORTINFO(a) = (pinfo))
426
#define SCM_PORT_PORTTYPE(a) (SCM_PORT_PORTINFO(a)->port_type)
427
#define SCM_PORT_SET_PORTTYPE(a, type) (SCM_PORT_PORTTYPE(a) = type)
428
#define SCM_PORT_UNGOTTENCHAR(a) (SCM_PORT_PORTINFO(a)->ungottenchar)
429
#define SCM_PORT_SET_UNGOTTENCHAR(a, ch) (SCM_PORT_UNGOTTENCHAR(a) = ch)
430
#define SCM_PORT_GETC_FUNC(a) (SCM_PORT_PORTINFO(a)->getc_func)
431
#define SCM_PORT_SET_GETC_FUNC(a, func) (SCM_PORT_GETC_FUNC(a) = func)
432
#define SCM_PORT_PRINT_FUNC(a) (SCM_PORT_PORTINFO(a)->print_func)
433
#define SCM_PORT_SET_PRINT_FUNC(a, func) (SCM_PORT_PRINT_FUNC(a) = func)
436
#define SCM_PORT_FILE(a) (SCM_PORT_PORTINFO(a)->info.file_port.file)
437
#define SCM_PORT_SET_FILE(a, file) (SCM_PORT_FILE(a) = file)
438
#define SCM_PORT_FILENAME(a) (SCM_PORT_PORTINFO(a)->info.file_port.filename)
439
#define SCM_PORT_SET_FILENAME(a, filename) (SCM_PORT_FILENAME(a) = filename)
440
#define SCM_PORT_LINE(a) (SCM_PORT_PORTINFO(a)->info.file_port.line)
441
#define SCM_PORT_SET_LINE(a, line) (SCM_PORT_LINE(a) = line)
443
#define SCM_PORT_STR(a) (SCM_PORT_PORTINFO(a)->info.str_port.port_str)
444
#define SCM_PORT_SET_STR(a, str) (SCM_PORT_STR(a) = str)
445
#define SCM_PORT_STR_CURRENTPOS(a) (SCM_PORT_PORTINFO(a)->info.str_port.str_currentpos)
446
#define SCM_PORT_SET_STR_CURRENTPOS(a, pos) (SCM_PORT_STR_CURRENTPOS(a) = pos)
448
#define SCM_CONTINUATIONP(a) (SCM_TYPE(a) == ScmContinuation)
449
#define SCM_ENTYPE_CONTINUATION(a) (SCM_ENTYPE((a), ScmContinuation))
450
#define SCM_CONTINUATION_OPAQUE0(a) (SCM_AS_CONTINUATION(a)->obj.continuation.opaque0)
451
#define SCM_CONTINUATION_SET_OPAQUE0(a, val) (SCM_CONTINUATION_OPAQUE0(a) = (val))
452
#define SCM_CONTINUATION_OPAQUE1(a) (SCM_AS_CONTINUATION(a)->obj.continuation.opaque1)
453
#define SCM_CONTINUATION_SET_OPAQUE1(a, val) (SCM_CONTINUATION_OPAQUE1(a) = (val))
455
#if SCM_USE_VALUECONS
456
/* to modify a VALUECONS, rewrite its type to cons by SCM_ENTYPE_CONS(vcons) */
457
#define SCM_VALUEPACKETP(a) (SCM_TYPE(a) == ScmValuePacket)
458
#define SCM_NULLVALUESP(a) (EQ(a, SigScm_null_values))
459
#define SCM_ENTYPE_VALUEPACKET(a) (SCM_ENTYPE((a), ScmValuePacket))
460
#define SCM_MAKE_VALUEPACKET(vals) (NULLP(vals) ? SigScm_null_values : \
461
(SCM_ENTYPE_VALUEPACKET(vals), (vals)))
462
#define SCM_VALUEPACKET_VALUES(a) ((SCM_NULLVALUESP(a)) ? SCM_NULL : \
463
(SCM_ENTYPE_CONS(a), (a)))
464
#define SCM_VALUECONS_CAR(a) (SCM_AS_VALUEPACKET(a)->obj.cons.car)
465
#define SCM_VALUECONS_CDR(a) (SCM_AS_VALUEPACKET(a)->obj.cons.cdr)
466
#else /* SCM_USE_VALUECONS */
467
#define SCM_VALUEPACKETP(a) (SCM_TYPE(a) == ScmValuePacket)
468
#define SCM_ENTYPE_VALUEPACKET(a) (SCM_ENTYPE((a), ScmValuePacket))
469
#define SCM_MAKE_VALUEPACKET(vals) (Scm_NewValuePacket(vals))
470
#define SCM_VALUEPACKET_VALUES(a) (SCM_AS_VALUEPACKET(a)->obj.value_pack.values)
471
#define SCM_VALUEPACKET_SET_VALUES(a, v) (SCM_VALUEPACKET_VALUES(a) = (v))
472
#endif /* SCM_USE_VALUECONS */
474
/*============================================================================
475
Special Constants (such as SCM_NULL)
476
============================================================================*/
477
#define SCM_CONSTANTP(a) (SCM_TYPE(a) == ScmConstant)
479
/*============================================================================
481
============================================================================*/
482
#define SCM_C_POINTERP(a) (SCM_TYPE(a) == ScmCPointer)
483
#define SCM_ENTYPE_C_POINTER(a) (SCM_ENTYPE((a), ScmCPointer))
484
#define SCM_C_POINTER_VALUE(a) (SCM_AS_C_POINTER(a)->obj.c_pointer.data)
485
#define SCM_C_POINTER_SET_VALUE(a, ptr) (SCM_C_POINTER_VALUE(a) = ptr)
487
#define SCM_C_FUNCPOINTERP(a) (SCM_TYPE(a) == ScmCFuncPointer)
488
#define SCM_ENTYPE_C_FUNCPOINTER(a) (SCM_ENTYPE((a), ScmCFuncPointer))
489
#define SCM_C_FUNCPOINTER_VALUE(a) (SCM_AS_C_FUNCPOINTER(a)->obj.c_func_pointer.func)
490
#define SCM_C_FUNCPOINTER_SET_VALUE(a, funcptr) (SCM_C_FUNCPOINTER_VALUE(a) = funcptr)
492
/*============================================================================
493
Environment Specifiers
494
============================================================================*/
495
#define SCM_INTERACTION_ENV SCM_NULL
497
* Current implementation cannot handle scheme-report-environment and
498
* null-environment properly. Be careful to use these environemnts.
500
#define SCM_R5RS_ENV SCM_INTERACTION_ENV
501
#define SCM_NULL_ENV SCM_INTERACTION_ENV
503
#define SCM_ENVP(env) (NULLP(env) || CONSP(env))
505
/*============================================================================
506
Abstract ScmObj Reference For Storage-Representation Independent Efficient
508
============================================================================*/
509
#define SCM_REF_CAR(cons) (&SCM_CAR(cons))
510
#define SCM_REF_CDR(cons) (&SCM_CDR(cons))
511
#define SCM_DEREF(ref) (*(ref))
512
/* RFC: Is there a better name? */
513
#define SCM_SET(ref, obj) (*(ref) = (obj))
515
/*============================================================================
516
Special Constants and Predicates
517
============================================================================*/
518
#define SCM_INVALID NULL
519
#define SCM_NULL SigScm_null
520
#define SCM_TRUE SigScm_true
521
#define SCM_FALSE SigScm_false
522
#define SCM_EOF SigScm_eof
523
#define SCM_UNBOUND SigScm_unbound
524
#define SCM_UNDEF SigScm_undef
526
#define SCM_EQ(a, b) ((a) == (b))
527
#define SCM_NULLP(a) (SCM_EQ((a), SCM_NULL))
528
#define SCM_FALSEP(a) (SCM_EQ((a), SCM_FALSE))
529
#define SCM_NFALSEP(a) (!SCM_EQ((a), SCM_FALSE))
530
#define SCM_EOFP(a) (SCM_EQ((a), SCM_EOF))
532
/*============================================================================
534
============================================================================*/
535
/* for list construction */
538
* - Rename to SCM_SYM_* to indicate that these macro are not pointing to
541
#define SCM_QUOTE SigScm_quote
542
#define SCM_QUASIQUOTE SigScm_quasiquote
543
#define SCM_UNQUOTE SigScm_unquote
544
#define SCM_UNQUOTE_SPLICING SigScm_unquote_splicing
546
/*============================================================================
547
Internal Declarations For Special Constants And Predefined Symbols
548
============================================================================*/
550
* These declarations are dedicated to internal use. libsscm users MUST NOT
551
* refer these internal representations directly.
553
* It may be changed when SigScheme's internal storage model or accessing
554
* method for the constants has been changed. To avoid suffering code
555
* incompatibility from it, use the abstract macro such as SCM_NULL defined
556
* above. They safely hides the internal model against such change.
559
extern ScmObj SigScm_null, SigScm_true, SigScm_false, SigScm_eof;
560
extern ScmObj SigScm_unbound, SigScm_undef;
563
extern ScmObj SigScm_quote, SigScm_quasiquote, SigScm_unquote;
564
extern ScmObj SigScm_unquote_splicing;
566
#endif /* __SIGSCMTYPE_H */