summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/mrbconf.h13
-rw-r--r--include/mruby.h14
-rw-r--r--include/mruby/array.h7
-rw-r--r--include/mruby/compile.h14
-rw-r--r--include/mruby/string.h9
5 files changed, 33 insertions, 24 deletions
diff --git a/include/mrbconf.h b/include/mrbconf.h
index 52490ceba..b485642dc 100644
--- a/include/mrbconf.h
+++ b/include/mrbconf.h
@@ -46,6 +46,10 @@
/* page size of memory pool */
//#define POOL_PAGE_SIZE 16000
+/* initial minimum size for string buffer */
+//#define MRB_STR_BUF_MIN_SIZE 128
+
+
/* -DDISABLE_XXXX to drop following features */
//#define DISABLE_STDIO /* use of stdio */
@@ -64,7 +68,7 @@
# define str_to_mrb_float(buf) strtod(buf, NULL)
#endif
-#ifdef MRB_INT64
+#if defined(MRB_INT64)
# ifdef MRB_NAN_BOXING
# error Cannot use NaN boxing when mrb_int is 64bit
# else
@@ -73,6 +77,11 @@
# define MRB_INT_MAX INT64_MAX
# define str_to_mrb_int(buf) strtoll(buf, NULL, 10)
# endif
+#elif defined(MRB_INT16)
+ typedef int16_t mrb_int;
+# define MRB_INT_MIN INT16_MIN
+# define MRB_INT_MAX INT16_MAX
+# define str_to_mrb_int(buf) strtol(buf, NULL, 10)
#else
typedef int32_t mrb_int;
# define MRB_INT_MIN INT32_MIN
@@ -106,8 +115,10 @@ typedef short mrb_sym;
# define strtoll _strtoi64
# define PRId32 "I32d"
# define PRId64 "I64d"
+typedef unsigned int mrb_bool;
#else
# include <inttypes.h>
+typedef _Bool mrb_bool;
#endif
#ifdef ENABLE_STDIO
diff --git a/include/mruby.h b/include/mruby.h
index ed746f409..1054fd639 100644
--- a/include/mruby.h
+++ b/include/mruby.h
@@ -121,9 +121,9 @@ typedef struct mrb_state {
size_t gc_threshold;
int gc_interval_ratio;
int gc_step_ratio;
- unsigned int gc_disabled:1;
- unsigned int gc_full:1;
- unsigned int is_generational_gc_mode:1;
+ mrb_bool gc_disabled:1;
+ mrb_bool gc_full:1;
+ mrb_bool is_generational_gc_mode:1;
size_t majorgc_old_threshold;
struct alloca_header *mems;
@@ -156,6 +156,7 @@ void mrb_undef_class_method(mrb_state*, struct RClass*, const char*);
mrb_value mrb_instance_new(mrb_state *mrb, mrb_value cv);
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_obj_get(mrb_state *mrb, const char *name);
@@ -189,10 +190,10 @@ mrb_value mrb_funcall(mrb_state*, mrb_value, const char*, int,...);
mrb_value mrb_funcall_argv(mrb_state*, mrb_value, mrb_sym, int, mrb_value*);
mrb_value mrb_funcall_with_block(mrb_state*, mrb_value, mrb_sym, int, mrb_value*, mrb_value);
mrb_sym mrb_intern(mrb_state*,const char*);
-mrb_sym mrb_intern2(mrb_state*,const char*,int);
+mrb_sym mrb_intern2(mrb_state*,const char*,size_t);
mrb_sym mrb_intern_str(mrb_state*,mrb_value);
const char *mrb_sym2name(mrb_state*,mrb_sym);
-const char *mrb_sym2name_len(mrb_state*,mrb_sym,int*);
+const char *mrb_sym2name_len(mrb_state*,mrb_sym,size_t*);
mrb_value mrb_str_format(mrb_state *, int, const mrb_value *, mrb_value);
void *mrb_malloc(mrb_state*, size_t);
@@ -201,9 +202,8 @@ void *mrb_realloc(mrb_state*, void*, size_t);
struct RBasic *mrb_obj_alloc(mrb_state*, enum mrb_vtype, struct RClass*);
void *mrb_free(mrb_state*, void*);
-mrb_value mrb_str_new(mrb_state *mrb, const char *p, int len); /* mrb_str_new */
+mrb_value mrb_str_new(mrb_state *mrb, const char *p, size_t len);
mrb_value mrb_str_new_cstr(mrb_state*, const char*);
-mrb_value mrb_str_new2(mrb_state *mrb, const char *p);
mrb_state* mrb_open(void);
mrb_state* mrb_open_allocf(mrb_allocf, void *ud);
diff --git a/include/mruby/array.h b/include/mruby/array.h
index 5d78ccddd..7fba4a99c 100644
--- a/include/mruby/array.h
+++ b/include/mruby/array.h
@@ -38,12 +38,14 @@ struct RArray {
void mrb_ary_decref(mrb_state*, mrb_shared_array*);
mrb_value mrb_ary_new_capa(mrb_state*, mrb_int);
mrb_value mrb_ary_new(mrb_state *mrb);
-mrb_value mrb_ary_new_elts(mrb_state *mrb, mrb_int n, const mrb_value *elts);
+mrb_value mrb_ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals);
+/* compatibility macros - soon to be removed */
+#define mrb_ary_new_elts(mrb,size,vals) mrb_ary_new_from_values(mrb,size,vals)
+#define mrb_ary_new4(mrb,size,vals) mrb_ary_new_from_values(mrb,size,vals)
void mrb_ary_concat(mrb_state*, mrb_value, mrb_value);
mrb_value mrb_ary_splat(mrb_state*, mrb_value);
void mrb_ary_push(mrb_state*, mrb_value, mrb_value);
mrb_value mrb_ary_pop(mrb_state *mrb, mrb_value ary);
-mrb_value mrb_ary_new_from_values(mrb_state *mrb, mrb_int size, mrb_value *vals);
mrb_value mrb_ary_aget(mrb_state *mrb, mrb_value self);
mrb_value mrb_ary_ref(mrb_state *mrb, mrb_value ary, mrb_int n);
void mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val);
@@ -51,7 +53,6 @@ mrb_int mrb_ary_len(mrb_state *mrb, mrb_value ary);
void mrb_ary_replace(mrb_state *mrb, mrb_value a, mrb_value b);
mrb_value mrb_check_array_type(mrb_state *mrb, mrb_value self);
mrb_value mrb_ary_unshift(mrb_state *mrb, mrb_value self, mrb_value item);
-mrb_value mrb_ary_new4(mrb_state *mrb, mrb_int n, const mrb_value *elts);
mrb_value mrb_assoc_new(mrb_state *mrb, mrb_value car, mrb_value cdr);
mrb_value mrb_ary_entry(mrb_value ary, mrb_int offset);
mrb_value mrb_ary_shift(mrb_state *mrb, mrb_value self);
diff --git a/include/mruby/compile.h b/include/mruby/compile.h
index 2cbc28321..a50c85e42 100644
--- a/include/mruby/compile.h
+++ b/include/mruby/compile.h
@@ -21,9 +21,9 @@ typedef struct mrbc_context {
int slen;
char *filename;
short lineno;
- int capture_errors:1;
- int dump_result:1;
- int no_exec:1;
+ mrb_bool capture_errors:1;
+ mrb_bool dump_result:1;
+ mrb_bool no_exec:1;
} mrbc_context;
mrbc_context* mrbc_context_new(mrb_state *mrb);
@@ -67,8 +67,8 @@ enum heredoc_type {
/* heredoc structure */
struct mrb_parser_heredoc_info {
enum heredoc_type type;
- int allow_indent:1;
- int line_head:1;
+ mrb_bool allow_indent:1;
+ mrb_bool line_head:1;
const char *term;
int term_len;
mrb_ast_node *doc;
@@ -102,8 +102,8 @@ struct mrb_parser_state {
mrb_ast_node *heredocs; /* list of mrb_parser_heredoc_info* */
mrb_ast_node *parsing_heredoc;
- int heredoc_starts_nextline:1;
- int heredoc_end_now:1; /* for mirb */
+ mrb_bool heredoc_starts_nextline:1;
+ mrb_bool heredoc_end_now:1; /* for mirb */
void *ylval;
diff --git a/include/mruby/string.h b/include/mruby/string.h
index 4ba4ce544..613c6c6a7 100644
--- a/include/mruby/string.h
+++ b/include/mruby/string.h
@@ -13,8 +13,6 @@ extern "C" {
#define IS_EVSTR(p,e) ((p) < (e) && (*(p) == '$' || *(p) == '@' || *(p) == '{'))
-#define STR_BUF_MIN_SIZE 128
-
extern const char mrb_digitmap[];
typedef struct mrb_shared_string {
@@ -48,14 +46,13 @@ mrb_value mrb_str_plus(mrb_state*, mrb_value, mrb_value);
mrb_value mrb_obj_as_string(mrb_state *mrb, mrb_value obj);
mrb_value mrb_str_resize(mrb_state *mrb, mrb_value str, int len); /* mrb_str_resize */
mrb_value mrb_string_value(mrb_state *mrb, mrb_value *ptr); /* StringValue */
-mrb_value mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, int len);
+mrb_value mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len);
mrb_value mrb_check_string_type(mrb_state *mrb, mrb_value str);
mrb_value mrb_str_buf_new(mrb_state *mrb, int capa);
-mrb_value mrb_str_buf_cat(mrb_state *mrb, mrb_value str, const char *ptr, int len);
+mrb_value mrb_str_buf_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len);
char *mrb_string_value_cstr(mrb_state *mrb, mrb_value *ptr);
char *mrb_string_value_ptr(mrb_state *mrb, mrb_value ptr);
-int mrb_str_sublen(mrb_state *mrb, mrb_value str, int pos);
int mrb_str_offset(mrb_state *mrb, mrb_value str, int pos);
mrb_value mrb_str_dup(mrb_state *mrb, mrb_value str); /* mrb_str_dup */
mrb_value mrb_str_intern(mrb_state *mrb, mrb_value self);
@@ -68,7 +65,7 @@ mrb_value mrb_str_buf_append(mrb_state *mrb, mrb_value str, mrb_value str2);
mrb_value mrb_str_inspect(mrb_state *mrb, mrb_value str);
int mrb_str_equal(mrb_state *mrb, mrb_value str1, mrb_value str2);
mrb_value mrb_str_dump(mrb_state *mrb, mrb_value str);
-mrb_value mrb_str_cat(mrb_state *mrb, mrb_value str, const char *ptr, long len);
+mrb_value mrb_str_cat(mrb_state *mrb, mrb_value str, const char *ptr, mrb_int len);
mrb_value mrb_str_append(mrb_state *mrb, mrb_value str, mrb_value str2);
int mrb_str_cmp(mrb_state *mrb, mrb_value str1, mrb_value str2);