summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/mruby.h46
-rw-r--r--include/mruby/string.h2
2 files changed, 28 insertions, 20 deletions
diff --git a/include/mruby.h b/include/mruby.h
index 6e222057f..99d06146f 100644
--- a/include/mruby.h
+++ b/include/mruby.h
@@ -1,7 +1,7 @@
/*
** mruby - An embeddable Ruby implementation
**
-** Copyright (c) mruby developers 2010-2016
+** Copyright (c) mruby developers 2010-2017
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
@@ -608,6 +608,14 @@ MRB_API mrb_bool mrb_class_defined(mrb_state *mrb, const char *name);
MRB_API struct RClass * mrb_class_get(mrb_state *mrb, const char *name);
/**
+ * Gets a exception class.
+ * @param [mrb_state*] mrb The current mruby state.
+ * @param [const char *] name The name of the class.
+ * @return [struct RClass *] A reference to the class.
+*/
+MRB_API struct RClass * mrb_exc_get(mrb_state *mrb, const char *name);
+
+/**
* Returns an mrb_bool. True if inner class was defined, and false if the inner class was not defined.
*
* Example:
@@ -1091,23 +1099,23 @@ MRB_API void mrb_print_error(mrb_state *mrb);
+ those E_* macros requires mrb_state* variable named mrb.
+ exception objects obtained from those macros are local to mrb
*/
-#define E_RUNTIME_ERROR (mrb_class_get(mrb, "RuntimeError"))
-#define E_TYPE_ERROR (mrb_class_get(mrb, "TypeError"))
-#define E_ARGUMENT_ERROR (mrb_class_get(mrb, "ArgumentError"))
-#define E_INDEX_ERROR (mrb_class_get(mrb, "IndexError"))
-#define E_RANGE_ERROR (mrb_class_get(mrb, "RangeError"))
-#define E_NAME_ERROR (mrb_class_get(mrb, "NameError"))
-#define E_NOMETHOD_ERROR (mrb_class_get(mrb, "NoMethodError"))
-#define E_SCRIPT_ERROR (mrb_class_get(mrb, "ScriptError"))
-#define E_SYNTAX_ERROR (mrb_class_get(mrb, "SyntaxError"))
-#define E_LOCALJUMP_ERROR (mrb_class_get(mrb, "LocalJumpError"))
-#define E_REGEXP_ERROR (mrb_class_get(mrb, "RegexpError"))
-#define E_SYSSTACK_ERROR (mrb_class_get(mrb, "SystemStackError"))
-
-#define E_NOTIMP_ERROR (mrb_class_get(mrb, "NotImplementedError"))
-#define E_FLOATDOMAIN_ERROR (mrb_class_get(mrb, "FloatDomainError"))
-
-#define E_KEY_ERROR (mrb_class_get(mrb, "KeyError"))
+#define E_RUNTIME_ERROR (mrb_exc_get(mrb, "RuntimeError"))
+#define E_TYPE_ERROR (mrb_exc_get(mrb, "TypeError"))
+#define E_ARGUMENT_ERROR (mrb_exc_get(mrb, "ArgumentError"))
+#define E_INDEX_ERROR (mrb_exc_get(mrb, "IndexError"))
+#define E_RANGE_ERROR (mrb_exc_get(mrb, "RangeError"))
+#define E_NAME_ERROR (mrb_exc_get(mrb, "NameError"))
+#define E_NOMETHOD_ERROR (mrb_exc_get(mrb, "NoMethodError"))
+#define E_SCRIPT_ERROR (mrb_exc_get(mrb, "ScriptError"))
+#define E_SYNTAX_ERROR (mrb_exc_get(mrb, "SyntaxError"))
+#define E_LOCALJUMP_ERROR (mrb_exc_get(mrb, "LocalJumpError"))
+#define E_REGEXP_ERROR (mrb_exc_get(mrb, "RegexpError"))
+#define E_SYSSTACK_ERROR (mrb_exc_get(mrb, "SystemStackError"))
+
+#define E_NOTIMP_ERROR (mrb_exc_get(mrb, "NotImplementedError"))
+#define E_FLOATDOMAIN_ERROR (mrb_exc_get(mrb, "FloatDomainError"))
+
+#define E_KEY_ERROR (mrb_exc_get(mrb, "KeyError"))
MRB_API mrb_value mrb_yield(mrb_state *mrb, mrb_value b, mrb_value arg);
MRB_API mrb_value mrb_yield_argv(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv);
@@ -1160,7 +1168,7 @@ MRB_API mrb_value mrb_fiber_yield(mrb_state *mrb, mrb_int argc, const mrb_value
*
* @mrbgem mruby-fiber
*/
-#define E_FIBER_ERROR (mrb_class_get(mrb, "FiberError"))
+#define E_FIBER_ERROR (mrb_exc_get(mrb, "FiberError"))
/* memory pool implementation */
typedef struct mrb_pool mrb_pool;
diff --git a/include/mruby/string.h b/include/mruby/string.h
index 9ccf8f187..5a5a6ffd2 100644
--- a/include/mruby/string.h
+++ b/include/mruby/string.h
@@ -68,7 +68,7 @@ struct RString {
#define mrb_str_ptr(s) ((struct RString*)(mrb_ptr(s)))
#define RSTRING(s) mrb_str_ptr(s)
#define RSTRING_PTR(s) RSTR_PTR(RSTRING(s))
-#define RSTRING_EMBED_LEN(s) RSTR_ENBED_LEN(RSTRING(s))
+#define RSTRING_EMBED_LEN(s) RSTR_EMBED_LEN(RSTRING(s))
#define RSTRING_LEN(s) RSTR_LEN(RSTRING(s))
#define RSTRING_CAPA(s) RSTR_CAPA(RSTRING(s))
#define RSTRING_END(s) (RSTRING_PTR(s) + RSTRING_LEN(s))