ruby.h


DEFINITIONS

This source file includes following functions.
  1. NORETURN
  2. OFFT2NUM
  3. OFFT2NUM
  4. NUM2LL
  5. NUM2OFFT
  6. NUM2OFFT


   1  /**********************************************************************
   2  
   3    ruby.h -
   4  
   5    $Author: michal $
   6    created at: Thu Jun 10 14:26:32 JST 1993
   7  
   8    Copyright (C) 1993-2002 Yukihiro Matsumoto
   9    Copyright (C) 2000  Network Applied Communication Laboratory, Inc.
  10    Copyright (C) 2000  Information-technology Promotion Agency, Japan
  11  
  12  **********************************************************************/
  13  
  14  #ifndef RUBY_H
  15  #define RUBY_H
  16  
  17  #if defined(__cplusplus)
  18  extern "C" {
  19  #endif
  20  
  21  #include "config.h"
  22  #include "defines.h"
  23  
  24  #ifdef HAVE_STDLIB_H
  25  # include <stdlib.h>
  26  #endif
  27  
  28  #ifdef HAVE_STRING_H
  29  # include <string.h>
  30  #else
  31  # include <strings.h>
  32  #endif
  33  
  34  #include <stddef.h>
  35  #include <stdio.h>
  36  
  37  /* need to include <ctype.h> to use these macros */
  38  #ifndef ISPRINT
  39  #define ISASCII(c) isascii((unsigned char)(c))
  40  #undef ISPRINT
  41  #define ISPRINT(c) (ISASCII(c) && isprint((unsigned char)(c)))
  42  #define ISSPACE(c) (ISASCII(c) && isspace((unsigned char)(c)))
  43  #define ISUPPER(c) (ISASCII(c) && isupper((unsigned char)(c)))
  44  #define ISLOWER(c) (ISASCII(c) && islower((unsigned char)(c)))
  45  #define ISALNUM(c) (ISASCII(c) && isalnum((unsigned char)(c)))
  46  #define ISALPHA(c) (ISASCII(c) && isalpha((unsigned char)(c)))
  47  #define ISDIGIT(c) (ISASCII(c) && isdigit((unsigned char)(c)))
  48  #define ISXDIGIT(c) (ISASCII(c) && isxdigit((unsigned char)(c)))
  49  #endif
  50  
  51  #ifndef NORETURN
  52  # define NORETURN(x) x
  53  #endif
  54  
  55  #if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
  56  #include <alloca.h>
  57  #endif
  58  
  59  #ifdef _AIX
  60  #pragma alloca
  61  #endif
  62  
  63  #if defined(__VMS)
  64  # pragma builtins
  65  # define alloca __alloca
  66  #endif
  67  
  68  #if SIZEOF_LONG != SIZEOF_VOIDP
  69  # error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
  70  #endif
  71  typedef unsigned long VALUE;
  72  typedef unsigned long ID;
  73  
  74  #ifdef __STDC__
  75  # include <limits.h>
  76  #else
  77  # ifndef LONG_MAX
  78  #  ifdef HAVE_LIMITS_H
  79  #   include <limits.h>
  80  #  else
  81      /* assuming 32bit(2's compliment) long */
  82  #   define LONG_MAX 2147483647
  83  #  endif
  84  # endif
  85  # ifndef LONG_MIN
  86  #  define LONG_MIN (-LONG_MAX-1)
  87  # endif
  88  # ifndef CHAR_BIT
  89  #  define CHAR_BIT 8
  90  # endif
  91  #endif
  92  
  93  #if HAVE_LONG_LONG
  94  # ifndef LLONG_MAX
  95  #  ifdef LONG_LONG_MAX
  96  #   define LLONG_MAX  LONG_LONG_MAX
  97  #  else
  98  #   ifdef _I64_MAX
  99  #    define LLONG_MAX _I64_MAX
 100  #   else
 101      /* assuming 64bit(2's complement) long long */
 102  #    define LLONG_MAX 9223372036854775807LL
 103  #   endif
 104  #  endif
 105  # endif
 106  # ifndef LLONG_MIN
 107  #  ifdef LONG_LONG_MIN
 108  #   define LLONG_MIN  LONG_LONG_MIN
 109  #  else
 110  #   ifdef _I64_MIN
 111  #    define LLONG_MIN _I64_MAX
 112  #   else
 113  #    define LLONG_MIN (-LLONG_MAX-1)
 114  #   endif
 115  #  endif
 116  # endif
 117  #endif
 118  
 119  #define FIXNUM_MAX (LONG_MAX>>1)
 120  #define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
 121  
 122  #define FIXNUM_FLAG 0x01
 123  #define INT2FIX(i) ((VALUE)(((long)(i))<<1 | FIXNUM_FLAG))
 124  #define LONG2FIX(i) INT2FIX(i)
 125  #define rb_fix_new(v) INT2FIX(v)
 126  VALUE rb_int2inum _((long));
 127  #define INT2NUM(v) rb_int2inum(v)
 128  #define LONG2NUM(v) INT2NUM(v)
 129  #define rb_int_new(v) rb_int2inum(v)
 130  VALUE rb_uint2inum _((unsigned long));
 131  #define UINT2NUM(v) rb_uint2inum(v)
 132  #define ULONG2NUM(v) UINT2NUM(v)
 133  #define rb_uint_new(v) rb_uint2inum(v)
 134  
 135  #if HAVE_LONG_LONG
 136  VALUE rb_ll2inum _((LONG_LONG));
 137  #define LL2NUM(v) rb_ll2inum(v)
 138  VALUE rb_ull2inum _((unsigned LONG_LONG));
 139  #define ULL2NUM(v) rb_ull2inum(v)
 140  #endif
 141  
 142  #if SIZEOF_OFF_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
 143  # define OFFT2NUM(v) LL2NUM(v)
 144  #else
 145  # define OFFT2NUM(v) INT2NUM(v)
 146  #endif
 147  
 148  #define FIX2LONG(x) RSHIFT((long)x,1)
 149  #define FIX2ULONG(x) (((unsigned long)(x))>>1)
 150  #define FIXNUM_P(f) (((long)(f))&FIXNUM_FLAG)
 151  #define POSFIXABLE(f) ((f) <= FIXNUM_MAX)
 152  #define NEGFIXABLE(f) ((f) >= FIXNUM_MIN)
 153  #define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
 154  
 155  #define IMMEDIATE_MASK 0x03
 156  #define IMMEDIATE_P(x) ((VALUE)(x) & IMMEDIATE_MASK)
 157  
 158  #define SYMBOL_FLAG 0x0e
 159  #define SYMBOL_P(x) (((VALUE)(x)&0xff)==SYMBOL_FLAG)
 160  #define ID2SYM(x) ((VALUE)(((long)(x))<<8|SYMBOL_FLAG))
 161  #define SYM2ID(x) RSHIFT((long)x,8)
 162  
 163  /* special contants - i.e. non-zero and non-fixnum constants */
 164  #define Qfalse 0
 165  #define Qtrue  2
 166  #define Qnil   4
 167  #define Qundef 6                /* undefined value for placeholder */
 168  
 169  #define RTEST(v) (((VALUE)(v) & ~Qnil) != 0)
 170  #define NIL_P(v) ((VALUE)(v) == Qnil)
 171  
 172  #define CLASS_OF(v) rb_class_of((VALUE)(v))
 173  
 174  #define T_NONE   0x00
 175  
 176  #define T_NIL    0x01
 177  #define T_OBJECT 0x02
 178  #define T_CLASS  0x03
 179  #define T_ICLASS 0x04
 180  #define T_MODULE 0x05
 181  #define T_FLOAT  0x06
 182  #define T_STRING 0x07
 183  #define T_REGEXP 0x08
 184  #define T_ARRAY  0x09
 185  #define T_FIXNUM 0x0a
 186  #define T_HASH   0x0b
 187  #define T_STRUCT 0x0c
 188  #define T_BIGNUM 0x0d
 189  #define T_FILE   0x0e
 190  
 191  #define T_TRUE   0x20
 192  #define T_FALSE  0x21
 193  #define T_DATA   0x22
 194  #define T_MATCH  0x23
 195  #define T_SYMBOL 0x24
 196  
 197  #define T_BLKTAG 0x3b
 198  #define T_UNDEF  0x3c
 199  #define T_VARMAP 0x3d
 200  #define T_SCOPE  0x3e
 201  #define T_NODE   0x3f
 202  
 203  #define T_MASK   0x3f
 204  
 205  #define BUILTIN_TYPE(x) (((struct RBasic*)(x))->flags & T_MASK)
 206  
 207  #define TYPE(x) rb_type((VALUE)(x))
 208  
 209  void rb_check_type _((VALUE,int));
 210  #define Check_Type(v,t) rb_check_type((VALUE)(v),t)
 211  
 212  VALUE rb_str_to_str _((VALUE));
 213  VALUE rb_string_value _((volatile VALUE*));
 214  char *rb_string_value_ptr _((volatile VALUE*));
 215  
 216  #define StringValue(v) if (TYPE(v) != T_STRING) rb_string_value(&(v))
 217  void rb_check_safe_str _((VALUE));
 218  #define SafeStringValue(v) do {\
 219      StringValue(v);\
 220      rb_check_safe_str(v);\
 221  } while (0)
 222  #define StringValuePtr(v) rb_string_value_ptr(&(v))
 223  /* obsolete macro - use SafeStringValue(v) */
 224  #define Check_SafeStr(v) rb_check_safe_str((VALUE)(v))
 225  
 226  void rb_secure _((int));
 227  EXTERN int ruby_safe_level;
 228  #define rb_safe_level() (ruby_safe_level)
 229  void rb_set_safe_level _((int));
 230  
 231  long rb_num2long _((VALUE));
 232  unsigned long rb_num2ulong _((VALUE));
 233  #define NUM2LONG(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2long((VALUE)x))
 234  #define NUM2ULONG(x) rb_num2ulong((VALUE)x)
 235  #if SIZEOF_INT < SIZEOF_LONG
 236  int rb_num2int _((VALUE));
 237  #define NUM2INT(x) (FIXNUM_P(x)?FIX2INT(x):rb_num2int((VALUE)x))
 238  int rb_fix2int _((VALUE));
 239  #define FIX2INT(x) rb_fix2int((VALUE)x)
 240  #define NUM2UINT(x) ((unsigned int)NUM2INT(x))
 241  #define FIX2UINT(x) ((unsigned int)FIX2INT(x))
 242  #else
 243  #define NUM2INT(x) NUM2LONG(x)
 244  #define NUM2UINT(x) NUM2ULONG(x)
 245  #define FIX2INT(x) FIX2LONG(x)
 246  #define FIX2UINT(x) FIX2ULONG(x)
 247  #endif
 248  
 249  #if HAVE_LONG_LONG
 250  LONG_LONG rb_num2ll _((VALUE));
 251  unsigned LONG_LONG rb_num2ull _((VALUE));
 252  # define NUM2LL(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2ll((VALUE)x))
 253  #endif
 254  
 255  #if HAVE_LONG_LONG && SIZEOF_OFF_T > SIZEOF_LONG
 256  # define NUM2OFFT(x) ((off_t)NUM2LL(x))
 257  #else
 258  # define NUM2OFFT(x) NUM2LONG(x)
 259  #endif
 260  
 261  double rb_num2dbl _((VALUE));
 262  #define NUM2DBL(x) rb_num2dbl((VALUE)(x))
 263  
 264  /* obsolete API - use StringValue() */
 265  char *rb_str2cstr _((VALUE,long*));
 266  /* obsolete API - use StringValuePtr() */
 267  #define STR2CSTR(x) rb_str2cstr((VALUE)(x),0)
 268  
 269  #define NUM2CHR(x) (((TYPE(x) == T_STRING)&&(RSTRING(x)->len>=1))?\
 270                       RSTRING(x)->ptr[0]:(char)(NUM2INT(x)&0xff))
 271  #define CHR2FIX(x) INT2FIX((long)((x)&0xff))
 272  
 273  VALUE rb_newobj _((void));
 274  #define NEWOBJ(obj,type) type *obj = (type*)rb_newobj()
 275  #define OBJSETUP(obj,c,t) do {\
 276      RBASIC(obj)->flags = (t);\
 277      RBASIC(obj)->klass = (c);\
 278      if (rb_safe_level() >= 3) FL_SET(obj, FL_TAINT);\
 279  } while (0)
 280  #define CLONESETUP(clone,obj) do {\
 281      OBJSETUP(clone,rb_singleton_class_clone((VALUE)obj),RBASIC(obj)->flags);\
 282      rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);\
 283      if (FL_TEST(obj, FL_EXIVAR)) rb_copy_generic_ivar((VALUE)clone,(VALUE)obj);\
 284  } while (0)
 285  #define DUPSETUP(dup,obj) do {\
 286      OBJSETUP(dup,rb_obj_class(obj),(RBASIC(obj)->flags)&(T_MASK|FL_EXIVAR|FL_TAINT));\
 287      if (FL_TEST(obj, FL_EXIVAR)) rb_copy_generic_ivar((VALUE)dup,(VALUE)obj);\
 288  } while (0)
 289  
 290  struct RBasic {
 291      unsigned long flags;
 292      VALUE klass;
 293  };
 294  
 295  struct RObject {
 296      struct RBasic basic;
 297      struct st_table *iv_tbl;
 298  };
 299  
 300  struct RClass {
 301      struct RBasic basic;
 302      struct st_table *iv_tbl;
 303      struct st_table *m_tbl;
 304      VALUE super;
 305  };
 306  
 307  struct RFloat {
 308      struct RBasic basic;
 309      double value;
 310  };
 311  
 312  #define ELTS_SHARED FL_USER2
 313  
 314  struct RString {
 315      struct RBasic basic;
 316      long len;
 317      char *ptr;
 318      union {
 319          long capa;
 320          VALUE shared;
 321      } aux;
 322  };
 323  
 324  struct RArray {
 325      struct RBasic basic;
 326      long len;
 327      union {
 328          long capa;
 329          VALUE shared;
 330      } aux;
 331      VALUE *ptr;
 332  };
 333  
 334  struct RRegexp {
 335      struct RBasic basic;
 336      struct re_pattern_buffer *ptr;
 337      long len;
 338      char *str;
 339  };
 340  
 341  struct RHash {
 342      struct RBasic basic;
 343      struct st_table *tbl;
 344      int iter_lev;
 345      VALUE ifnone;
 346  };
 347  
 348  struct RFile {
 349      struct RBasic basic;
 350      struct OpenFile *fptr;
 351  };
 352  
 353  struct RData {
 354      struct RBasic basic;
 355      void (*dmark) _((void*));
 356      void (*dfree) _((void*));
 357      void *data;
 358  };
 359  
 360  #define DATA_PTR(dta) (RDATA(dta)->data)
 361  
 362  /*
 363  #define RUBY_DATA_FUNC(func) ((void (*)_((void*)))func)
 364  */
 365  typedef void (*RUBY_DATA_FUNC) _((void*));
 366  
 367  VALUE rb_data_object_alloc _((VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC));
 368  
 369  #define Data_Wrap_Struct(klass,mark,free,sval)\
 370      rb_data_object_alloc(klass,sval,(RUBY_DATA_FUNC)mark,(RUBY_DATA_FUNC)free)
 371  
 372  #define Data_Make_Struct(klass,type,mark,free,sval) (\
 373      sval = ALLOC(type),\
 374      memset(sval, 0, sizeof(type)),\
 375      Data_Wrap_Struct(klass,mark,free,sval)\
 376  )
 377  
 378  #define Data_Get_Struct(obj,type,sval) do {\
 379      Check_Type(obj, T_DATA); \
 380      sval = (type*)DATA_PTR(obj);\
 381  } while (0)
 382  
 383  struct RStruct {
 384      struct RBasic basic;
 385      long len;
 386      VALUE *ptr;
 387  };
 388  
 389  struct RBignum {
 390      struct RBasic basic;
 391      char sign;
 392      long len;
 393      void *digits;
 394  };
 395  
 396  #define R_CAST(st)   (struct st*)
 397  #define RBASIC(obj)  (R_CAST(RBasic)(obj))
 398  #define ROBJECT(obj) (R_CAST(RObject)(obj))
 399  #define RCLASS(obj)  (R_CAST(RClass)(obj))
 400  #define RMODULE(obj) RCLASS(obj)
 401  #define RFLOAT(obj)  (R_CAST(RFloat)(obj))
 402  #define RSTRING(obj) (R_CAST(RString)(obj))
 403  #define RREGEXP(obj) (R_CAST(RRegexp)(obj))
 404  #define RARRAY(obj)  (R_CAST(RArray)(obj))
 405  #define RHASH(obj)   (R_CAST(RHash)(obj))
 406  #define RDATA(obj)   (R_CAST(RData)(obj))
 407  #define RSTRUCT(obj) (R_CAST(RStruct)(obj))
 408  #define RBIGNUM(obj) (R_CAST(RBignum)(obj))
 409  #define RFILE(obj)   (R_CAST(RFile)(obj))
 410  
 411  #define FL_SINGLETON FL_USER0
 412  #define FL_MARK      (1<<6)
 413  #define FL_FINALIZE  (1<<7)
 414  #define FL_TAINT     (1<<8)
 415  #define FL_EXIVAR    (1<<9)
 416  #define FL_FREEZE    (1<<10)
 417  
 418  #define FL_USHIFT    11
 419  
 420  #define FL_USER0     (1<<(FL_USHIFT+0))
 421  #define FL_USER1     (1<<(FL_USHIFT+1))
 422  #define FL_USER2     (1<<(FL_USHIFT+2))
 423  #define FL_USER3     (1<<(FL_USHIFT+3))
 424  #define FL_USER4     (1<<(FL_USHIFT+4))
 425  #define FL_USER5     (1<<(FL_USHIFT+5))
 426  #define FL_USER6     (1<<(FL_USHIFT+6))
 427  #define FL_USER7     (1<<(FL_USHIFT+7))
 428  
 429  #define FL_UMASK  (0xff<<FL_USHIFT)
 430  
 431  #define SPECIAL_CONST_P(x) (IMMEDIATE_P(x) || !RTEST(x))
 432  
 433  #define FL_ABLE(x) (!SPECIAL_CONST_P(x))
 434  #define FL_TEST(x,f) (FL_ABLE(x)?(RBASIC(x)->flags&(f)):0)
 435  #define FL_SET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags |= (f);} while (0)
 436  #define FL_UNSET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags &= ~(f);} while (0)
 437  #define FL_REVERSE(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags ^= (f);} while (0)
 438  
 439  #define OBJ_TAINTED(x) FL_TEST((x), FL_TAINT)
 440  #define OBJ_TAINT(x) FL_SET((x), FL_TAINT)
 441  #define OBJ_INFECT(x,s) do {if (FL_ABLE(x) && FL_ABLE(s)) RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT;} while (0)
 442  
 443  #define OBJ_FROZEN(x) FL_TEST((x), FL_FREEZE)
 444  #define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE)
 445  
 446  #define ALLOC_N(type,n) (type*)xmalloc(sizeof(type)*(n))
 447  #define ALLOC(type) (type*)xmalloc(sizeof(type))
 448  #define REALLOC_N(var,type,n) (var)=(type*)xrealloc((char*)(var),sizeof(type)*(n))
 449  
 450  #define ALLOCA_N(type,n) (type*)alloca(sizeof(type)*(n))
 451  
 452  #define MEMZERO(p,type,n) memset((p), 0, sizeof(type)*(n))
 453  #define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n))
 454  #define MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(n))
 455  #define MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(n))
 456  
 457  void rb_glob _((char*,void(*)(const char*,VALUE),VALUE));
 458  void rb_globi _((char*,void(*)(const char*,VALUE),VALUE));
 459  
 460  VALUE rb_define_class _((const char*,VALUE));
 461  VALUE rb_define_module _((const char*));
 462  VALUE rb_define_class_under _((VALUE, const char*, VALUE));
 463  VALUE rb_define_module_under _((VALUE, const char*));
 464  
 465  void rb_include_module _((VALUE,VALUE));
 466  void rb_extend_object _((VALUE,VALUE));
 467  
 468  void rb_define_variable _((const char*,VALUE*));
 469  void rb_define_virtual_variable _((const char*,VALUE(*)(ANYARGS),void(*)(ANYARGS)));
 470  void rb_define_hooked_variable _((const char*,VALUE*,VALUE(*)(ANYARGS),void(*)(ANYARGS)));
 471  void rb_define_readonly_variable _((const char*,VALUE*));
 472  void rb_define_const _((VALUE,const char*,VALUE));
 473  void rb_define_global_const _((const char*,VALUE));
 474  
 475  #define RUBY_METHOD_FUNC(func) ((VALUE (*)(ANYARGS))func)
 476  void rb_define_method _((VALUE,const char*,VALUE(*)(ANYARGS),int));
 477  void rb_define_module_function _((VALUE,const char*,VALUE(*)(ANYARGS),int));
 478  void rb_define_global_function _((const char*,VALUE(*)(ANYARGS),int));
 479  
 480  void rb_undef_method _((VALUE,const char*));
 481  void rb_define_alias _((VALUE,const char*,const char*));
 482  void rb_define_attr _((VALUE,const char*,int,int));
 483  
 484  void rb_global_variable _((VALUE*));
 485  void rb_gc_register_address _((VALUE*));
 486  void rb_gc_unregister_address _((VALUE*));
 487  
 488  ID rb_intern _((const char*));
 489  char *rb_id2name _((ID));
 490  ID rb_to_id _((VALUE));
 491  
 492  char *rb_class2name _((VALUE));
 493  
 494  void rb_p _((VALUE));
 495  
 496  VALUE rb_eval_string _((const char*));
 497  VALUE rb_eval_string_protect _((const char*, int*));
 498  VALUE rb_eval_string_wrap _((const char*, int*));
 499  VALUE rb_funcall __((VALUE, ID, int, ...));
 500  VALUE rb_funcall2 _((VALUE, ID, int, const VALUE*));
 501  VALUE rb_funcall3 _((VALUE, ID, int, const VALUE*));
 502  int rb_scan_args __((int, const VALUE*, const char*, ...));
 503  VALUE rb_call_super _((int, const VALUE*));
 504  
 505  VALUE rb_gv_set _((const char*, VALUE));
 506  VALUE rb_gv_get _((const char*));
 507  VALUE rb_iv_get _((VALUE, const char*));
 508  VALUE rb_iv_set _((VALUE, const char*, VALUE));
 509  
 510  VALUE rb_equal _((VALUE,VALUE));
 511  
 512  EXTERN VALUE ruby_verbose, ruby_debug;
 513  
 514  NORETURN(void rb_raise __((VALUE, const char*, ...)));
 515  NORETURN(void rb_fatal __((const char*, ...)));
 516  NORETURN(void rb_bug __((const char*, ...)));
 517  NORETURN(void rb_sys_fail _((const char*)));
 518  NORETURN(void rb_iter_break _((void)));
 519  NORETURN(void rb_exit _((int)));
 520  NORETURN(void rb_notimplement _((void)));
 521  
 522  void rb_warning __((const char*, ...));         /* reports if `-w' specified */
 523  void rb_sys_warning __((const char*, ...));     /* reports if `-w' specified */
 524  void rb_warn __((const char*, ...));            /* reports always */
 525  
 526  VALUE rb_each _((VALUE));
 527  VALUE rb_yield _((VALUE));
 528  int rb_block_given_p _((void));
 529  VALUE rb_iterate _((VALUE(*)(VALUE),VALUE,VALUE(*)(ANYARGS),VALUE));
 530  VALUE rb_rescue _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE));
 531  VALUE rb_rescue2 __((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...));
 532  VALUE rb_ensure _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE));
 533  VALUE rb_catch _((const char*,VALUE(*)(ANYARGS),VALUE));
 534  NORETURN(void rb_throw _((const char*,VALUE)));
 535  
 536  VALUE rb_require _((const char*));
 537  
 538  void ruby_init _((void));
 539  void ruby_options _((int, char**));
 540  void ruby_run _((void));
 541  
 542  EXTERN VALUE rb_mKernel;
 543  EXTERN VALUE rb_mComparable;
 544  EXTERN VALUE rb_mEnumerable;
 545  EXTERN VALUE rb_mPrecision;
 546  EXTERN VALUE rb_mErrno;
 547  EXTERN VALUE rb_mFileTest;
 548  EXTERN VALUE rb_mGC;
 549  EXTERN VALUE rb_mMath;
 550  EXTERN VALUE rb_mProcess;
 551  
 552  EXTERN VALUE rb_cObject;
 553  EXTERN VALUE rb_cArray;
 554  EXTERN VALUE rb_cBignum;
 555  EXTERN VALUE rb_cClass;
 556  EXTERN VALUE rb_cDir;
 557  EXTERN VALUE rb_cData;
 558  EXTERN VALUE rb_cFalseClass;
 559  EXTERN VALUE rb_cFile;
 560  EXTERN VALUE rb_cFixnum;
 561  EXTERN VALUE rb_cFloat;
 562  EXTERN VALUE rb_cHash;
 563  EXTERN VALUE rb_cInteger;
 564  EXTERN VALUE rb_cIO;
 565  EXTERN VALUE rb_cModule;
 566  EXTERN VALUE rb_cNilClass;
 567  EXTERN VALUE rb_cNumeric;
 568  EXTERN VALUE rb_cProc;
 569  EXTERN VALUE rb_cRange;
 570  EXTERN VALUE rb_cRegexp;
 571  EXTERN VALUE rb_cString;
 572  EXTERN VALUE rb_cSymbol;
 573  EXTERN VALUE rb_cThread;
 574  EXTERN VALUE rb_cTime;
 575  EXTERN VALUE rb_cTrueClass;
 576  EXTERN VALUE rb_cStruct;
 577  
 578  EXTERN VALUE rb_eException;
 579  EXTERN VALUE rb_eStandardError;
 580  EXTERN VALUE rb_eSystemExit;
 581  EXTERN VALUE rb_eInterrupt;
 582  EXTERN VALUE rb_eSignal;
 583  EXTERN VALUE rb_eFatal;
 584  EXTERN VALUE rb_eArgError;
 585  EXTERN VALUE rb_eEOFError;
 586  EXTERN VALUE rb_eIndexError;
 587  EXTERN VALUE rb_eRangeError;
 588  EXTERN VALUE rb_eIOError;
 589  EXTERN VALUE rb_eRuntimeError;
 590  EXTERN VALUE rb_eSecurityError;
 591  EXTERN VALUE rb_eSystemCallError;
 592  EXTERN VALUE rb_eTypeError;
 593  EXTERN VALUE rb_eZeroDivError;
 594  EXTERN VALUE rb_eNotImpError;
 595  EXTERN VALUE rb_eNoMemError;
 596  EXTERN VALUE rb_eNoMethodError;
 597  EXTERN VALUE rb_eFloatDomainError;
 598  
 599  EXTERN VALUE rb_eScriptError;
 600  EXTERN VALUE rb_eNameError;
 601  EXTERN VALUE rb_eSyntaxError;
 602  EXTERN VALUE rb_eLoadError;
 603  
 604  EXTERN VALUE rb_defout, rb_stdin, rb_stdout, rb_stderr, ruby_errinfo;
 605  
 606  static inline VALUE
 607  #if defined(HAVE_PROTOTYPES)
 608  rb_class_of(VALUE obj)
 609  #else
 610  rb_class_of(obj)
 611      VALUE obj;
 612  #endif
 613  {
 614      if (FIXNUM_P(obj)) return rb_cFixnum;
 615      if (obj == Qnil) return rb_cNilClass;
 616      if (obj == Qfalse) return rb_cFalseClass;
 617      if (obj == Qtrue) return rb_cTrueClass;
 618      if (SYMBOL_P(obj)) return rb_cSymbol;
 619  
 620      return RBASIC(obj)->klass;
 621  }
 622  
 623  static inline int
 624  #if defined(HAVE_PROTOTYPES)
 625  rb_type(VALUE obj)
 626  #else
 627  rb_type(obj)
 628     VALUE obj;
 629  #endif
 630  {
 631      if (FIXNUM_P(obj)) return T_FIXNUM;
 632      if (obj == Qnil) return T_NIL;
 633      if (obj == Qfalse) return T_FALSE;
 634      if (obj == Qtrue) return T_TRUE;
 635      if (obj == Qundef) return T_UNDEF;
 636      if (SYMBOL_P(obj)) return T_SYMBOL;
 637      return BUILTIN_TYPE(obj);
 638  }
 639  
 640  static inline int
 641  #if defined(HAVE_PROTOTYPES)
 642  rb_special_const_p(VALUE obj)
 643  #else
 644  rb_special_const_p(obj)
 645      VALUE obj;
 646  #endif
 647  {
 648      if (SPECIAL_CONST_P(obj)) return Qtrue;
 649      return Qfalse;
 650  }
 651  
 652  #include "intern.h"
 653  #include "missing.h"
 654  
 655  #if defined(EXTLIB) && defined(USE_DLN_A_OUT)
 656  /* hook for external modules */
 657  static char *dln_libs_to_be_linked[] = { EXTLIB, 0 };
 658  #endif
 659  
 660  #if defined(__cplusplus)
 661  }  /* extern "C" { */
 662  #endif
 663  
 664  #endif /* ifndef RUBY_H */