diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/mruby.h | 29 | ||||
| -rw-r--r-- | include/mruby/value.h | 38 |
2 files changed, 38 insertions, 29 deletions
diff --git a/include/mruby.h b/include/mruby.h index 33a15de0e..dd555eb8b 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -73,15 +73,15 @@ enum mrb_fiber_state { struct mrb_context { struct mrb_context *prev; - mrb_value *stack; + mrb_value *stack; /* stack of virtual machine */ mrb_value *stbase, *stend; mrb_callinfo *ci; mrb_callinfo *cibase, *ciend; - mrb_code **rescue; + mrb_code **rescue; /* exception handler stack */ int rsize; - struct RProc **ensure; + struct RProc **ensure; /* ensure handler stack */ int esize; uint8_t status; @@ -97,19 +97,19 @@ enum gc_state { typedef struct mrb_state { void *jmp; - mrb_allocf allocf; + mrb_allocf allocf; /* memory allocation function */ struct mrb_context *c; struct mrb_context *root_c; - struct RObject *exc; - struct iv_tbl *globals; - struct mrb_irep **irep; + struct RObject *exc; /* exception */ + struct iv_tbl *globals; /* global variable table */ + struct mrb_irep **irep; /* program data array */ size_t irep_len, irep_capa; mrb_sym init_sym; struct RObject *top_self; - struct RClass *object_class; + struct RClass *object_class; /* Object class */ struct RClass *class_class; struct RClass *module_class; struct RClass *proc_class; @@ -125,11 +125,11 @@ typedef struct mrb_state { struct RClass *symbol_class; struct RClass *kernel_module; - struct heap_page *heaps; + struct heap_page *heaps; /* heaps for GC */ struct heap_page *sweeps; struct heap_page *free_heaps; size_t live; /* count of live objects */ - struct RBasic *arena[MRB_ARENA_SIZE]; + struct RBasic *arena[MRB_ARENA_SIZE]; /* GC protection array */ int arena_idx; enum gc_state gc_state; /* state of gc */ @@ -178,6 +178,7 @@ struct RClass * mrb_class_new(mrb_state *mrb, struct RClass *super); struct RClass * mrb_module_new(mrb_state *mrb); int mrb_class_defined(mrb_state *mrb, const char *name); struct RClass * mrb_class_get(mrb_state *mrb, const char *name); +struct RClass * mrb_class_get_under(mrb_state *mrb, struct RClass *outer, const char *name); mrb_value mrb_obj_dup(mrb_state *mrb, mrb_value obj); mrb_value mrb_check_to_integer(mrb_state *mrb, mrb_value val, const char *method); @@ -239,9 +240,11 @@ mrb_sym mrb_intern(mrb_state *mrb,const char *cstr) return mrb_intern_cstr(mrb, cstr); } -void *mrb_malloc(mrb_state*, size_t); -void *mrb_calloc(mrb_state*, size_t, size_t); -void *mrb_realloc(mrb_state*, void*, size_t); +void *mrb_malloc(mrb_state*, size_t); /* raise RuntimeError if no mem */ +void *mrb_calloc(mrb_state*, size_t, size_t); /* ditto */ +void *mrb_realloc(mrb_state*, void*, size_t); /* ditto */ +void *mrb_realloc_simple(mrb_state*, void*, size_t); /* return NULL if no memory available */ +void *mrb_malloc_simple(mrb_state*, size_t); /* return NULL if no memory available */ struct RBasic *mrb_obj_alloc(mrb_state*, enum mrb_vtype, struct RClass*); void mrb_free(mrb_state*, void*); diff --git a/include/mruby/value.h b/include/mruby/value.h index 06241ec76..e78035b5f 100644 --- a/include/mruby/value.h +++ b/include/mruby/value.h @@ -51,23 +51,29 @@ typedef short mrb_sym; #ifdef _MSC_VER -# define _ALLOW_KEYWORD_MACROS -# include <float.h> -# define inline __inline +# ifndef __cplusplus +# define inline __inline +# endif # define snprintf _snprintf -# define isnan _isnan -# define isinf(n) (!_finite(n) && !_isnan(n)) -# define strtoll _strtoi64 -# define PRId32 "I32d" -# define PRIi32 "I32i" -# define PRIo32 "I32o" -# define PRIx32 "I32x" -# define PRIX32 "I32X" -# define PRId64 "I64d" -# define PRIi64 "I64i" -# define PRIo64 "I64o" -# define PRIx64 "I64x" -# define PRIX64 "I64X" +# if _MSC_VER < 1800 +# include <float.h> +# define isnan _isnan +# define isinf(n) (!_finite(n) && !_isnan(n)) +# define strtoll _strtoi64 +# define strtof (float)strtod +# define PRId32 "I32d" +# define PRIi32 "I32i" +# define PRIo32 "I32o" +# define PRIx32 "I32x" +# define PRIX32 "I32X" +# define PRId64 "I64d" +# define PRIi64 "I64i" +# define PRIo64 "I64o" +# define PRIx64 "I64x" +# define PRIX64 "I64X" +# else +# include <inttypes.h> +# endif #else # include <inttypes.h> #endif |
