summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/mruby.h7
-rw-r--r--include/mruby/data.h19
-rw-r--r--include/mruby/dump.h5
-rw-r--r--include/mruby/numeric.h6
-rw-r--r--include/mruby/value.h2
-rw-r--r--include/mruby/variable.h1
6 files changed, 26 insertions, 14 deletions
diff --git a/include/mruby.h b/include/mruby.h
index e204820a3..1336d34d8 100644
--- a/include/mruby.h
+++ b/include/mruby.h
@@ -125,6 +125,7 @@ typedef struct mrb_state {
mrb_bool gc_disabled:1;
mrb_bool gc_full:1;
mrb_bool is_generational_gc_mode:1;
+ mrb_bool out_of_memory:1;
size_t majorgc_old_threshold;
struct alloca_header *mems;
@@ -281,9 +282,15 @@ void mrb_exc_raise(mrb_state *mrb, mrb_value exc);
void mrb_raise(mrb_state *mrb, struct RClass *c, const char *msg);
void mrb_raisef(mrb_state *mrb, struct RClass *c, const char *fmt, ...);
+void mrb_name_error(mrb_state *mrb, mrb_sym id, const char *fmt, ...);
void mrb_warn(const char *fmt, ...);
void mrb_bug(const char *fmt, ...);
+/* macros to get typical exception objects
+ note:
+ + those E_* macros requires mrb_state* variable named mrb.
+ + exception objects obtained from those macros are local to mrb
+*/
#define E_RUNTIME_ERROR (mrb_class_obj_get(mrb, "RuntimeError"))
#define E_TYPE_ERROR (mrb_class_obj_get(mrb, "TypeError"))
#define E_ARGUMENT_ERROR (mrb_class_obj_get(mrb, "ArgumentError"))
diff --git a/include/mruby/data.h b/include/mruby/data.h
index 6ddaebfaa..c6b380f28 100644
--- a/include/mruby/data.h
+++ b/include/mruby/data.h
@@ -28,19 +28,22 @@ struct RData *mrb_data_object_alloc(mrb_state *mrb, struct RClass* klass, void *
#define Data_Wrap_Struct(mrb,klass,type,ptr)\
mrb_data_object_alloc(mrb,klass,ptr,type)
-#define Data_Make_Struct(mrb,klass,strct,type,sval,data) (\
- sval = mrb_malloc(mrb, sizeof(strct)),\
- { static const strct zero = { 0 }; *sval = zero; },\
- data = Data_Wrap_Struct(mrb,klass,type,sval)\
-)
+#define Data_Make_Struct(mrb,klass,strct,type,sval,data) do { \
+ sval = mrb_malloc(mrb, sizeof(strct)); \
+ { static const strct zero = { 0 }; *sval = zero; };\
+ data = Data_Wrap_Struct(mrb,klass,type,sval);\
+} while (0)
#define RDATA(obj) ((struct RData *)((obj).value.p))
#define DATA_PTR(d) (RDATA(d)->data)
#define DATA_TYPE(d) (RDATA(d)->type)
-void *mrb_get_datatype(mrb_state *mrb, mrb_value, const mrb_data_type*);
-void *mrb_check_datatype(mrb_state *mrb, mrb_value, const mrb_data_type*);
+void mrb_data_check_type(mrb_state *mrb, mrb_value, const mrb_data_type*);
+void *mrb_data_get_ptr(mrb_state *mrb, mrb_value, const mrb_data_type*);
+void *mrb_data_check_and_get(mrb_state *mrb, mrb_value, const mrb_data_type*);
+#define mrb_get_datatype(mrb,val,type) mrb_data_get_ptr(mrb, val, type)
+#define mrb_check_datatype(mrb,val,type) mrb_data_check_and_get(mrb, val, type)
#define Data_Get_Struct(mrb,obj,type,sval) do {\
- *(void**)&sval = mrb_check_datatype(mrb, obj, type); \
+ *(void**)&sval = mrb_data_check_and_get(mrb, obj, type); \
} while (0)
#if defined(__cplusplus)
diff --git a/include/mruby/dump.h b/include/mruby/dump.h
index 2533a4c93..d1d097cd2 100644
--- a/include/mruby/dump.h
+++ b/include/mruby/dump.h
@@ -141,9 +141,8 @@ bin_to_uint8(const uint8_t *bin)
}
/* crc.c */
-uint32_t
-calc_crc_16_ccitt(const uint8_t *src, uint32_t nbytes, uint16_t crcwk);
-
+uint16_t
+calc_crc_16_ccitt(const uint8_t *src, size_t nbytes, uint16_t crc);
#if defined(__cplusplus)
} /* extern "C" { */
#endif
diff --git a/include/mruby/numeric.h b/include/mruby/numeric.h
index 4bcb43966..aac7b9920 100644
--- a/include/mruby/numeric.h
+++ b/include/mruby/numeric.h
@@ -15,8 +15,10 @@ extern "C" {
#define NEGFIXABLE(f) ((f) >= MRB_INT_MIN)
#define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
-mrb_value mrb_flt2big(mrb_state *mrb, mrb_float d);
-mrb_value mrb_fix2str(mrb_state *mrb, mrb_value x, int base);
+mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val);
+mrb_value mrb_flo_to_str(mrb_state *mrb, mrb_value flo, int max_digit);
+
+mrb_value mrb_fixnum_to_str(mrb_state *mrb, mrb_value x, int base);
mrb_value mrb_fixnum_plus(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_fixnum_minus(mrb_state *mrb, mrb_value x, mrb_value y);
diff --git a/include/mruby/value.h b/include/mruby/value.h
index 1815f0562..1cc5263ad 100644
--- a/include/mruby/value.h
+++ b/include/mruby/value.h
@@ -42,7 +42,7 @@ typedef struct mrb_value {
mrb_int i;
mrb_sym sym;
} value;
- enum mrb_vtype tt:8;
+ enum mrb_vtype tt;
} mrb_value;
#define mrb_type(o) (o).tt
diff --git a/include/mruby/variable.h b/include/mruby/variable.h
index f699f5dfd..2845e0daa 100644
--- a/include/mruby/variable.h
+++ b/include/mruby/variable.h
@@ -49,6 +49,7 @@ mrb_bool mrb_iv_defined(mrb_state*, mrb_value, mrb_sym);
mrb_value mrb_iv_remove(mrb_state *mrb, mrb_value obj, mrb_sym sym);
void mrb_iv_copy(mrb_state *mrb, mrb_value dst, mrb_value src);
int mrb_const_defined_at(mrb_state *mrb, struct RClass *klass, mrb_sym id);
+mrb_value mrb_mod_constants(mrb_state *mrb, mrb_value mod);
mrb_value mrb_f_global_variables(mrb_state *mrb, mrb_value self);
mrb_value mrb_gv_get(mrb_state *mrb, mrb_sym sym);
void mrb_gv_set(mrb_state *mrb, mrb_sym sym, mrb_value val);