mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
DISABLE_STDIO/ENABLE_DEBUG macros to rename; close #3014
changes: * rename DISABLE_STDIO -> MRB_DISABLE_STDIO * rename ENABLE_DEBUG -> MRB_ENABLE_DEBUG_HOOK * no more opposite macro definitions (e.g. ENABLE_STDIO, DISABLE_DEBUG). * rewrite above macro references throughout the code. * update documents
This commit is contained in:
+2
-2
@@ -25,7 +25,7 @@ struct backtrace_location {
|
||||
|
||||
typedef void (*output_stream_func)(mrb_state*, struct backtrace_location*, void*);
|
||||
|
||||
#ifdef ENABLE_STDIO
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
|
||||
struct print_backtrace_args {
|
||||
FILE *stream;
|
||||
@@ -165,7 +165,7 @@ exc_output_backtrace(mrb_state *mrb, struct RObject *exc, output_stream_func fun
|
||||
overwritten. So invoke these functions just after detecting exceptions.
|
||||
*/
|
||||
|
||||
#ifdef ENABLE_STDIO
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
|
||||
MRB_API void
|
||||
mrb_print_backtrace(mrb_state *mrb)
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
#include "mruby/string.h"
|
||||
#include "mruby/proc.h"
|
||||
|
||||
#ifdef ENABLE_STDIO
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
static int
|
||||
print_r(mrb_state *mrb, mrb_irep *irep, size_t n, int pre)
|
||||
{
|
||||
@@ -53,7 +53,7 @@ print_lv(mrb_state *mrb, mrb_irep *irep, mrb_code c, int r)
|
||||
static void
|
||||
codedump(mrb_state *mrb, mrb_irep *irep)
|
||||
{
|
||||
#ifdef ENABLE_STDIO
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
int i;
|
||||
int ai;
|
||||
mrb_code c;
|
||||
|
||||
+2
-2
@@ -989,7 +989,7 @@ mrb_dump_irep(mrb_state *mrb, mrb_irep *irep, uint8_t flags, uint8_t **bin, size
|
||||
return dump_irep(mrb, irep, dump_flags(flags, FLAG_BYTEORDER_NONATIVE), bin, bin_size);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_STDIO
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
|
||||
int
|
||||
mrb_dump_irep_binary(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE* fp)
|
||||
@@ -1092,4 +1092,4 @@ mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE *fp, con
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif /* ENABLE_STDIO */
|
||||
#endif /* MRB_DISABLE_STDIO */
|
||||
|
||||
+2
-2
@@ -309,7 +309,7 @@ mrb_name_error(mrb_state *mrb, mrb_sym id, const char *fmt, ...)
|
||||
MRB_API void
|
||||
mrb_warn(mrb_state *mrb, const char *fmt, ...)
|
||||
{
|
||||
#ifdef ENABLE_STDIO
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
va_list ap;
|
||||
mrb_value str;
|
||||
|
||||
@@ -324,7 +324,7 @@ mrb_warn(mrb_state *mrb, const char *fmt, ...)
|
||||
MRB_API mrb_noreturn void
|
||||
mrb_bug(mrb_state *mrb, const char *fmt, ...)
|
||||
{
|
||||
#ifdef ENABLE_STDIO
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
va_list ap;
|
||||
mrb_value str;
|
||||
|
||||
|
||||
+2
-2
@@ -642,7 +642,7 @@ mrb_load_irep(mrb_state *mrb, const uint8_t *bin)
|
||||
return mrb_load_irep_cxt(mrb, bin, NULL);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_STDIO
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
|
||||
MRB_API mrb_irep*
|
||||
mrb_read_irep_file(mrb_state *mrb, FILE* fp)
|
||||
@@ -704,4 +704,4 @@ mrb_load_irep_file(mrb_state *mrb, FILE* fp)
|
||||
{
|
||||
return mrb_load_irep_file_cxt(mrb, fp, NULL);
|
||||
}
|
||||
#endif /* ENABLE_STDIO */
|
||||
#endif /* MRB_DISABLE_STDIO */
|
||||
|
||||
+5
-16
@@ -8,7 +8,7 @@
|
||||
#include "mruby/string.h"
|
||||
#include "mruby/variable.h"
|
||||
|
||||
#ifdef ENABLE_STDIO
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
static void
|
||||
printstr(mrb_value obj, FILE *stream)
|
||||
{
|
||||
@@ -24,35 +24,24 @@ printstr(mrb_value obj, FILE *stream)
|
||||
MRB_API void
|
||||
mrb_p(mrb_state *mrb, mrb_value obj)
|
||||
{
|
||||
mrb_value val = mrb_inspect(mrb, obj);
|
||||
|
||||
printstr(val, stdout);
|
||||
printstr(mrb_inspect(mrb, obj), stdout);
|
||||
}
|
||||
|
||||
MRB_API void
|
||||
mrb_print_error(mrb_state *mrb)
|
||||
{
|
||||
mrb_value s;
|
||||
|
||||
mrb_print_backtrace(mrb);
|
||||
s = mrb_funcall(mrb, mrb_obj_value(mrb->exc), "inspect", 0);
|
||||
printstr(s, stderr);
|
||||
printstr(mrb_funcall(mrb, mrb_obj_value(mrb->exc), "inspect", 0), stderr);
|
||||
}
|
||||
|
||||
MRB_API void
|
||||
mrb_show_version(mrb_state *mrb)
|
||||
{
|
||||
mrb_value msg;
|
||||
|
||||
msg = mrb_const_get(mrb, mrb_obj_value(mrb->object_class), mrb_intern_lit(mrb, "MRUBY_DESCRIPTION"));
|
||||
printstr(msg, stdout);
|
||||
printstr(mrb_const_get(mrb, mrb_obj_value(mrb->object_class), mrb_intern_lit(mrb, "MRUBY_DESCRIPTION")), stdout);
|
||||
}
|
||||
|
||||
MRB_API void
|
||||
mrb_show_copyright(mrb_state *mrb)
|
||||
{
|
||||
mrb_value msg;
|
||||
|
||||
msg = mrb_const_get(mrb, mrb_obj_value(mrb->object_class), mrb_intern_lit(mrb, "MRUBY_COPYRIGHT"));
|
||||
printstr(msg, stdout);
|
||||
printstr(mrb_const_get(mrb, mrb_obj_value(mrb->object_class), mrb_intern_lit(mrb, "MRUBY_COPYRIGHT")), stdout);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "value_array.h"
|
||||
#include "mruby/throw.h"
|
||||
|
||||
#ifndef ENABLE_STDIO
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -693,7 +693,7 @@ argnum_error(mrb_state *mrb, mrb_int num)
|
||||
|
||||
#define ERR_PC_SET(mrb, pc) mrb->c->ci->err = pc;
|
||||
#define ERR_PC_CLR(mrb) mrb->c->ci->err = 0;
|
||||
#ifdef ENABLE_DEBUG
|
||||
#ifdef MRB_ENABLE_DEBUG_HOOK
|
||||
#define CODE_FETCH_HOOK(mrb, irep, pc, regs) if ((mrb)->code_fetch_hook) (mrb)->code_fetch_hook((mrb), (irep), (pc), (regs));
|
||||
#else
|
||||
#define CODE_FETCH_HOOK(mrb, irep, pc, regs)
|
||||
@@ -2340,10 +2340,10 @@ RETRY_TRY_BLOCK:
|
||||
|
||||
CASE(OP_DEBUG) {
|
||||
/* A B C debug print R(A),R(B),R(C) */
|
||||
#ifdef ENABLE_DEBUG
|
||||
#ifdef MRB_ENABLE_DEBUG_HOOK
|
||||
mrb->debug_op_hook(mrb, irep, pc, regs);
|
||||
#else
|
||||
#ifdef ENABLE_STDIO
|
||||
#ifndef MRB_DISABLE_STDIO
|
||||
printf("OP_DEBUG %d %d %d\n", GETARG_A(i), GETARG_B(i), GETARG_C(i));
|
||||
#else
|
||||
abort();
|
||||
|
||||
Reference in New Issue
Block a user