2000-05-01 13:42:38 +04:00
|
|
|
/**********************************************************************
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
ruby.h -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: Thu Jun 10 14:26:32 JST 1993
|
|
|
|
|
2000-01-05 07:41:21 +03:00
|
|
|
Copyright (C) 1993-2000 Yukihiro Matsumoto
|
2000-05-01 13:42:38 +04:00
|
|
|
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
|
2000-05-09 08:53:16 +04:00
|
|
|
Copyright (C) 2000 Information-technology Promotion Agency, Japan
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2000-05-01 13:42:38 +04:00
|
|
|
**********************************************************************/
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
#ifndef RUBY_H
|
|
|
|
#define RUBY_H
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
1998-01-16 15:13:05 +03:00
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#include "config.h"
|
1998-01-16 15:13:05 +03:00
|
|
|
#include "defines.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_STDLIB_H
|
|
|
|
# include <stdlib.h>
|
|
|
|
#endif
|
|
|
|
|
1998-01-16 15:19:22 +03:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#else
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
/* need to include <ctype.h> to use these macros */
|
1999-08-13 09:45:20 +04:00
|
|
|
#undef ISPRINT
|
|
|
|
#define ISPRINT(c) isprint((unsigned char)(c))
|
1999-01-20 07:59:39 +03:00
|
|
|
#define ISSPACE(c) isspace((unsigned char)(c))
|
|
|
|
#define ISUPPER(c) isupper((unsigned char)(c))
|
|
|
|
#define ISLOWER(c) islower((unsigned char)(c))
|
|
|
|
#define ISALNUM(c) isalnum((unsigned char)(c))
|
|
|
|
#define ISALPHA(c) isalpha((unsigned char)(c))
|
|
|
|
#define ISDIGIT(c) isdigit((unsigned char)(c))
|
|
|
|
#define ISXDIGIT(c) isxdigit((unsigned char)(c))
|
|
|
|
|
1998-01-16 15:13:05 +03:00
|
|
|
#ifndef __STDC__
|
|
|
|
# define volatile
|
1999-01-20 07:59:39 +03:00
|
|
|
#endif
|
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
#undef _
|
1999-01-20 07:59:39 +03:00
|
|
|
#ifdef HAVE_PROTOTYPES
|
|
|
|
# define _(args) args
|
|
|
|
#else
|
1998-01-16 15:13:05 +03:00
|
|
|
# define _(args) ()
|
1999-01-20 07:59:39 +03:00
|
|
|
#endif
|
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
#undef __
|
1999-01-20 07:59:39 +03:00
|
|
|
#ifdef HAVE_STDARG_PROTOTYPES
|
|
|
|
# define __(args) args
|
1998-01-16 15:13:05 +03:00
|
|
|
#else
|
1999-01-20 07:59:39 +03:00
|
|
|
# define __(args) ()
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_ATTR_NORETURN
|
|
|
|
# define NORETURN __attribute__ ((noreturn))
|
|
|
|
#else
|
|
|
|
# define NORETURN
|
1998-01-16 15:13:05 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
|
|
|
|
#include <alloca.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _AIX
|
|
|
|
#pragma alloca
|
|
|
|
#endif
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#if SIZEOF_LONG != SIZEOF_VOIDP
|
|
|
|
---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
|
1999-08-13 09:45:20 +04:00
|
|
|
#endif
|
1999-01-20 07:59:39 +03:00
|
|
|
typedef unsigned long VALUE;
|
1999-12-14 09:50:43 +03:00
|
|
|
typedef unsigned long ID;
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
#ifdef __STDC__
|
|
|
|
# include <limits.h>
|
|
|
|
#else
|
|
|
|
# ifndef LONG_MAX
|
|
|
|
# ifdef HAVE_LIMITS_H
|
|
|
|
# include <limits.h>
|
|
|
|
# else
|
1999-01-20 07:59:39 +03:00
|
|
|
/* assuming 32bit(2's compliment) long */
|
|
|
|
# define LONG_MAX 2147483647
|
1998-01-16 15:13:05 +03:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# ifndef LONG_MIN
|
1999-01-20 07:59:39 +03:00
|
|
|
# define LONG_MIN (-LONG_MAX-1)
|
1998-01-16 15:13:05 +03:00
|
|
|
# endif
|
|
|
|
# ifndef CHAR_BIT
|
|
|
|
# define CHAR_BIT 8
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define FIXNUM_MAX (LONG_MAX>>1)
|
1999-01-20 07:59:39 +03:00
|
|
|
#define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
#define FIXNUM_FLAG 0x01
|
2000-03-07 11:37:59 +03:00
|
|
|
#define INT2FIX(i) ((VALUE)(((long)(i))<<1 | FIXNUM_FLAG))
|
2000-02-17 10:11:22 +03:00
|
|
|
#define rb_fix_new(v) INT2FIX(v)
|
1999-01-20 07:59:39 +03:00
|
|
|
VALUE rb_int2inum _((long));
|
|
|
|
#define INT2NUM(v) rb_int2inum(v)
|
2000-02-17 10:11:22 +03:00
|
|
|
#define rb_int_new(v) rb_int2inum(v)
|
1999-12-14 09:50:43 +03:00
|
|
|
VALUE rb_uint2inum _((unsigned long));
|
|
|
|
#define UINT2NUM(v) rb_uint2inum(v)
|
2000-02-17 10:11:22 +03:00
|
|
|
#define rb_uint_new(v) rb_uint2inum(v)
|
1998-01-16 15:13:05 +03:00
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#define FIX2LONG(x) RSHIFT((long)x,1)
|
|
|
|
#define FIX2ULONG(x) (((unsigned long)(x))>>1)
|
1998-01-16 15:19:22 +03:00
|
|
|
#define FIXNUM_P(f) (((long)(f))&FIXNUM_FLAG)
|
1998-01-16 15:13:05 +03:00
|
|
|
#define POSFIXABLE(f) ((f) <= FIXNUM_MAX)
|
|
|
|
#define NEGFIXABLE(f) ((f) >= FIXNUM_MIN)
|
|
|
|
#define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
|
|
|
|
|
2000-03-07 11:37:59 +03:00
|
|
|
#define IMMEDIATE_MASK 0x03
|
|
|
|
#define IMMEDIATE_P(x) ((VALUE)(x) & IMMEDIATE_MASK)
|
|
|
|
|
|
|
|
#define SYMBOL_FLAG 0x0e
|
|
|
|
#define SYMBOL_P(x) (((VALUE)(x)&0xff)==SYMBOL_FLAG)
|
|
|
|
#define ID2SYM(x) ((VALUE)(((long)(x))<<8|SYMBOL_FLAG))
|
|
|
|
#define SYM2ID(x) RSHIFT((long)x,8)
|
|
|
|
|
1998-01-16 15:13:05 +03:00
|
|
|
/* special contants - i.e. non-zero and non-fixnum constants */
|
1998-01-16 15:19:22 +03:00
|
|
|
#define Qfalse 0
|
|
|
|
#define Qtrue 2
|
|
|
|
#define Qnil 4
|
2000-01-05 07:41:21 +03:00
|
|
|
#define Qundef 6 /* undefined value for placeholder */
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2000-09-25 13:15:08 +04:00
|
|
|
#define RTEST(v) (((VALUE)(v) & ~Qnil) != 0)
|
1998-01-16 15:13:05 +03:00
|
|
|
#define NIL_P(v) ((VALUE)(v) == Qnil)
|
|
|
|
|
|
|
|
#define CLASS_OF(v) rb_class_of((VALUE)(v))
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#define T_NONE 0x00
|
|
|
|
|
|
|
|
#define T_NIL 0x01
|
|
|
|
#define T_OBJECT 0x02
|
|
|
|
#define T_CLASS 0x03
|
|
|
|
#define T_ICLASS 0x04
|
|
|
|
#define T_MODULE 0x05
|
|
|
|
#define T_FLOAT 0x06
|
|
|
|
#define T_STRING 0x07
|
|
|
|
#define T_REGEXP 0x08
|
|
|
|
#define T_ARRAY 0x09
|
|
|
|
#define T_FIXNUM 0x0a
|
|
|
|
#define T_HASH 0x0b
|
|
|
|
#define T_STRUCT 0x0c
|
|
|
|
#define T_BIGNUM 0x0d
|
|
|
|
#define T_FILE 0x0e
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
#define T_TRUE 0x20
|
|
|
|
#define T_FALSE 0x21
|
|
|
|
#define T_DATA 0x22
|
|
|
|
#define T_MATCH 0x23
|
2000-03-07 11:37:59 +03:00
|
|
|
#define T_SYMBOL 0x24
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2000-03-07 11:37:59 +03:00
|
|
|
#define T_UNDEF 0x3c
|
2000-02-01 06:12:21 +03:00
|
|
|
#define T_VARMAP 0x3d
|
|
|
|
#define T_SCOPE 0x3e
|
|
|
|
#define T_NODE 0x3f
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2000-02-01 06:12:21 +03:00
|
|
|
#define T_MASK 0x3f
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
#define BUILTIN_TYPE(x) (((struct RBasic*)(x))->flags & T_MASK)
|
|
|
|
|
|
|
|
#define TYPE(x) rb_type((VALUE)(x))
|
|
|
|
|
|
|
|
void rb_check_type _((VALUE,int));
|
|
|
|
#define Check_Type(v,t) rb_check_type((VALUE)(v),t)
|
|
|
|
void rb_check_safe_str _((VALUE));
|
|
|
|
#define Check_SafeStr(v) rb_check_safe_str((VALUE)(v))
|
|
|
|
void rb_secure _((int));
|
|
|
|
|
2000-02-29 11:05:32 +03:00
|
|
|
EXTERN int ruby_safe_level;
|
2000-02-01 06:12:21 +03:00
|
|
|
#define rb_safe_level() (ruby_safe_level)
|
|
|
|
void rb_set_safe_level _((int));
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
long rb_num2long _((VALUE));
|
|
|
|
unsigned long rb_num2ulong _((VALUE));
|
1999-08-13 09:45:20 +04:00
|
|
|
#define NUM2LONG(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2long((VALUE)x))
|
1999-01-20 07:59:39 +03:00
|
|
|
#define NUM2ULONG(x) rb_num2ulong((VALUE)x)
|
|
|
|
#if SIZEOF_INT < SIZEOF_LONG
|
|
|
|
int rb_num2int _((VALUE));
|
|
|
|
#define NUM2INT(x) (FIXNUM_P(x)?FIX2INT(x):rb_num2int((VALUE)x))
|
|
|
|
int rb_fix2int _((VALUE));
|
|
|
|
#define FIX2INT(x) rb_fix2int((VALUE)x)
|
2000-10-16 13:13:20 +04:00
|
|
|
#define NUM2UINT(x) ((unsigned int)NUM2INT(x))
|
|
|
|
#define FIX2UINT(x) ((unsigned int)FIX2INT(x))
|
1999-01-20 07:59:39 +03:00
|
|
|
#else
|
|
|
|
#define NUM2INT(x) NUM2LONG(x)
|
|
|
|
#define NUM2UINT(x) NUM2ULONG(x)
|
|
|
|
#define FIX2INT(x) FIX2LONG(x)
|
|
|
|
#define FIX2UINT(x) FIX2ULONG(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
double rb_num2dbl _((VALUE));
|
|
|
|
#define NUM2DBL(x) rb_num2dbl((VALUE)(x))
|
|
|
|
|
|
|
|
char *rb_str2cstr _((VALUE,int*));
|
|
|
|
#define str2cstr(x,l) rb_str2cstr((VALUE)(x),(l))
|
|
|
|
#define STR2CSTR(x) rb_str2cstr((VALUE)(x),0)
|
1998-01-16 15:19:22 +03:00
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#define NUM2CHR(x) (((TYPE(x) == T_STRING)&&(RSTRING(x)->len>=1))?\
|
1999-08-13 09:45:20 +04:00
|
|
|
RSTRING(x)->ptr[0]:(char)(NUM2INT(x)&0xff))
|
|
|
|
#define CHR2FIX(x) INT2FIX((long)((x)&0xff))
|
1998-01-16 15:13:05 +03:00
|
|
|
|
1998-01-16 15:19:22 +03:00
|
|
|
VALUE rb_newobj _((void));
|
1998-01-16 15:13:05 +03:00
|
|
|
#define NEWOBJ(obj,type) type *obj = (type*)rb_newobj()
|
|
|
|
#define OBJSETUP(obj,c,t) {\
|
|
|
|
RBASIC(obj)->flags = (t);\
|
2000-08-09 08:32:24 +04:00
|
|
|
RBASIC(obj)->klass = (c);\
|
1999-01-20 07:59:39 +03:00
|
|
|
if (rb_safe_level() >= 3) FL_SET(obj, FL_TAINT);\
|
1998-01-16 15:13:05 +03:00
|
|
|
}
|
1999-08-13 09:45:20 +04:00
|
|
|
#define CLONESETUP(clone,obj) do {\
|
2000-08-09 08:32:24 +04:00
|
|
|
OBJSETUP(clone,rb_singleton_class_clone(RBASIC(obj)->klass),RBASIC(obj)->flags);\
|
1999-01-20 07:59:39 +03:00
|
|
|
rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);\
|
1999-08-13 09:45:20 +04:00
|
|
|
if (FL_TEST(obj, FL_EXIVAR)) rb_clone_generic_ivar((VALUE)clone,(VALUE)obj);\
|
|
|
|
} while (0)
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
struct RBasic {
|
1999-01-20 07:59:39 +03:00
|
|
|
unsigned long flags;
|
|
|
|
VALUE klass;
|
1998-01-16 15:13:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RObject {
|
|
|
|
struct RBasic basic;
|
|
|
|
struct st_table *iv_tbl;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RClass {
|
|
|
|
struct RBasic basic;
|
|
|
|
struct st_table *iv_tbl;
|
|
|
|
struct st_table *m_tbl;
|
1998-01-16 15:19:22 +03:00
|
|
|
VALUE super;
|
1998-01-16 15:13:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RFloat {
|
|
|
|
struct RBasic basic;
|
|
|
|
double value;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RString {
|
|
|
|
struct RBasic basic;
|
1999-08-13 09:45:20 +04:00
|
|
|
long len;
|
1999-01-20 07:59:39 +03:00
|
|
|
char *ptr;
|
1998-01-16 15:19:22 +03:00
|
|
|
VALUE orig;
|
1998-01-16 15:13:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RArray {
|
|
|
|
struct RBasic basic;
|
1999-08-13 09:45:20 +04:00
|
|
|
long len, capa;
|
1998-01-16 15:13:05 +03:00
|
|
|
VALUE *ptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RRegexp {
|
|
|
|
struct RBasic basic;
|
|
|
|
struct re_pattern_buffer *ptr;
|
1999-08-13 09:45:20 +04:00
|
|
|
long len;
|
1999-01-20 07:59:39 +03:00
|
|
|
char *str;
|
1998-01-16 15:13:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RHash {
|
|
|
|
struct RBasic basic;
|
|
|
|
struct st_table *tbl;
|
|
|
|
int iter_lev;
|
1999-01-20 07:59:39 +03:00
|
|
|
VALUE ifnone;
|
1998-01-16 15:13:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RFile {
|
|
|
|
struct RBasic basic;
|
|
|
|
struct OpenFile *fptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RData {
|
|
|
|
struct RBasic basic;
|
1999-12-14 09:50:43 +03:00
|
|
|
void (*dmark) _((void*));
|
|
|
|
void (*dfree) _((void*));
|
1998-01-16 15:13:05 +03:00
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DATA_PTR(dta) (RDATA(dta)->data)
|
|
|
|
|
2000-06-26 19:16:03 +04:00
|
|
|
/*
|
2000-06-22 12:29:58 +04:00
|
|
|
#define RUBY_DATA_FUNC(func) ((void (*)_((void*)))func)
|
2000-06-26 19:16:03 +04:00
|
|
|
*/
|
|
|
|
typedef void (*RUBY_DATA_FUNC) _((void*));
|
|
|
|
|
|
|
|
VALUE rb_data_object_alloc _((VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC));
|
|
|
|
|
|
|
|
#define Data_Wrap_Struct(klass,mark,free,sval) (\
|
|
|
|
rb_data_object_alloc(klass,sval,(RUBY_DATA_FUNC)mark,(RUBY_DATA_FUNC)free)\
|
|
|
|
)
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#define Data_Make_Struct(klass,type,mark,free,sval) (\
|
1998-01-16 15:13:05 +03:00
|
|
|
sval = ALLOC(type),\
|
|
|
|
memset(sval, 0, sizeof(type)),\
|
2000-06-26 19:16:03 +04:00
|
|
|
Data_Wrap_Struct(klass,mark,free,sval)\
|
1998-01-16 15:13:05 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
#define Data_Get_Struct(obj,type,sval) {\
|
|
|
|
Check_Type(obj, T_DATA); \
|
|
|
|
sval = (type*)DATA_PTR(obj);\
|
|
|
|
}
|
|
|
|
|
|
|
|
struct RStruct {
|
|
|
|
struct RBasic basic;
|
1999-08-13 09:45:20 +04:00
|
|
|
long len;
|
1998-01-16 15:13:05 +03:00
|
|
|
VALUE *ptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RBignum {
|
|
|
|
struct RBasic basic;
|
|
|
|
char sign;
|
1999-08-13 09:45:20 +04:00
|
|
|
long len;
|
2000-01-05 07:41:21 +03:00
|
|
|
void *digits;
|
1998-01-16 15:13:05 +03:00
|
|
|
};
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#define R_CAST(st) (struct st*)
|
1998-01-16 15:13:05 +03:00
|
|
|
#define RBASIC(obj) (R_CAST(RBasic)(obj))
|
|
|
|
#define ROBJECT(obj) (R_CAST(RObject)(obj))
|
|
|
|
#define RCLASS(obj) (R_CAST(RClass)(obj))
|
1999-01-20 07:59:39 +03:00
|
|
|
#define RMODULE(obj) RCLASS(obj)
|
1998-01-16 15:13:05 +03:00
|
|
|
#define RFLOAT(obj) (R_CAST(RFloat)(obj))
|
|
|
|
#define RSTRING(obj) (R_CAST(RString)(obj))
|
|
|
|
#define RREGEXP(obj) (R_CAST(RRegexp)(obj))
|
|
|
|
#define RARRAY(obj) (R_CAST(RArray)(obj))
|
|
|
|
#define RHASH(obj) (R_CAST(RHash)(obj))
|
|
|
|
#define RDATA(obj) (R_CAST(RData)(obj))
|
|
|
|
#define RSTRUCT(obj) (R_CAST(RStruct)(obj))
|
|
|
|
#define RBIGNUM(obj) (R_CAST(RBignum)(obj))
|
|
|
|
#define RFILE(obj) (R_CAST(RFile)(obj))
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#define FL_SINGLETON FL_USER0
|
2000-02-01 06:12:21 +03:00
|
|
|
#define FL_MARK (1<<6)
|
|
|
|
#define FL_FINALIZE (1<<7)
|
|
|
|
#define FL_TAINT (1<<8)
|
|
|
|
#define FL_EXIVAR (1<<9)
|
|
|
|
#define FL_FREEZE (1<<10)
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
#define FL_USHIFT 11
|
|
|
|
|
|
|
|
#define FL_USER0 (1<<(FL_USHIFT+0))
|
|
|
|
#define FL_USER1 (1<<(FL_USHIFT+1))
|
|
|
|
#define FL_USER2 (1<<(FL_USHIFT+2))
|
|
|
|
#define FL_USER3 (1<<(FL_USHIFT+3))
|
|
|
|
#define FL_USER4 (1<<(FL_USHIFT+4))
|
|
|
|
#define FL_USER5 (1<<(FL_USHIFT+5))
|
|
|
|
#define FL_USER6 (1<<(FL_USHIFT+6))
|
1999-01-20 07:59:39 +03:00
|
|
|
#define FL_USER7 (1<<(FL_USHIFT+7))
|
1998-01-16 15:13:05 +03:00
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#define FL_UMASK (0xff<<FL_USHIFT)
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2000-03-07 11:37:59 +03:00
|
|
|
#define SPECIAL_CONST_P(x) (IMMEDIATE_P(x) || !RTEST(x))
|
2000-01-05 07:41:21 +03:00
|
|
|
|
|
|
|
#define FL_ABLE(x) (!SPECIAL_CONST_P(x))
|
1998-01-16 15:13:05 +03:00
|
|
|
#define FL_TEST(x,f) (FL_ABLE(x)?(RBASIC(x)->flags&(f)):0)
|
2000-05-12 13:07:57 +04:00
|
|
|
#define FL_SET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags |= (f);} while (0)
|
|
|
|
#define FL_UNSET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags &= ~(f);} while (0)
|
|
|
|
#define FL_REVERSE(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags ^= (f);} while (0)
|
1998-01-16 15:13:05 +03:00
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#define OBJ_TAINTED(x) FL_TEST((x), FL_TAINT)
|
|
|
|
#define OBJ_TAINT(x) FL_SET((x), FL_TAINT)
|
2000-05-12 13:07:57 +04:00
|
|
|
#define OBJ_INFECT(x,s) do {if (FL_ABLE(x) && FL_ABLE(s)) RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT;} while (0)
|
1998-01-16 15:19:22 +03:00
|
|
|
|
2000-02-01 06:12:21 +03:00
|
|
|
#define OBJ_FROZEN(x) FL_TEST((x), FL_FREEZE)
|
|
|
|
#define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE)
|
|
|
|
|
2000-05-16 06:46:57 +04:00
|
|
|
#define xmalloc ruby_xmalloc
|
|
|
|
#define xcalloc ruby_xcalloc
|
|
|
|
#define xrealloc ruby_xrealloc
|
|
|
|
#define xfree ruby_xfree
|
|
|
|
|
2000-11-27 12:23:38 +03:00
|
|
|
void *xmalloc _((long));
|
|
|
|
void *xcalloc _((long,long));
|
|
|
|
void *xrealloc _((void*,long));
|
2000-05-16 06:46:57 +04:00
|
|
|
void xfree _((void*));
|
|
|
|
|
1998-01-16 15:13:05 +03:00
|
|
|
#define ALLOC_N(type,n) (type*)xmalloc(sizeof(type)*(n))
|
|
|
|
#define ALLOC(type) (type*)xmalloc(sizeof(type))
|
|
|
|
#define REALLOC_N(var,type,n) (var)=(type*)xrealloc((char*)(var),sizeof(type)*(n))
|
|
|
|
|
|
|
|
#define ALLOCA_N(type,n) (type*)alloca(sizeof(type)*(n))
|
|
|
|
|
|
|
|
#define MEMZERO(p,type,n) memset((p), 0, sizeof(type)*(n))
|
|
|
|
#define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n))
|
|
|
|
#define MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(n))
|
2000-09-15 10:00:30 +04:00
|
|
|
#define MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(n))
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2000-05-29 06:10:22 +04:00
|
|
|
void rb_glob _((char*,void(*)(),VALUE));
|
2000-11-20 04:24:28 +03:00
|
|
|
void rb_iglob _((char*,void(*)(),VALUE));
|
2000-05-29 06:10:22 +04:00
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
VALUE rb_define_class _((const char*,VALUE));
|
|
|
|
VALUE rb_define_module _((const char*));
|
|
|
|
VALUE rb_define_class_under _((VALUE, const char*, VALUE));
|
|
|
|
VALUE rb_define_module_under _((VALUE, const char*));
|
1998-01-16 15:19:22 +03:00
|
|
|
|
1998-01-16 15:13:05 +03:00
|
|
|
void rb_include_module _((VALUE,VALUE));
|
|
|
|
void rb_extend_object _((VALUE,VALUE));
|
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
void rb_define_variable _((const char*,VALUE*));
|
|
|
|
void rb_define_virtual_variable _((const char*,VALUE(*)(),void(*)()));
|
|
|
|
void rb_define_hooked_variable _((const char*,VALUE*,VALUE(*)(),void(*)()));
|
|
|
|
void rb_define_readonly_variable _((const char*,VALUE*));
|
2000-05-12 13:07:57 +04:00
|
|
|
void rb_define_const _((VALUE,const char*,VALUE));
|
|
|
|
void rb_define_global_const _((const char*,VALUE));
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2000-06-22 12:29:58 +04:00
|
|
|
#define RUBY_METHOD_FUNC(func) ((VALUE (*)__((...)))func)
|
1999-08-13 09:45:20 +04:00
|
|
|
void rb_define_method _((VALUE,const char*,VALUE(*)(),int));
|
|
|
|
void rb_define_module_function _((VALUE,const char*,VALUE(*)(),int));
|
|
|
|
void rb_define_global_function _((const char*,VALUE(*)(),int));
|
1998-01-16 15:19:22 +03:00
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
void rb_undef_method _((VALUE,const char*));
|
|
|
|
void rb_define_alias _((VALUE,const char*,const char*));
|
|
|
|
void rb_define_attr _((VALUE,const char*,int,int));
|
1998-01-16 15:13:05 +03:00
|
|
|
|
2000-02-08 11:54:01 +03:00
|
|
|
void rb_global_variable _((VALUE*));
|
|
|
|
void rb_gc_register_address _((VALUE*));
|
|
|
|
void rb_gc_unregister_address _((VALUE*));
|
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
ID rb_intern _((const char*));
|
1998-01-16 15:13:05 +03:00
|
|
|
char *rb_id2name _((ID));
|
|
|
|
ID rb_to_id _((VALUE));
|
|
|
|
|
|
|
|
char *rb_class2name _((VALUE));
|
1998-01-16 15:19:22 +03:00
|
|
|
|
|
|
|
void rb_p _((VALUE));
|
1998-01-16 15:13:05 +03:00
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
VALUE rb_eval_string _((const char*));
|
|
|
|
VALUE rb_eval_string_protect _((const char*, int*));
|
|
|
|
VALUE rb_eval_string_wrap _((const char*, int*));
|
1999-01-20 07:59:39 +03:00
|
|
|
VALUE rb_funcall __((VALUE, ID, int, ...));
|
1999-08-13 09:45:20 +04:00
|
|
|
VALUE rb_funcall2 _((VALUE, ID, int, VALUE*));
|
|
|
|
VALUE rb_funcall3 _((VALUE, ID, int, VALUE*));
|
|
|
|
int rb_scan_args __((int, VALUE*, const char*, ...));
|
2000-03-06 07:15:42 +03:00
|
|
|
VALUE rb_call_super _((int, VALUE*));
|
1998-01-16 15:13:05 +03:00
|
|
|
|
1999-11-17 10:30:37 +03:00
|
|
|
VALUE rb_gv_set _((const char*, VALUE));
|
|
|
|
VALUE rb_gv_get _((const char*));
|
1999-08-13 09:45:20 +04:00
|
|
|
VALUE rb_iv_get _((VALUE, const char*));
|
|
|
|
VALUE rb_iv_set _((VALUE, const char*, VALUE));
|
1998-01-16 15:13:05 +03:00
|
|
|
|
|
|
|
VALUE rb_equal _((VALUE,VALUE));
|
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
EXTERN VALUE ruby_verbose, ruby_debug;
|
1998-01-16 15:13:05 +03:00
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
void rb_raise __((VALUE, const char*, ...)) NORETURN;
|
|
|
|
void rb_fatal __((const char*, ...)) NORETURN;
|
|
|
|
void rb_bug __((const char*, ...)) NORETURN;
|
|
|
|
void rb_sys_fail _((const char*)) NORETURN;
|
1999-01-20 07:59:39 +03:00
|
|
|
void rb_iter_break _((void)) NORETURN;
|
|
|
|
void rb_exit _((int)) NORETURN;
|
|
|
|
void rb_notimplement _((void)) NORETURN;
|
1998-01-16 15:13:05 +03:00
|
|
|
|
1999-08-13 09:45:20 +04:00
|
|
|
void rb_warn __((const char*, ...));
|
|
|
|
void rb_warning __((const char*, ...)); /* reports if `-w' specified */
|
1998-01-16 15:13:05 +03:00
|
|
|
|
1998-01-16 15:19:22 +03:00
|
|
|
VALUE rb_each _((VALUE));
|
|
|
|
VALUE rb_yield _((VALUE));
|
2000-05-24 08:34:26 +04:00
|
|
|
int rb_block_given_p _((void));
|
1999-01-20 07:59:39 +03:00
|
|
|
VALUE rb_iterate _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
|
|
|
|
VALUE rb_rescue _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
|
2000-08-31 09:29:54 +04:00
|
|
|
VALUE rb_rescue2 __((VALUE(*)(),VALUE,VALUE(*)(),VALUE,...));
|
1999-01-20 07:59:39 +03:00
|
|
|
VALUE rb_ensure _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
|
1999-08-13 09:45:20 +04:00
|
|
|
VALUE rb_catch _((const char*,VALUE(*)(),VALUE));
|
|
|
|
void rb_throw _((const char*,VALUE)) NORETURN;
|
|
|
|
|
|
|
|
VALUE rb_require _((const char*));
|
1999-01-20 07:59:39 +03:00
|
|
|
|
|
|
|
void ruby_init _((void));
|
|
|
|
void ruby_options _((int, char**));
|
|
|
|
void ruby_run _((void));
|
|
|
|
|
|
|
|
EXTERN VALUE rb_mKernel;
|
|
|
|
EXTERN VALUE rb_mComparable;
|
|
|
|
EXTERN VALUE rb_mEnumerable;
|
1999-08-13 09:45:20 +04:00
|
|
|
EXTERN VALUE rb_mPrecision;
|
1999-01-20 07:59:39 +03:00
|
|
|
EXTERN VALUE rb_mErrno;
|
|
|
|
EXTERN VALUE rb_mFileTest;
|
|
|
|
EXTERN VALUE rb_mGC;
|
|
|
|
EXTERN VALUE rb_mMath;
|
|
|
|
EXTERN VALUE rb_mProcess;
|
|
|
|
|
|
|
|
EXTERN VALUE rb_cObject;
|
|
|
|
EXTERN VALUE rb_cArray;
|
|
|
|
EXTERN VALUE rb_cBignum;
|
|
|
|
EXTERN VALUE rb_cClass;
|
|
|
|
EXTERN VALUE rb_cDir;
|
|
|
|
EXTERN VALUE rb_cData;
|
|
|
|
EXTERN VALUE rb_cFalseClass;
|
|
|
|
EXTERN VALUE rb_cFile;
|
|
|
|
EXTERN VALUE rb_cFixnum;
|
|
|
|
EXTERN VALUE rb_cFloat;
|
|
|
|
EXTERN VALUE rb_cHash;
|
|
|
|
EXTERN VALUE rb_cInteger;
|
|
|
|
EXTERN VALUE rb_cIO;
|
|
|
|
EXTERN VALUE rb_cModule;
|
|
|
|
EXTERN VALUE rb_cNilClass;
|
|
|
|
EXTERN VALUE rb_cNumeric;
|
|
|
|
EXTERN VALUE rb_cProc;
|
|
|
|
EXTERN VALUE rb_cRange;
|
|
|
|
EXTERN VALUE rb_cRegexp;
|
|
|
|
EXTERN VALUE rb_cString;
|
2000-03-07 11:37:59 +03:00
|
|
|
EXTERN VALUE rb_cSymbol;
|
1999-01-20 07:59:39 +03:00
|
|
|
EXTERN VALUE rb_cThread;
|
|
|
|
EXTERN VALUE rb_cTime;
|
|
|
|
EXTERN VALUE rb_cTrueClass;
|
|
|
|
EXTERN VALUE rb_cStruct;
|
|
|
|
|
|
|
|
EXTERN VALUE rb_eException;
|
|
|
|
EXTERN VALUE rb_eStandardError;
|
1999-08-13 09:45:20 +04:00
|
|
|
EXTERN VALUE rb_eSystemExit;
|
|
|
|
EXTERN VALUE rb_eInterrupt;
|
|
|
|
EXTERN VALUE rb_eSignal;
|
|
|
|
EXTERN VALUE rb_eFatal;
|
1999-01-20 07:59:39 +03:00
|
|
|
EXTERN VALUE rb_eArgError;
|
|
|
|
EXTERN VALUE rb_eEOFError;
|
|
|
|
EXTERN VALUE rb_eIndexError;
|
2000-03-07 11:37:59 +03:00
|
|
|
EXTERN VALUE rb_eRangeError;
|
1999-01-20 07:59:39 +03:00
|
|
|
EXTERN VALUE rb_eIOError;
|
|
|
|
EXTERN VALUE rb_eRuntimeError;
|
|
|
|
EXTERN VALUE rb_eSecurityError;
|
|
|
|
EXTERN VALUE rb_eSystemCallError;
|
|
|
|
EXTERN VALUE rb_eTypeError;
|
1999-08-13 09:45:20 +04:00
|
|
|
EXTERN VALUE rb_eZeroDivError;
|
1999-01-20 07:59:39 +03:00
|
|
|
EXTERN VALUE rb_eNotImpError;
|
1999-12-14 09:50:43 +03:00
|
|
|
EXTERN VALUE rb_eNoMemError;
|
1999-08-13 09:45:20 +04:00
|
|
|
EXTERN VALUE rb_eFloatDomainError;
|
1999-01-20 07:59:39 +03:00
|
|
|
|
2000-07-31 08:36:38 +04:00
|
|
|
EXTERN VALUE rb_eScriptError;
|
|
|
|
EXTERN VALUE rb_eNameError;
|
|
|
|
EXTERN VALUE rb_eSyntaxError;
|
|
|
|
EXTERN VALUE rb_eLoadError;
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#if defined(__GNUC__) && __GNUC__ >= 2 && !defined(RUBY_NO_INLINE)
|
|
|
|
extern __inline__ VALUE rb_class_of _((VALUE));
|
|
|
|
extern __inline__ int rb_type _((VALUE));
|
|
|
|
extern __inline__ int rb_special_const_p _((VALUE));
|
|
|
|
|
|
|
|
extern __inline__ VALUE
|
|
|
|
rb_class_of(VALUE obj)
|
|
|
|
{
|
|
|
|
if (FIXNUM_P(obj)) return rb_cFixnum;
|
|
|
|
if (obj == Qnil) return rb_cNilClass;
|
|
|
|
if (obj == Qfalse) return rb_cFalseClass;
|
|
|
|
if (obj == Qtrue) return rb_cTrueClass;
|
2000-03-07 11:37:59 +03:00
|
|
|
if (SYMBOL_P(obj)) return rb_cSymbol;
|
1999-01-20 07:59:39 +03:00
|
|
|
|
|
|
|
return RBASIC(obj)->klass;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern __inline__ int
|
|
|
|
rb_type(VALUE obj)
|
|
|
|
{
|
|
|
|
if (FIXNUM_P(obj)) return T_FIXNUM;
|
|
|
|
if (obj == Qnil) return T_NIL;
|
|
|
|
if (obj == Qfalse) return T_FALSE;
|
|
|
|
if (obj == Qtrue) return T_TRUE;
|
2000-05-01 13:42:38 +04:00
|
|
|
if (obj == Qundef) return T_UNDEF;
|
2000-03-07 11:37:59 +03:00
|
|
|
if (SYMBOL_P(obj)) return T_SYMBOL;
|
1999-01-20 07:59:39 +03:00
|
|
|
return BUILTIN_TYPE(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern __inline__ int
|
|
|
|
rb_special_const_p(VALUE obj)
|
|
|
|
{
|
2000-01-05 07:41:21 +03:00
|
|
|
if (SPECIAL_CONST_P(obj)) return Qtrue;
|
1999-08-13 09:45:20 +04:00
|
|
|
return Qfalse;
|
1999-01-20 07:59:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
VALUE rb_class_of _((VALUE));
|
|
|
|
int rb_type _((VALUE));
|
|
|
|
int rb_special_const_p _((VALUE));
|
|
|
|
#endif
|
1998-01-16 15:19:22 +03:00
|
|
|
|
|
|
|
#include "intern.h"
|
|
|
|
|
1998-01-16 15:13:05 +03:00
|
|
|
#if defined(EXTLIB) && defined(USE_DLN_A_OUT)
|
|
|
|
/* hook for external modules */
|
1999-01-20 07:59:39 +03:00
|
|
|
static char *dln_libs_to_be_linked[] = { EXTLIB, 0 };
|
1998-01-16 15:13:05 +03:00
|
|
|
#endif
|
|
|
|
|
1999-01-20 07:59:39 +03:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
} /* extern "C" { */
|
1998-01-16 15:13:05 +03:00
|
|
|
#endif
|
1999-01-20 07:59:39 +03:00
|
|
|
|
|
|
|
#endif /* ifndef RUBY_H */
|