diff options
| author | Masaki Muranaka <[email protected]> | 2013-03-13 13:30:40 +0900 |
|---|---|---|
| committer | Masaki Muranaka <[email protected]> | 2013-03-14 15:13:12 +0900 |
| commit | 1ffc9ba3255f8b63164c42ea8304115f5a6b2464 (patch) | |
| tree | 696cc7a62568dd72974e5a20c7fa8486cb5b58e2 | |
| parent | 0739960b7fab2ce61bbeaedef7680cd4805a03f4 (diff) | |
| download | mruby-1ffc9ba3255f8b63164c42ea8304115f5a6b2464.tar.gz mruby-1ffc9ba3255f8b63164c42ea8304115f5a6b2464.zip | |
Define type mrb_bool. It is typedef-ed to _Bool on C99, unsigned int on MSVC.
It is safer than applying 1bit bit-fields to signed int.
For forward compatibility, you should substiture only 1 or 0 for the variable typed mrb_bool.
| -rw-r--r-- | include/mrbconf.h | 2 | ||||
| -rw-r--r-- | include/mruby.h | 6 | ||||
| -rw-r--r-- | include/mruby/compile.h | 14 | ||||
| -rw-r--r-- | src/codegen.c | 2 | ||||
| -rw-r--r-- | src/gc.c | 2 | ||||
| -rw-r--r-- | tools/mrbc/mrbc.c | 4 | ||||
| -rw-r--r-- | tools/mruby/mruby.c | 8 |
7 files changed, 20 insertions, 18 deletions
diff --git a/include/mrbconf.h b/include/mrbconf.h index cabc10b4f..275cdf4c1 100644 --- a/include/mrbconf.h +++ b/include/mrbconf.h @@ -110,8 +110,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 e058d409f..c5f359bd8 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; 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/src/codegen.c b/src/codegen.c index ed44f1792..cbbd2d16a 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -49,7 +49,7 @@ typedef struct scope { int pc; int lastlabel; int ainfo:15; - int mscope:1; + mrb_bool mscope:1; struct loopinfo *loop; int ensure_level; @@ -197,7 +197,7 @@ struct heap_page { struct heap_page *next; struct heap_page *free_next; struct heap_page *free_prev; - unsigned int old:1; + mrb_bool old:1; RVALUE objects[MRB_HEAP_PAGE_SIZE]; }; diff --git a/tools/mrbc/mrbc.c b/tools/mrbc/mrbc.c index 698586ec0..09ab2ca1d 100644 --- a/tools/mrbc/mrbc.c +++ b/tools/mrbc/mrbc.c @@ -19,8 +19,8 @@ struct _args { char *filename; char *initname; char *ext; - int check_syntax : 1; - int verbose : 1; + mrb_bool check_syntax : 1; + mrb_bool verbose : 1; }; static void diff --git a/tools/mruby/mruby.c b/tools/mruby/mruby.c index aa9123844..c509c0d30 100644 --- a/tools/mruby/mruby.c +++ b/tools/mruby/mruby.c @@ -26,10 +26,10 @@ void mrb_show_copyright(mrb_state *); struct _args { FILE *rfp; char* cmdline; - int fname : 1; - int mrbfile : 1; - int check_syntax : 1; - int verbose : 1; + mrb_bool fname : 1; + mrb_bool mrbfile : 1; + mrb_bool check_syntax : 1; + mrb_bool verbose : 1; int argc; char** argv; }; |
