Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix the type of argument named 'aspec'.

'aspec' should be large at least 24 bit.
  • Loading branch information...
commit 52eba9fee795fbd6a3a1afb4efe3ae5a777df551 1 parent 17bc0a1
@crimsonwoods crimsonwoods authored
Showing with 18 additions and 17 deletions.
  1. +12 −11 include/mruby.h
  2. +1 −1  include/mruby/class.h
  3. +5 −5 src/class.c
View
23 include/mruby.h
@@ -37,6 +37,7 @@ extern "C" {
#include "mruby/value.h"
typedef int32_t mrb_code;
+typedef int32_t mrb_aspec;
struct mrb_state;
@@ -145,10 +146,10 @@ struct RClass *mrb_define_module(mrb_state *, const char*);
mrb_value mrb_singleton_class(mrb_state*, mrb_value);
void mrb_include_module(mrb_state*, struct RClass*, struct RClass*);
-void mrb_define_method(mrb_state*, struct RClass*, const char*, mrb_func_t,int);
-void mrb_define_class_method(mrb_state *, struct RClass *, const char *, mrb_func_t, int);
-void mrb_define_singleton_method(mrb_state*, struct RObject*, const char*, mrb_func_t,int);
-void mrb_define_module_function(mrb_state*, struct RClass*, const char*, mrb_func_t,int);
+void mrb_define_method(mrb_state*, struct RClass*, const char*, mrb_func_t, mrb_aspec);
+void mrb_define_class_method(mrb_state *, struct RClass *, const char *, mrb_func_t, mrb_aspec);
+void mrb_define_singleton_method(mrb_state*, struct RObject*, const char*, mrb_func_t, mrb_aspec);
+void mrb_define_module_function(mrb_state*, struct RClass*, const char*, mrb_func_t, mrb_aspec);
void mrb_define_const(mrb_state*, struct RClass*, const char *name, mrb_value);
void mrb_undef_method(mrb_state*, struct RClass*, const char*);
void mrb_undef_class_method(mrb_state*, struct RClass*, const char*);
@@ -166,22 +167,22 @@ struct RClass * mrb_define_class_under(mrb_state *mrb, struct RClass *outer, con
struct RClass * mrb_define_module_under(mrb_state *mrb, struct RClass *outer, const char *name);
/* required arguments */
-#define ARGS_REQ(n) (((n)&0x1f) << 19)
+#define ARGS_REQ(n) ((mrb_aspec)((n)&0x1f) << 19)
/* optional arguments */
-#define ARGS_OPT(n) (((n)&0x1f) << 14)
+#define ARGS_OPT(n) ((mrb_aspec)((n)&0x1f) << 14)
/* rest argument */
-#define ARGS_REST() (1 << 13)
+#define ARGS_REST() ((mrb_aspec)(1 << 13))
/* required arguments after rest */
-#define ARGS_POST(n) (((n)&0x1f) << 8)
+#define ARGS_POST(n) ((mrb_aspec)((n)&0x1f) << 8)
/* keyword arguments (n of keys, kdict) */
-#define ARGS_KEY(n1,n2) ((((n1)&0x1f) << 3) | ((n2)?(1<<2):0))
+#define ARGS_KEY(n1,n2) ((mrb_aspec)((((n1)&0x1f) << 3) | ((n2)?(1<<2):0)))
/* block argument */
-#define ARGS_BLOCK() (1 << 1)
+#define ARGS_BLOCK() ((mrb_aspec)(1 << 1))
/* accept any number of arguments */
#define ARGS_ANY() ARGS_REST()
/* accept no arguments */
-#define ARGS_NONE() 0
+#define ARGS_NONE() ((mrb_aspec)0)
int mrb_get_args(mrb_state *mrb, const char *format, ...);
View
2  include/mruby/class.h
@@ -55,7 +55,7 @@ struct RClass *mrb_vm_define_class(mrb_state*, mrb_value, mrb_value, mrb_sym);
struct RClass *mrb_vm_define_module(mrb_state*, mrb_value, mrb_sym);
void mrb_define_method_vm(mrb_state*, struct RClass*, mrb_sym, mrb_value);
void mrb_define_method_raw(mrb_state*, struct RClass*, mrb_sym, struct RProc *);
-void mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t func, int aspec);
+void mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t func, mrb_aspec aspec);
void mrb_alias_method(mrb_state *mrb, struct RClass *c, mrb_sym a, mrb_sym b);
struct RClass *mrb_class_outer_module(mrb_state*, struct RClass *);
View
10 src/class.c
@@ -297,7 +297,7 @@ mrb_define_method_raw(mrb_state *mrb, struct RClass *c, mrb_sym mid, struct RPro
}
void
-mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t func, int aspec)
+mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t func, mrb_aspec aspec)
{
struct RProc *p;
int ai = mrb_gc_arena_save(mrb);
@@ -309,7 +309,7 @@ mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t f
}
void
-mrb_define_method(mrb_state *mrb, struct RClass *c, const char *name, mrb_func_t func, int aspec)
+mrb_define_method(mrb_state *mrb, struct RClass *c, const char *name, mrb_func_t func, mrb_aspec aspec)
{
mrb_define_method_id(mrb, c, mrb_intern(mrb, name), func, aspec);
}
@@ -928,20 +928,20 @@ mrb_singleton_class(mrb_state *mrb, mrb_value v)
}
void
-mrb_define_singleton_method(mrb_state *mrb, struct RObject *o, const char *name, mrb_func_t func, int aspec)
+mrb_define_singleton_method(mrb_state *mrb, struct RObject *o, const char *name, mrb_func_t func, mrb_aspec aspec)
{
prepare_singleton_class(mrb, (struct RBasic*)o);
mrb_define_method_id(mrb, o->c, mrb_intern(mrb, name), func, aspec);
}
void
-mrb_define_class_method(mrb_state *mrb, struct RClass *c, const char *name, mrb_func_t func, int aspec)
+mrb_define_class_method(mrb_state *mrb, struct RClass *c, const char *name, mrb_func_t func, mrb_aspec aspec)
{
mrb_define_singleton_method(mrb, (struct RObject*)c, name, func, aspec);
}
void
-mrb_define_module_function(mrb_state *mrb, struct RClass *c, const char *name, mrb_func_t func, int aspec)
+mrb_define_module_function(mrb_state *mrb, struct RClass *c, const char *name, mrb_func_t func, mrb_aspec aspec)
{
mrb_define_class_method(mrb, c, name, func, aspec);
mrb_define_method(mrb, c, name, func, aspec);
Please sign in to comment.
Something went wrong with that request. Please try again.