Commit 76f7aecf authored by Yukihiro Matsumoto's avatar Yukihiro Matsumoto

use ENABLE/DISABLE instead of INCLUDE for configuration macro names

parent 4aa9111f
......@@ -8,8 +8,21 @@
#define MRUBYCONF_H
#include <stdint.h>
/* configuration options: */
/* add -DMRB_USE_FLOAT to use float instead of double for floating point numbers */
#undef MRB_USE_FLOAT
/* -DDISABLE_XXXX to change to drop the feature */
#define DISABLE_REGEXP /* regular expression classes */
#undef DISABLE_KERNEL_SPRINTF /* Kernel.sprintf method */
#undef DISABLE_MATH /* Math functions */
#undef DISABLE_TIME /* Time class */
#undef HAVE_UNISTD_H /* WINDOWS */
#define HAVE_UNISTD_H /* LINUX */
/* end of configuration */
#ifdef MRB_USE_FLOAT
typedef float mrb_float;
#else
......@@ -20,34 +33,19 @@ typedef double mrb_float;
typedef int mrb_int;
typedef intptr_t mrb_sym;
//#define PARSER_DUMP /* print out parser state */
#undef PARSER_DUMP /* do not print out parser state */
//#define INCLUDE_ENCODING /* use UTF-8 encoding classes */
#undef INCLUDE_ENCODING /* not use encoding classes (ascii only) */
//#define INCLUDE_REGEXP /* use regular expression classes */
#undef INCLUDE_REGEXP /* not use regular expression classes */
#ifdef INCLUDE_REGEXP
# define INCLUDE_ENCODING /* Regexp depends Encoding */
/* define ENABLE_XXXX from DISABLE_XXX */
#ifndef DISABLE_REGEXP
#define ENABLE_REGEXP
#endif
#define INCLUDE_KERNEL_SPRINTF /* not use Kernel.sprintf method */
//#undef INCLUDE_KERNEL_SPRINTF /* not use Kernel.sprintf method */
#define INCLUDE_MATH /* use (non ISO) Math module */
//#undef INCLUDE_MATH /* not use (non ISO) Math module */
#define INCLUDE_TIME /* use Time module */
//#undef INCLUDE_TIME /* not use Time module */
#ifdef MRUBY_DEBUG_BUILD
# define PARSER_DUMP
#ifndef DISABLE_KERNEL_SPRINTF
#define ENABLE_KERNEL_SPRINTF
#endif
#ifndef DISABLE_MATH
#define ENABLE_MATH
#endif
#ifndef DISABLE_TIME
#define ENABLE_TIME
#endif
#undef HAVE_UNISTD_H /* WINDOWS */
#define HAVE_UNISTD_H /* LINUX */
#ifndef FALSE
# define FALSE 0
......
......@@ -40,14 +40,7 @@ mrb_class(mrb_state *mrb, mrb_value v)
case MRB_TT_FLOAT:
return mrb->float_class;
#ifdef INCLUDE_REGEXP
// case MRB_TT_REGEX:
// return mrb->regex_class;
// case MRB_TT_MATCH:
// return mrb->match_class;
// case MRB_TT_DATA:
// return mrb->encode_class;
#else
#ifdef ENABLE_REGEXP
case MRB_TT_REGEX:
case MRB_TT_MATCH:
mrb_raise(mrb, E_TYPE_ERROR, "type mismatch: %s given",
......
......@@ -8,7 +8,7 @@
#include "mruby/dump.h"
#include "mruby/string.h"
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
#include "re.h"
#endif
#include "mruby/irep.h"
......@@ -237,7 +237,7 @@ get_pool_block_size(mrb_state *mrb, mrb_irep *irep, int type)
nlen = str_dump_len(RSTRING_PTR(str), RSTRING_LEN(str), type);
size += nlen;
break;
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
case MRB_TT_REGEX:
str = mrb_reg_to_s(mrb, irep->pool[pool_no]);
nlen = str_dump_len(RSTRING_PTR(str), RSTRING_LEN(str), type);
......@@ -365,7 +365,7 @@ write_pool_block(mrb_state *mrb, mrb_irep *irep, char *buf, int type)
str_dump(RSTRING_PTR(str), char_buf, RSTRING_LEN(str), type);
break;
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
case MRB_TT_REGEX:
str = mrb_reg_to_s(mrb, irep->pool[pool_no]);
nlen = str_dump_len(RSTRING_PTR(str), RSTRING_LEN(str), type);
......
......@@ -71,7 +71,7 @@
*/
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
#include "re.h"
#endif
......@@ -92,7 +92,7 @@ typedef struct {
struct RRange range;
struct RStruct structdata;
struct RProc procdata;
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
struct RMatch match;
struct RRegexp regexp;
#endif
......@@ -412,7 +412,7 @@ gc_mark_children(mrb_state *mrb, struct RBasic *obj)
}
break;
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
case MRB_TT_MATCH:
{
struct RMatch *m = (struct RMatch*)obj;
......@@ -611,7 +611,7 @@ gc_gray_mark(mrb_state *mrb, struct RBasic *obj)
children+=2;
break;
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
case MRB_TT_MATCH:
children+=2;
break;
......
......@@ -51,15 +51,15 @@ mrb_init_core(mrb_state *mrb)
mrb_init_range(mrb);
mrb_init_struct(mrb);
mrb_init_gc(mrb);
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
mrb_init_regexp(mrb);
#endif
mrb_init_exception(mrb);
mrb_init_print(mrb);
#ifdef INCLUDE_TIME
#ifdef ENABLE_TIME
mrb_init_time(mrb);
#endif
#ifdef INCLUDE_MATH
#ifdef ENABLE_MATH
mrb_init_math(mrb);
#endif
......
......@@ -8,7 +8,7 @@
#include "mruby/dump.h"
#include "mruby/string.h"
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
#include "re.h"
#endif
#include "mruby/irep.h"
......@@ -418,7 +418,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
irep->pool[i] = mrb_str_new(mrb, buf, pdl);
break;
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
case MRB_TT_REGEX:
str = mrb_str_new(mrb, buf, pdl);
irep->pool[i] = mrb_reg_quote(mrb, str);
......
......@@ -6,7 +6,7 @@
#include "mruby.h"
#ifdef INCLUDE_MATH
#ifdef ENABLE_MATH
#include <math.h>
#define domain_error(msg) \
......@@ -681,4 +681,4 @@ mrb_init_math(mrb_state *mrb)
mrb_define_module_function(mrb, mrb_math, "erf", math_erf, ARGS_REQ(1));
mrb_define_module_function(mrb, mrb_math, "erfc", math_erfc, ARGS_REQ(1));
}
#endif /* INCLUDE_MATH */
#endif /* ENABLE_MATH */
......@@ -4776,9 +4776,6 @@ mrb_compile_file(mrb_state * mrb, FILE *f)
if (!p) return -1;
if (!p->tree) return -1;
if (p->nerr) return -1;
#ifdef PARSER_DUMP
parser_dump(mrb, p->tree, 0);
#endif
n = mrb_generate_code(mrb, p->tree);
mrb_pool_close(p->pool);
......@@ -4795,9 +4792,6 @@ mrb_compile_nstring(mrb_state *mrb, char *s, size_t len)
if (!p) return -1;
if (!p->tree) return -1;
if (p->nerr) return -1;
#ifdef PARSER_DUMP
parser_dump(mrb, p->tree, 0);
#endif
n = mrb_generate_code(mrb, p->tree);
mrb_pool_close(p->pool);
......
......@@ -13,7 +13,7 @@
#include "regint.h"
#include "mruby/class.h"
#include "error.h"
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
#define REGEX_CLASS (mrb_class_obj_get(mrb, "Regexp"))
#define MATCH_CLASS (mrb_class_obj_get(mrb, "MatchData"))
......@@ -2318,7 +2318,7 @@ mrb_backref_set(mrb_state *mrb, mrb_value val)
{
vm_svar_set(mrb, 1, val);
}
#endif //INCLUDE_REGEXP
#endif //ENABLE_REGEXP
#ifdef INCLUDE_ENCODING
static inline long
......@@ -2421,7 +2421,7 @@ mrb_memsearch(mrb_state *mrb, const void *x0, int m, const void *y0, int n, mrb_
}
#endif //INCLUDE_ENCODING
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
mrb_value
mrb_reg_init_str(mrb_state *mrb, mrb_value re, mrb_value s, int options)
{
......@@ -2469,7 +2469,7 @@ re_adjust_startpos(struct re_pattern_buffer *bufp, const char *string, int size,
}*/
return startpos;
}
#endif //INCLUDE_REGEXP
#endif //ENABLE_REGEXP
#ifdef INCLUDE_ENCODING
static const unsigned char mbctab_ascii[] = {
......
......@@ -30,7 +30,7 @@
#include "mruby.h"
#include <string.h>
#include "regparse.h"
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
OnigCaseFoldType OnigDefaultCaseFoldFlag = ONIGENC_CASE_FOLD_MIN;
......@@ -5628,7 +5628,7 @@ onig_end(void)
THREAD_SYSTEM_END;
return 0;
}
#endif //INCLUDE_REGEXP
#endif //ENABLE_REGEXP
#ifdef INCLUDE_ENCODING
extern int
......@@ -5653,7 +5653,7 @@ onig_is_in_code_range(const UChar* p, OnigCodePoint code)
}
#endif //INCLUDE_ENCODING
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
extern int
onig_is_code_in_cc_len(int elen, OnigCodePoint code, CClassNode* cc)
{
......@@ -6285,4 +6285,4 @@ print_tree(FILE* f, Node* node)
print_indent_tree(f, node, 0);
}
#endif
#endif //INCLUDE_REGEXP
#endif //ENABLE_REGEXP
......@@ -28,7 +28,7 @@
*/
#include "mruby.h"
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
#include <string.h>
#include "regint.h"
#include <stdio.h> /* for vsnprintf() */
......@@ -372,4 +372,4 @@ onig_snprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc,
pat, pat_end, fmt, args);
va_end(args);
}
#endif //INCLUDE_REGEXP
#endif //ENABLE_REGEXP
......@@ -28,7 +28,7 @@
*/
#include "mruby.h"
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
#include <string.h>
#include "regint.h"
......@@ -3754,4 +3754,4 @@ onig_copy_encoding(OnigEncoding to, OnigEncoding from)
{
*to = *from;
}
#endif //INCLUDE_REGEXP
#endif //ENABLE_REGEXP
......@@ -32,7 +32,7 @@
#include <string.h>
#include "regparse.h"
#include <stdarg.h>
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
#define WARN_BUFSIZE 256
......@@ -298,7 +298,7 @@ strcat_capa_from_static(UChar* dest, UChar* dest_end,
onig_strcpy(r + (dest_end - dest), src, src_end);
return r;
}
#endif //INCLUDE_REGEXP
#endif //ENABLE_REGEXP
#ifdef INCLUDE_ENCODING
#ifdef USE_ST_LIBRARY
......@@ -393,7 +393,7 @@ onig_st_insert_strend(hash_table_type* table, const UChar* str_key,
#endif /* USE_ST_LIBRARY */
#endif //INCLUDE_ENCODING
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
#ifdef USE_NAMED_GROUP
#define INIT_NAME_BACKREFS_ALLOC_NUM 8
......@@ -5597,4 +5597,4 @@ onig_scan_env_set_error_string(ScanEnv* env, int ecode ARG_UNUSED,
env->error = arg;
env->error_end = arg_end;
}
#endif //INCLUDE_REGEXP
#endif //ENABLE_REGEXP
This diff is collapsed.
......@@ -12,7 +12,7 @@
#include <stdarg.h>
//#include "defines.h"
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
#include "encoding.h"
#endif
......
......@@ -6,7 +6,7 @@
#include "mruby.h"
#ifdef INCLUDE_TIME
#ifdef ENABLE_TIME
#include <string.h>
#include <stdio.h>
#include <time.h>
......@@ -744,4 +744,3 @@ mrb_init_time(mrb_state *mrb)
*/
}
#endif
......@@ -14,7 +14,7 @@
#include "error.h"
#include "mruby/array.h"
#ifdef INCLUDE_REGEXP
#ifdef ENABLE_REGEXP
#include "re.h"
#include "st.h"
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment