w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

mruby.h File Reference
#include <stdarg.h>
#include <stdint.h>
#include <stddef.h>
#include <limits.h>
#include "mrbconf.h"
#include <mruby/common.h>
#include <mruby/value.h>
#include <mruby/gc.h>
#include <mruby/version.h>
#include <float.h>
Include dependency graph for mruby.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mrb_callinfo
 
struct  mrb_context
 
struct  mrb_cache_entry
 
struct  mrb_state
 
struct  mrb_kwargs
 

Macros

#define mrb_assert(p)   ((void)0)
 
#define mrb_assert_int_fit(t1, n, t2, max)   ((void)0)
 
#define _mrb_static_assert_cat0(a, b)   a##b
 
#define _mrb_static_assert_cat(a, b)   _mrb_static_assert_cat0(a, b)
 
#define _mrb_static_assert_id(prefix)   _mrb_static_assert_cat(prefix, __LINE__)
 
#define mrb_static_assert(exp, str)    struct _mrb_static_assert_id(_mrb_static_assert_) { char x[(exp) ? 1 : -1]; }
 
#define mrb_static_assert1(exp)   mrb_static_assert(exp, #exp)
 
#define FLT_EPSILON   (1.19209290e-07f)
 
#define DBL_EPSILON   ((double)2.22044604925031308085e-16L)
 
#define LDBL_EPSILON   (1.08420217248550443401e-19L)
 
#define MRB_FLOAT_EPSILON   DBL_EPSILON
 
#define MRB_FIXED_STATE_ATEXIT_STACK_SIZE   5
 
#define MRB_METHOD_CACHE_SIZE   (1<<8)
 
#define mrb_exc_get(mrb, name)   mrb_exc_get_id(mrb, mrb_intern_cstr(mrb, name))
 
#define MRB_ARGS_REQ(n)   ((mrb_aspec)((n)&0x1f) << 18)
 
#define MRB_ARGS_OPT(n)   ((mrb_aspec)((n)&0x1f) << 13)
 
#define MRB_ARGS_ARG(n1, n2)   (MRB_ARGS_REQ(n1)|MRB_ARGS_OPT(n2))
 
#define MRB_ARGS_REST()   ((mrb_aspec)(1 << 12))
 
#define MRB_ARGS_POST(n)   ((mrb_aspec)((n)&0x1f) << 7)
 
#define MRB_ARGS_KEY(n1, n2)   ((mrb_aspec)((((n1)&0x1f) << 2) | ((n2)?(1<<1):0)))
 
#define MRB_ARGS_BLOCK()   ((mrb_aspec)1)
 
#define MRB_ARGS_ANY()   MRB_ARGS_REST()
 
#define MRB_ARGS_NONE()   ((mrb_aspec)0)
 
#define mrb_strlen_lit(lit)   (sizeof(lit "") - 1)
 
#define mrb_intern_lit(mrb, lit)   mrb_intern_static(mrb, (lit ""), mrb_strlen_lit(lit))
 
#define mrb_sym2name(mrb, sym)   mrb_sym_name(mrb,sym)
 
#define mrb_sym2name_len(mrb, sym, len)   mrb_sym_name_len(mrb,sym,len)
 
#define mrb_sym2str(mrb, sym)   mrb_sym_str(mrb,sym)
 
#define mrb_str_new_lit(mrb, lit)   mrb_str_new_static(mrb, (lit), mrb_strlen_lit(lit))
 
#define mrb_str_new_frozen(mrb, p, len)   mrb_obj_freeze(mrb,mrb_str_new(mrb,p,len))
 
#define mrb_str_new_cstr_frozen(mrb, p)   mrb_obj_freeze(mrb,mrb_str_new_cstr(mrb,p))
 
#define mrb_str_new_static_frozen(mrb, p, len)   mrb_obj_freeze(mrb,mrb_str_new_static(mrb,p,len))
 
#define mrb_str_new_lit_frozen(mrb, lit)   mrb_obj_freeze(mrb,mrb_str_new_lit(mrb,lit))
 
#define mrb_utf8_from_locale(p, l)   ((char*)(p))
 
#define mrb_locale_from_utf8(p, l)   ((char*)(p))
 
#define mrb_locale_free(p)
 
#define mrb_utf8_free(p)
 
#define mrb_toplevel_run_keep(m, p, k)   mrb_top_run((m),(p),mrb_top_self(m),(k))
 
#define mrb_toplevel_run(m, p)   mrb_toplevel_run_keep((m),(p),0)
 
#define mrb_context_run(m, p, s, k)   mrb_vm_run((m),(p),(s),(k))
 
#define mrb_gc_mark_value(mrb, val)
 
#define mrb_field_write_barrier_value(mrb, obj, val)
 
#define mrb_convert_type(mrb, val, type, tname, method)   mrb_type_convert(mrb, val, type, mrb_intern_lit(mrb, method))
 
#define mrb_check_convert_type(mrb, val, type, tname, method)   mrb_type_convert_check(mrb, val, type, mrb_intern_lit(mrb, method))
 
#define ISASCII(c)   ((unsigned)(c) <= 0x7f)
 
#define ISPRINT(c)   (((unsigned)(c) - 0x20) < 0x5f)
 
#define ISSPACE(c)   ((c) == ' ' || (unsigned)(c) - '\t' < 5)
 
#define ISUPPER(c)   (((unsigned)(c) - 'A') < 26)
 
#define ISLOWER(c)   (((unsigned)(c) - 'a') < 26)
 
#define ISALPHA(c)   ((((unsigned)(c) | 0x20) - 'a') < 26)
 
#define ISDIGIT(c)   (((unsigned)(c) - '0') < 10)
 
#define ISXDIGIT(c)   (ISDIGIT(c) || ((unsigned)(c) | 0x20) - 'a' < 6)
 
#define ISALNUM(c)   (ISALPHA(c) || ISDIGIT(c))
 
#define ISBLANK(c)   ((c) == ' ' || (c) == '\t')
 
#define ISCNTRL(c)   ((unsigned)(c) < 0x20 || (c) == 0x7f)
 
#define TOUPPER(c)   (ISLOWER(c) ? ((c) & 0x5f) : (c))
 
#define TOLOWER(c)   (ISUPPER(c) ? ((c) | 0x20) : (c))
 
#define MRB_ERROR_SYM(sym)   mrb_intern_lit(mrb, #sym)
 
#define E_RUNTIME_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(RuntimeError))
 
#define E_TYPE_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(TypeError))
 
#define E_ZERODIV_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(ZeroDivisionError))
 
#define E_ARGUMENT_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(ArgumentError))
 
#define E_INDEX_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(IndexError))
 
#define E_RANGE_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(RangeError))
 
#define E_NAME_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(NameError))
 
#define E_NOMETHOD_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(NoMethodError))
 
#define E_SCRIPT_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(ScriptError))
 
#define E_SYNTAX_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(SyntaxError))
 
#define E_LOCALJUMP_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(LocalJumpError))
 
#define E_REGEXP_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(RegexpError))
 
#define E_FROZEN_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(FrozenError))
 
#define E_NOTIMP_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(NotImplementedError))
 
#define E_KEY_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(KeyError))
 
#define E_FLOATDOMAIN_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(FloatDomainError))
 
#define mrb_int(mrb, val)   mrb_integer(mrb_to_int(mrb, val))
 
#define E_FIBER_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(FiberError))
 

Typedefs

typedef uint8_t mrb_code
 
typedef uint32_t mrb_aspec
 
typedef void *(* mrb_allocf) (struct mrb_state *mrb, void *, size_t, void *ud)
 
typedef mrb_value(* mrb_func_t) (struct mrb_state *mrb, mrb_value self)
 
typedef uintptr_t mrb_method_t
 
typedef void(* mrb_atexit_func) (struct mrb_state *)
 
typedef struct mrb_state mrb_state
 
typedef const char * mrb_args_format
 
typedef struct mrb_kwargs mrb_kwargs
 
typedef struct mrb_pool mrb_pool
 

Enumerations

enum  mrb_fiber_state {
  MRB_FIBER_CREATED = 0 , MRB_FIBER_RUNNING , MRB_FIBER_RESUMED , MRB_FIBER_SUSPENDED ,
  MRB_FIBER_TRANSFERRED , MRB_FIBER_TERMINATED
}
 

Functions

struct RClassmrb_define_class (mrb_state *mrb, const char *name, struct RClass *super)
 
struct RClassmrb_define_class_id (mrb_state *mrb, mrb_sym name, struct RClass *super)
 
struct RClassmrb_define_module (mrb_state *mrb, const char *name)
 
struct RClassmrb_define_module_id (mrb_state *mrb, mrb_sym name)
 
mrb_value mrb_singleton_class (mrb_state *mrb, mrb_value val)
 
struct RClassmrb_singleton_class_ptr (mrb_state *mrb, mrb_value val)
 
void mrb_include_module (mrb_state *mrb, struct RClass *cla, struct RClass *included)
 
void mrb_prepend_module (mrb_state *mrb, struct RClass *cla, struct RClass *prepended)
 
void mrb_define_method (mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t func, mrb_aspec aspec)
 
void mrb_define_method_id (mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t func, mrb_aspec aspec)
 
void mrb_define_class_method (mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t fun, mrb_aspec aspec)
 
void mrb_define_class_method_id (mrb_state *mrb, struct RClass *cla, mrb_sym name, mrb_func_t fun, mrb_aspec aspec)
 
void mrb_define_singleton_method (mrb_state *mrb, struct RObject *cla, const char *name, mrb_func_t fun, mrb_aspec aspec)
 
void mrb_define_singleton_method_id (mrb_state *mrb, struct RObject *cla, mrb_sym name, mrb_func_t fun, mrb_aspec aspec)
 
void mrb_define_module_function (mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t fun, mrb_aspec aspec)
 
void mrb_define_module_function_id (mrb_state *mrb, struct RClass *cla, mrb_sym name, mrb_func_t fun, mrb_aspec aspec)
 
void mrb_define_const (mrb_state *mrb, struct RClass *cla, const char *name, mrb_value val)
 
void mrb_define_const_id (mrb_state *mrb, struct RClass *cla, mrb_sym name, mrb_value val)
 
void mrb_undef_method (mrb_state *mrb, struct RClass *cla, const char *name)
 
void mrb_undef_method_id (mrb_state *, struct RClass *, mrb_sym)
 
void mrb_undef_class_method (mrb_state *mrb, struct RClass *cls, const char *name)
 
void mrb_undef_class_method_id (mrb_state *mrb, struct RClass *cls, mrb_sym name)
 
mrb_value mrb_obj_new (mrb_state *mrb, struct RClass *c, mrb_int argc, const mrb_value *argv)
 
static mrb_value mrb_class_new_instance (mrb_state *mrb, mrb_int argc, const mrb_value *argv, struct RClass *c)
 
struct RClassmrb_class_new (mrb_state *mrb, struct RClass *super)
 
struct RClassmrb_module_new (mrb_state *mrb)
 
mrb_bool mrb_class_defined (mrb_state *mrb, const char *name)
 
mrb_bool mrb_class_defined_id (mrb_state *mrb, mrb_sym name)
 
struct RClassmrb_class_get (mrb_state *mrb, const char *name)
 
struct RClassmrb_class_get_id (mrb_state *mrb, mrb_sym name)
 
struct RClassmrb_exc_get_id (mrb_state *mrb, mrb_sym name)
 
mrb_bool mrb_class_defined_under (mrb_state *mrb, struct RClass *outer, const char *name)
 
mrb_bool mrb_class_defined_under_id (mrb_state *mrb, struct RClass *outer, mrb_sym name)
 
struct RClassmrb_class_get_under (mrb_state *mrb, struct RClass *outer, const char *name)
 
struct RClassmrb_class_get_under_id (mrb_state *mrb, struct RClass *outer, mrb_sym name)
 
struct RClassmrb_module_get (mrb_state *mrb, const char *name)
 
struct RClassmrb_module_get_id (mrb_state *mrb, mrb_sym name)
 
struct RClassmrb_module_get_under (mrb_state *mrb, struct RClass *outer, const char *name)
 
struct RClassmrb_module_get_under_id (mrb_state *mrb, struct RClass *outer, mrb_sym name)
 
void mrb_notimplement (mrb_state *)
 
mrb_value mrb_notimplement_m (mrb_state *, mrb_value)
 
mrb_value mrb_obj_dup (mrb_state *mrb, mrb_value obj)
 
mrb_bool mrb_obj_respond_to (mrb_state *mrb, struct RClass *c, mrb_sym mid)
 
struct RClassmrb_define_class_under (mrb_state *mrb, struct RClass *outer, const char *name, struct RClass *super)
 
struct RClassmrb_define_class_under_id (mrb_state *mrb, struct RClass *outer, mrb_sym name, struct RClass *super)
 
struct RClassmrb_define_module_under (mrb_state *mrb, struct RClass *outer, const char *name)
 
struct RClassmrb_define_module_under_id (mrb_state *mrb, struct RClass *outer, mrb_sym name)
 
mrb_int mrb_get_args (mrb_state *mrb, mrb_args_format format,...)
 
static mrb_sym mrb_get_mid (mrb_state *mrb)
 
mrb_int mrb_get_argc (mrb_state *mrb)
 
const mrb_valuemrb_get_argv (mrb_state *mrb)
 
mrb_value mrb_get_arg1 (mrb_state *mrb)
 
mrb_value mrb_funcall (mrb_state *mrb, mrb_value val, const char *name, mrb_int argc,...)
 
mrb_value mrb_funcall_id (mrb_state *mrb, mrb_value val, mrb_sym mid, mrb_int argc,...)
 
mrb_value mrb_funcall_argv (mrb_state *mrb, mrb_value val, mrb_sym name, mrb_int argc, const mrb_value *argv)
 
mrb_value mrb_funcall_with_block (mrb_state *mrb, mrb_value val, mrb_sym name, mrb_int argc, const mrb_value *argv, mrb_value block)
 
mrb_sym mrb_intern_cstr (mrb_state *mrb, const char *str)
 
mrb_sym mrb_intern (mrb_state *, const char *, size_t)
 
mrb_sym mrb_intern_static (mrb_state *, const char *, size_t)
 
mrb_sym mrb_intern_str (mrb_state *, mrb_value)
 
mrb_sym mrb_intern_check_cstr (mrb_state *, const char *)
 
mrb_sym mrb_intern_check (mrb_state *, const char *, size_t)
 
mrb_sym mrb_intern_check_str (mrb_state *, mrb_value)
 
mrb_value mrb_check_intern_cstr (mrb_state *, const char *)
 
mrb_value mrb_check_intern (mrb_state *, const char *, size_t)
 
mrb_value mrb_check_intern_str (mrb_state *, mrb_value)
 
const char * mrb_sym_name (mrb_state *, mrb_sym)
 
const char * mrb_sym_name_len (mrb_state *, mrb_sym, mrb_int *)
 
const char * mrb_sym_dump (mrb_state *, mrb_sym)
 
mrb_value mrb_sym_str (mrb_state *, mrb_sym)
 
voidmrb_malloc (mrb_state *, size_t)
 
voidmrb_calloc (mrb_state *, size_t, size_t)
 
voidmrb_realloc (mrb_state *, void *, size_t)
 
voidmrb_realloc_simple (mrb_state *, void *, size_t)
 
voidmrb_malloc_simple (mrb_state *, size_t)
 
struct RBasicmrb_obj_alloc (mrb_state *, enum mrb_vtype, struct RClass *)
 
void mrb_free (mrb_state *, void *)
 
mrb_value mrb_str_new (mrb_state *mrb, const char *p, size_t len)
 
mrb_value mrb_str_new_cstr (mrb_state *, const char *)
 
mrb_value mrb_str_new_static (mrb_state *mrb, const char *p, size_t len)
 
mrb_value mrb_obj_freeze (mrb_state *, mrb_value)
 
mrb_statemrb_open (void)
 
mrb_statemrb_open_allocf (mrb_allocf f, void *ud)
 
mrb_statemrb_open_core (mrb_allocf f, void *ud)
 
void mrb_close (mrb_state *mrb)
 
voidmrb_default_allocf (mrb_state *, void *, size_t, void *)
 
mrb_value mrb_top_self (mrb_state *mrb)
 
mrb_value mrb_top_run (mrb_state *mrb, const struct RProc *proc, mrb_value self, mrb_int stack_keep)
 
mrb_value mrb_vm_run (mrb_state *mrb, const struct RProc *proc, mrb_value self, mrb_int stack_keep)
 
mrb_value mrb_vm_exec (mrb_state *mrb, const struct RProc *proc, const mrb_code *iseq)
 
void mrb_p (mrb_state *, mrb_value)
 
mrb_int mrb_obj_id (mrb_value obj)
 
mrb_sym mrb_obj_to_sym (mrb_state *mrb, mrb_value name)
 
mrb_bool mrb_obj_eq (mrb_state *mrb, mrb_value a, mrb_value b)
 
mrb_bool mrb_obj_equal (mrb_state *mrb, mrb_value a, mrb_value b)
 
mrb_bool mrb_equal (mrb_state *mrb, mrb_value obj1, mrb_value obj2)
 
mrb_value mrb_convert_to_integer (mrb_state *mrb, mrb_value val, mrb_int base)
 
mrb_value mrb_Integer (mrb_state *mrb, mrb_value val)
 
mrb_value mrb_Float (mrb_state *mrb, mrb_value val)
 
mrb_value mrb_inspect (mrb_state *mrb, mrb_value obj)
 
mrb_bool mrb_eql (mrb_state *mrb, mrb_value obj1, mrb_value obj2)
 
mrb_int mrb_cmp (mrb_state *mrb, mrb_value obj1, mrb_value obj2)
 
static int mrb_gc_arena_save (mrb_state *mrb)
 
static void mrb_gc_arena_restore (mrb_state *mrb, int idx)
 
void mrb_garbage_collect (mrb_state *)
 
void mrb_full_gc (mrb_state *)
 
void mrb_incremental_gc (mrb_state *)
 
void mrb_gc_mark (mrb_state *, struct RBasic *)
 
void mrb_field_write_barrier (mrb_state *, struct RBasic *, struct RBasic *)
 
void mrb_write_barrier (mrb_state *, struct RBasic *)
 
mrb_value mrb_type_convert (mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method)
 
mrb_value mrb_type_convert_check (mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method)
 
mrb_value mrb_any_to_s (mrb_state *mrb, mrb_value obj)
 
const char * mrb_obj_classname (mrb_state *mrb, mrb_value obj)
 
struct RClassmrb_obj_class (mrb_state *mrb, mrb_value obj)
 
mrb_value mrb_class_path (mrb_state *mrb, struct RClass *c)
 
mrb_bool mrb_obj_is_kind_of (mrb_state *mrb, mrb_value obj, struct RClass *c)
 
mrb_value mrb_obj_inspect (mrb_state *mrb, mrb_value self)
 
mrb_value mrb_obj_clone (mrb_state *mrb, mrb_value self)
 
mrb_value mrb_exc_new (mrb_state *mrb, struct RClass *c, const char *ptr, size_t len)
 
void mrb_exc_raise (mrb_state *mrb, mrb_value exc)
 
void mrb_raise (mrb_state *mrb, struct RClass *c, const char *msg)
 
void mrb_raisef (mrb_state *mrb, struct RClass *c, const char *fmt,...)
 
void mrb_name_error (mrb_state *mrb, mrb_sym id, const char *fmt,...)
 
void mrb_frozen_error (mrb_state *mrb, void *frozen_obj)
 
void mrb_argnum_error (mrb_state *mrb, mrb_int argc, int min, int max)
 
void mrb_warn (mrb_state *mrb, const char *fmt,...)
 
void mrb_bug (mrb_state *mrb, const char *fmt,...)
 
void mrb_print_backtrace (mrb_state *mrb)
 
void mrb_print_error (mrb_state *mrb)
 
mrb_value mrb_vformat (mrb_state *mrb, const char *format, va_list ap)
 
mrb_value mrb_yield (mrb_state *mrb, mrb_value b, mrb_value arg)
 
mrb_value mrb_yield_argv (mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv)
 
mrb_value mrb_yield_with_class (mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value *argv, mrb_value self, struct RClass *c)
 
mrb_value mrb_yield_cont (mrb_state *mrb, mrb_value b, mrb_value self, mrb_int argc, const mrb_value *argv)
 
void mrb_gc_protect (mrb_state *mrb, mrb_value obj)
 
void mrb_gc_register (mrb_state *mrb, mrb_value obj)
 
void mrb_gc_unregister (mrb_state *mrb, mrb_value obj)
 
mrb_value mrb_to_int (mrb_state *mrb, mrb_value val)
 
mrb_value mrb_to_str (mrb_state *mrb, mrb_value val)
 
void mrb_check_type (mrb_state *mrb, mrb_value x, enum mrb_vtype t)
 
static void mrb_check_frozen (mrb_state *mrb, void *o)
 
void mrb_define_alias (mrb_state *mrb, struct RClass *c, const char *a, const char *b)
 
void mrb_define_alias_id (mrb_state *mrb, struct RClass *c, mrb_sym a, mrb_sym b)
 
const char * mrb_class_name (mrb_state *mrb, struct RClass *klass)
 
void mrb_define_global_const (mrb_state *mrb, const char *name, mrb_value val)
 
mrb_value mrb_attr_get (mrb_state *mrb, mrb_value obj, mrb_sym id)
 
mrb_bool mrb_respond_to (mrb_state *mrb, mrb_value obj, mrb_sym mid)
 
mrb_bool mrb_obj_is_instance_of (mrb_state *mrb, mrb_value obj, struct RClass *c)
 
mrb_bool mrb_func_basic_p (mrb_state *mrb, mrb_value obj, mrb_sym mid, mrb_func_t func)
 
mrb_value mrb_fiber_resume (mrb_state *mrb, mrb_value fib, mrb_int argc, const mrb_value *argv)
 
mrb_value mrb_fiber_yield (mrb_state *mrb, mrb_int argc, const mrb_value *argv)
 
mrb_value mrb_fiber_alive_p (mrb_state *mrb, mrb_value fib)
 
void mrb_stack_extend (mrb_state *, mrb_int)
 
struct mrb_poolmrb_pool_open (mrb_state *)
 
void mrb_pool_close (struct mrb_pool *)
 
voidmrb_pool_alloc (struct mrb_pool *, size_t)
 
voidmrb_pool_realloc (struct mrb_pool *, void *, size_t oldlen, size_t newlen)
 
mrb_bool mrb_pool_can_realloc (struct mrb_pool *, void *, size_t)
 
voidmrb_alloca (mrb_state *mrb, size_t)
 
void mrb_state_atexit (mrb_state *mrb, mrb_atexit_func func)
 
void mrb_show_version (mrb_state *mrb)
 
void mrb_show_copyright (mrb_state *mrb)
 
mrb_value mrb_format (mrb_state *mrb, const char *format,...)
 

Macro Definition Documentation

◆ _mrb_static_assert_cat

#define _mrb_static_assert_cat (   a,
  b 
)    _mrb_static_assert_cat0(a, b)

Definition at line 80 of file mruby.h.

◆ _mrb_static_assert_cat0

#define _mrb_static_assert_cat0 (   a,
  b 
)    a##b

Definition at line 79 of file mruby.h.

◆ _mrb_static_assert_id

#define _mrb_static_assert_id (   prefix)    _mrb_static_assert_cat(prefix, __LINE__)

Definition at line 84 of file mruby.h.

◆ DBL_EPSILON

#define DBL_EPSILON   ((double)2.22044604925031308085e-16L)

Definition at line 104 of file mruby.h.

◆ E_ARGUMENT_ERROR

#define E_ARGUMENT_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(ArgumentError))

Definition at line 1310 of file mruby.h.

◆ E_FIBER_ERROR

#define E_FIBER_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(FiberError))

FiberError reference

Implemented in mruby-fiber

Definition at line 1391 of file mruby.h.

◆ E_FLOATDOMAIN_ERROR

#define E_FLOATDOMAIN_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(FloatDomainError))

Definition at line 1323 of file mruby.h.

◆ E_FROZEN_ERROR

#define E_FROZEN_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(FrozenError))

Definition at line 1319 of file mruby.h.

◆ E_INDEX_ERROR

#define E_INDEX_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(IndexError))

Definition at line 1311 of file mruby.h.

◆ E_KEY_ERROR

#define E_KEY_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(KeyError))

Definition at line 1321 of file mruby.h.

◆ E_LOCALJUMP_ERROR

#define E_LOCALJUMP_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(LocalJumpError))

Definition at line 1317 of file mruby.h.

◆ E_NAME_ERROR

#define E_NAME_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(NameError))

Definition at line 1313 of file mruby.h.

◆ E_NOMETHOD_ERROR

#define E_NOMETHOD_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(NoMethodError))

Definition at line 1314 of file mruby.h.

◆ E_NOTIMP_ERROR

#define E_NOTIMP_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(NotImplementedError))

Definition at line 1320 of file mruby.h.

◆ E_RANGE_ERROR

#define E_RANGE_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(RangeError))

Definition at line 1312 of file mruby.h.

◆ E_REGEXP_ERROR

#define E_REGEXP_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(RegexpError))

Definition at line 1318 of file mruby.h.

◆ E_RUNTIME_ERROR

#define E_RUNTIME_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(RuntimeError))

Definition at line 1307 of file mruby.h.

◆ E_SCRIPT_ERROR

#define E_SCRIPT_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(ScriptError))

Definition at line 1315 of file mruby.h.

◆ E_SYNTAX_ERROR

#define E_SYNTAX_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(SyntaxError))

Definition at line 1316 of file mruby.h.

◆ E_TYPE_ERROR

#define E_TYPE_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(TypeError))

Definition at line 1308 of file mruby.h.

◆ E_ZERODIV_ERROR

#define E_ZERODIV_ERROR   mrb_exc_get_id(mrb, MRB_ERROR_SYM(ZeroDivisionError))

Definition at line 1309 of file mruby.h.

◆ FLT_EPSILON

#define FLT_EPSILON   (1.19209290e-07f)

Definition at line 101 of file mruby.h.

◆ ISALNUM

#define ISALNUM (   c)    (ISALPHA(c) || ISDIGIT(c))

Definition at line 1279 of file mruby.h.

◆ ISALPHA

#define ISALPHA (   c)    ((((unsigned)(c) | 0x20) - 'a') < 26)

Definition at line 1276 of file mruby.h.

◆ ISASCII

#define ISASCII (   c)    ((unsigned)(c) <= 0x7f)

Definition at line 1271 of file mruby.h.

◆ ISBLANK

#define ISBLANK (   c)    ((c) == ' ' || (c) == '\t')

Definition at line 1280 of file mruby.h.

◆ ISCNTRL

#define ISCNTRL (   c)    ((unsigned)(c) < 0x20 || (c) == 0x7f)

Definition at line 1281 of file mruby.h.

◆ ISDIGIT

#define ISDIGIT (   c)    (((unsigned)(c) - '0') < 10)

Definition at line 1277 of file mruby.h.

◆ ISLOWER

#define ISLOWER (   c)    (((unsigned)(c) - 'a') < 26)

Definition at line 1275 of file mruby.h.

◆ ISPRINT

#define ISPRINT (   c)    (((unsigned)(c) - 0x20) < 0x5f)

Definition at line 1272 of file mruby.h.

◆ ISSPACE

#define ISSPACE (   c)    ((c) == ' ' || (unsigned)(c) - '\t' < 5)

Definition at line 1273 of file mruby.h.

◆ ISUPPER

#define ISUPPER (   c)    (((unsigned)(c) - 'A') < 26)

Definition at line 1274 of file mruby.h.

◆ ISXDIGIT

#define ISXDIGIT (   c)    (ISDIGIT(c) || ((unsigned)(c) | 0x20) - 'a' < 6)

Definition at line 1278 of file mruby.h.

◆ LDBL_EPSILON

#define LDBL_EPSILON   (1.08420217248550443401e-19L)

Definition at line 107 of file mruby.h.

◆ MRB_ARGS_ANY

#define MRB_ARGS_ANY ( )    MRB_ARGS_REST()

Function accepts any number of arguments

Definition at line 874 of file mruby.h.

◆ MRB_ARGS_ARG

#define MRB_ARGS_ARG (   n1,
  n2 
)    (MRB_ARGS_REQ(n1)|MRB_ARGS_OPT(n2))

Function takes n1 mandatory arguments and n2 optional arguments

Parameters
n1The number of required arguments.
n2The number of optional arguments.

Definition at line 855 of file mruby.h.

◆ MRB_ARGS_BLOCK

#define MRB_ARGS_BLOCK ( )    ((mrb_aspec)1)

Function takes a block argument

Definition at line 869 of file mruby.h.

◆ MRB_ARGS_KEY

#define MRB_ARGS_KEY (   n1,
  n2 
)    ((mrb_aspec)((((n1)&0x1f) << 2) | ((n2)?(1<<1):0)))

keyword arguments (n of keys, kdict)

Definition at line 864 of file mruby.h.

◆ MRB_ARGS_NONE

#define MRB_ARGS_NONE ( )    ((mrb_aspec)0)

Function accepts no arguments

Definition at line 879 of file mruby.h.

◆ MRB_ARGS_OPT

#define MRB_ARGS_OPT (   n)    ((mrb_aspec)((n)&0x1f) << 13)

Function takes n optional arguments

Parameters
nThe number of optional arguments.

Definition at line 845 of file mruby.h.

◆ MRB_ARGS_POST

#define MRB_ARGS_POST (   n)    ((mrb_aspec)((n)&0x1f) << 7)

required arguments after rest

Definition at line 861 of file mruby.h.

◆ MRB_ARGS_REQ

#define MRB_ARGS_REQ (   n)    ((mrb_aspec)((n)&0x1f) << 18)

Function requires n arguments.

Parameters
nThe number of required arguments.

Definition at line 837 of file mruby.h.

◆ MRB_ARGS_REST

#define MRB_ARGS_REST ( )    ((mrb_aspec)(1 << 12))

rest argument

Definition at line 858 of file mruby.h.

◆ mrb_assert

#define mrb_assert (   p)    ((void)0)

Definition at line 65 of file mruby.h.

◆ mrb_assert_int_fit

#define mrb_assert_int_fit (   t1,
  n,
  t2,
  max 
)    ((void)0)

Definition at line 66 of file mruby.h.

◆ mrb_check_convert_type

#define mrb_check_convert_type (   mrb,
  val,
  type,
  tname,
  method 
)    mrb_type_convert_check(mrb, val, type, mrb_intern_lit(mrb, method))

Definition at line 1260 of file mruby.h.

◆ mrb_context_run

#define mrb_context_run (   m,
  p,
  s,
  k 
)    mrb_vm_run((m),(p),(s),(k))

Definition at line 1213 of file mruby.h.

◆ mrb_convert_type

#define mrb_convert_type (   mrb,
  val,
  type,
  tname,
  method 
)    mrb_type_convert(mrb, val, type, mrb_intern_lit(mrb, method))

Definition at line 1258 of file mruby.h.

◆ MRB_ERROR_SYM

#define MRB_ERROR_SYM (   sym)    mrb_intern_lit(mrb, #sym)

Definition at line 1306 of file mruby.h.

◆ mrb_exc_get

#define mrb_exc_get (   mrb,
  name 
)    mrb_exc_get_id(mrb, mrb_intern_cstr(mrb, name))

Definition at line 694 of file mruby.h.

◆ mrb_field_write_barrier_value

#define mrb_field_write_barrier_value (   mrb,
  obj,
  val 
)
Value:
do{\
} while (0)
#define mrb_immediate_p(o)
Definition: boxing_word.h:117
void mrb_field_write_barrier(mrb_state *, struct RBasic *, struct RBasic *)
Definition: gc.c:1345
#define mrb_basic_ptr(v)
Definition: object.h:22
Definition: strexpr.c:21

Definition at line 1252 of file mruby.h.

◆ MRB_FIXED_STATE_ATEXIT_STACK_SIZE

#define MRB_FIXED_STATE_ATEXIT_STACK_SIZE   5

Definition at line 148 of file mruby.h.

◆ MRB_FLOAT_EPSILON

#define MRB_FLOAT_EPSILON   DBL_EPSILON

Definition at line 113 of file mruby.h.

◆ mrb_gc_mark_value

#define mrb_gc_mark_value (   mrb,
  val 
)
Value:
do {\
} while (0)
void mrb_gc_mark(mrb_state *, struct RBasic *)
Definition: gc.c:786

Definition at line 1248 of file mruby.h.

◆ mrb_int

#define mrb_int (   mrb,
  val 
)    mrb_integer(mrb_to_int(mrb, val))

Definition at line 1343 of file mruby.h.

◆ mrb_intern_lit

#define mrb_intern_lit (   mrb,
  lit 
)    mrb_intern_static(mrb, (lit ""), mrb_strlen_lit(lit))

Definition at line 1102 of file mruby.h.

◆ mrb_locale_free

#define mrb_locale_free (   p)

Definition at line 1152 of file mruby.h.

◆ mrb_locale_from_utf8

#define mrb_locale_from_utf8 (   p,
 
)    ((char*)(p))

Definition at line 1151 of file mruby.h.

◆ MRB_METHOD_CACHE_SIZE

#define MRB_METHOD_CACHE_SIZE   (1<<8)

Definition at line 191 of file mruby.h.

◆ mrb_static_assert

#define mrb_static_assert (   exp,
  str 
)     struct _mrb_static_assert_id(_mrb_static_assert_) { char x[(exp) ? 1 : -1]; }

Definition at line 86 of file mruby.h.

◆ mrb_static_assert1

#define mrb_static_assert1 (   exp)    mrb_static_assert(exp, #exp)

Definition at line 89 of file mruby.h.

◆ mrb_str_new_cstr_frozen

#define mrb_str_new_cstr_frozen (   mrb,
  p 
)    mrb_obj_freeze(mrb,mrb_str_new_cstr(mrb,p))

Definition at line 1140 of file mruby.h.

◆ mrb_str_new_frozen

#define mrb_str_new_frozen (   mrb,
  p,
  len 
)    mrb_obj_freeze(mrb,mrb_str_new(mrb,p,len))

Definition at line 1139 of file mruby.h.

◆ mrb_str_new_lit

#define mrb_str_new_lit (   mrb,
  lit 
)    mrb_str_new_static(mrb, (lit), mrb_strlen_lit(lit))

Definition at line 1136 of file mruby.h.

◆ mrb_str_new_lit_frozen

#define mrb_str_new_lit_frozen (   mrb,
  lit 
)    mrb_obj_freeze(mrb,mrb_str_new_lit(mrb,lit))

Definition at line 1142 of file mruby.h.

◆ mrb_str_new_static_frozen

#define mrb_str_new_static_frozen (   mrb,
  p,
  len 
)    mrb_obj_freeze(mrb,mrb_str_new_static(mrb,p,len))

Definition at line 1141 of file mruby.h.

◆ mrb_strlen_lit

#define mrb_strlen_lit (   lit)    (sizeof(lit "") - 1)

Definition at line 1013 of file mruby.h.

◆ mrb_sym2name

#define mrb_sym2name (   mrb,
  sym 
)    mrb_sym_name(mrb,sym)

Definition at line 1117 of file mruby.h.

◆ mrb_sym2name_len

#define mrb_sym2name_len (   mrb,
  sym,
  len 
)    mrb_sym_name_len(mrb,sym,len)

Definition at line 1118 of file mruby.h.

◆ mrb_sym2str

#define mrb_sym2str (   mrb,
  sym 
)    mrb_sym_str(mrb,sym)

Definition at line 1119 of file mruby.h.

◆ mrb_toplevel_run

#define mrb_toplevel_run (   m,
  p 
)    mrb_toplevel_run_keep((m),(p),0)

Definition at line 1212 of file mruby.h.

◆ mrb_toplevel_run_keep

#define mrb_toplevel_run_keep (   m,
  p,
  k 
)    mrb_top_run((m),(p),mrb_top_self(m),(k))

Definition at line 1211 of file mruby.h.

◆ mrb_utf8_free

#define mrb_utf8_free (   p)

Definition at line 1153 of file mruby.h.

◆ mrb_utf8_from_locale

#define mrb_utf8_from_locale (   p,
 
)    ((char*)(p))

Definition at line 1150 of file mruby.h.

◆ TOLOWER

#define TOLOWER (   c)    (ISUPPER(c) ? ((c) | 0x20) : (c))

Definition at line 1283 of file mruby.h.

◆ TOUPPER

#define TOUPPER (   c)    (ISLOWER(c) ? ((c) & 0x5f) : (c))

Definition at line 1282 of file mruby.h.

Typedef Documentation

◆ mrb_allocf

typedef void*(* mrb_allocf) (struct mrb_state *mrb, void *, size_t, void *ud)

Function pointer type of custom allocator used in

See also
mrb_open_allocf.

The function pointing it must behave similarly as realloc except:

  • If ptr is NULL it must allocate new space.
  • If s is NULL, ptr must be freed.

See

See also
mrb_default_allocf for the default implementation.

Definition at line 145 of file mruby.h.

◆ mrb_args_format

typedef const char* mrb_args_format

Format specifiers for {mrb_get_args} function

Must be a C string composed of the following format specifiers:

char Ruby type C types Notes
o {Object} {mrb_value} Could be used to retrieve any type of argument
C {Class}/{Module} {mrb_value}
S {String} {mrb_value} when ! follows, the value may be nil
A {Array} {mrb_value} when ! follows, the value may be nil
H {Hash} {mrb_value} when ! follows, the value may be nil
s {String} const char *, {mrb_int} Receive two arguments; s! gives (NULL,0) for nil
z {String} const char * NULL terminated string; z! gives NULL for nil
a {Array} const {mrb_value} *, {mrb_int} Receive two arguments; a! gives (NULL,0) for nil
f {Integer}/{Float} {mrb_float}
i {Integer}/{Float} {mrb_int}
b boolean {mrb_bool}
n {String}/{Symbol} {mrb_sym}
d data void *, {mrb_data_type} const 2nd argument will be used to check data type so it won't be modified; when ! follows, the value may be nil
I inline struct void *
& block {mrb_value} &! raises exception if no block given.
* rest arguments const {mrb_value} *, {mrb_int} Receive the rest of arguments as an array; *! avoid copy of the stack.
| optional After this spec following specs would be optional.
? optional given {mrb_bool} TRUE if preceding argument is given. Used to check optional argument is given.
: keyword args {mrb_kwargs} const Get keyword arguments.
See also
mrb_kwargs
See also
mrb_get_args

Definition at line 910 of file mruby.h.

◆ mrb_aspec

Definition at line 131 of file mruby.h.

◆ mrb_atexit_func

typedef void(* mrb_atexit_func) (struct mrb_state *)

Definition at line 227 of file mruby.h.

◆ mrb_code

typedef uint8_t mrb_code

MRuby C API entry point

Definition at line 122 of file mruby.h.

◆ mrb_func_t

typedef mrb_value(* mrb_func_t) (struct mrb_state *mrb, mrb_value self)

Function pointer type for a function callable by mruby.

The arguments to the function are stored on the mrb_state. To get them see mrb_get_args

Parameters
mrbThe mruby state
selfThe self object
Returns
[mrb_value] The function's return value

Definition at line 203 of file mruby.h.

◆ mrb_kwargs

typedef struct mrb_kwargs mrb_kwargs

Get keyword arguments by mrb_get_args() with : specifier.

mrb_kwargs::num indicates that the number of keyword values.

mrb_kwargs::values is an object array, and the keyword argument corresponding to the string array is assigned. Note that undef is assigned if there is no keyword argument corresponding to mrb_kwargs::optional.

mrb_kwargs::table accepts a string array.

mrb_kwargs::required indicates that the specified number of keywords starting from the beginning of the string array are required.

mrb_kwargs::rest is the remaining keyword argument that can be accepted as **rest in Ruby. If NULL is specified, ArgumentError is raised when there is an undefined keyword.

Examples:

 // def method(a: 1, b: 2)

 uint32_t kw_num = 2;
 const char *kw_names[kw_num] = { "a", "b" };
 uint32_t kw_required = 0;
 mrb_value kw_values[kw_num];
 const mrb_kwargs kwargs = { kw_num, kw_required, kw_names, kw_values, NULL };

 mrb_get_args(mrb, ":", &kwargs);
 if (mrb_undef_p(kw_values[0])) { kw_values[0] = mrb_fixnum_value(1); }
 if (mrb_undef_p(kw_values[1])) { kw_values[1] = mrb_fixnum_value(2); }


 // def method(str, x:, y: 2, z: "default string", **opts)

 mrb_value str, kw_rest;
 uint32_t kw_num = 3;
 const mrb_sym kw_names[kw_num] = { MRB_SYM(x), MRB_SYM(y), MRB_SYM(z) };
 uint32_t kw_required = 1;
 mrb_value kw_values[kw_num];
 const mrb_kwargs kwargs = { kw_num, kw_required, kw_names, kw_values, &kw_rest };

 mrb_get_args(mrb, "S:", &str, &kwargs);
 // or: mrb_get_args(mrb, ":S", &kwargs, &str);
 if (mrb_undef_p(kw_values[1])) { kw_values[1] = mrb_fixnum_value(2); }
 if (mrb_undef_p(kw_values[2])) { kw_values[2] = mrb_str_new_cstr(mrb, "default string"); }

Definition at line 910 of file mruby.h.

◆ mrb_method_t

Definition at line 206 of file mruby.h.

◆ mrb_pool

typedef struct mrb_pool mrb_pool

Definition at line 1392 of file mruby.h.

◆ mrb_state

typedef struct mrb_state mrb_state

Enumeration Type Documentation

◆ mrb_fiber_state

Enumerator
MRB_FIBER_CREATED 
MRB_FIBER_RUNNING 
MRB_FIBER_RESUMED 
MRB_FIBER_SUSPENDED 
MRB_FIBER_TRANSFERRED 
MRB_FIBER_TERMINATED 

Definition at line 164 of file mruby.h.

Function Documentation

◆ mrb_alloca()

void* mrb_alloca ( mrb_state mrb,
size_t  size 
)

Definition at line 294 of file gc.c.

References mrb_malloc(), mrb_obj_alloc(), MRB_TT_STRING, s, size, and mrb_state::string_class.

Referenced by prepare_name_common().

◆ mrb_any_to_s()

◆ mrb_argnum_error()

◆ mrb_attr_get()

mrb_value mrb_attr_get ( mrb_state mrb,
mrb_value  obj,
mrb_sym  id 
)

Definition at line 1024 of file variable.c.

References mrb_iv_get().

Referenced by exc_to_s(), and mrb_exc_inspect().

◆ mrb_bug()

void mrb_bug ( mrb_state mrb,
const char *  fmt,
  ... 
)

◆ mrb_calloc()

void* mrb_calloc ( mrb_state mrb,
size_t  nelem,
size_t  len 
)

◆ mrb_check_frozen()

◆ mrb_check_intern()

mrb_value mrb_check_intern ( mrb_state mrb,
const char *  name,
size_t  len 
)

Definition at line 268 of file symbol.c.

References len, mrb_intern_check(), mrb_nil_value(), mrb_symbol_value(), name, and sym.

◆ mrb_check_intern_cstr()

mrb_value mrb_check_intern_cstr ( mrb_state mrb,
const char *  name 
)

Definition at line 282 of file symbol.c.

References mrb_intern_check_cstr(), mrb_nil_value(), mrb_symbol_value(), name, and sym.

◆ mrb_check_intern_str()

mrb_value mrb_check_intern_str ( mrb_state mrb,
mrb_value  str 
)

Definition at line 296 of file symbol.c.

References mrb_intern_check_str(), mrb_nil_value(), mrb_symbol_value(), str, and sym.

◆ mrb_check_type()

◆ mrb_class_defined()

mrb_bool mrb_class_defined ( mrb_state mrb,
const char *  name 
)

Returns an mrb_bool. True if class was defined, and false if the class was not defined.

Example: void mrb_example_gem_init(mrb_state* mrb) { struct RClass *example_class; mrb_bool cd;

example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class); cd = mrb_class_defined(mrb, "ExampleClass");

// If mrb_class_defined returns 1 then puts "True" // If mrb_class_defined returns 0 then puts "False" if (cd == 1){ puts("True"); } else { puts("False"); } }

Parameters
mrbThe current mruby state.
nameA string representing the name of the class.
Returns
[mrb_bool] A boolean value.

Definition at line 593 of file class.c.

References FALSE, mrb_const_defined(), mrb_intern_check_cstr(), mrb_obj_value(), name, mrb_state::object_class, and sym.

Referenced by compare_break_method(), and mrb_sys_fail().

◆ mrb_class_defined_id()

mrb_bool mrb_class_defined_id ( mrb_state mrb,
mrb_sym  name 
)

Definition at line 601 of file class.c.

References mrb_const_defined(), mrb_obj_value(), name, and mrb_state::object_class.

Referenced by io_set_process_status().

◆ mrb_class_defined_under()

mrb_bool mrb_class_defined_under ( mrb_state mrb,
struct RClass outer,
const char *  name 
)

Returns an mrb_bool. True if inner class was defined, and false if the inner class was not defined.

Example: void mrb_example_gem_init(mrb_state* mrb) { struct RClass *example_outer, *example_inner; mrb_bool cd;

example_outer = mrb_define_module(mrb, "ExampleOuter");

example_inner = mrb_define_class_under(mrb, example_outer, "ExampleInner", mrb->object_class); cd = mrb_class_defined_under(mrb, example_outer, "ExampleInner");

// If mrb_class_defined_under returns 1 then puts "True" // If mrb_class_defined_under returns 0 then puts "False" if (cd == 1){ puts("True"); } else { puts("False"); } }

Parameters
mrbThe current mruby state.
outerThe name of the outer class.
nameA string representing the name of the inner class.
Returns
[mrb_bool] A boolean value.

Definition at line 607 of file class.c.

References FALSE, mrb_const_defined_at(), mrb_intern_check_cstr(), mrb_obj_value(), name, and sym.

◆ mrb_class_defined_under_id()

mrb_bool mrb_class_defined_under_id ( mrb_state mrb,
struct RClass outer,
mrb_sym  name 
)

Definition at line 615 of file class.c.

References mrb_const_defined_at(), mrb_obj_value(), and name.

◆ mrb_class_get()

struct RClass* mrb_class_get ( mrb_state mrb,
const char *  name 
)

Gets a class.

Parameters
mrbThe current mruby state.
nameThe name of the class.
Returns
[struct RClass *] A reference to the class.

Definition at line 633 of file class.c.

References mrb_class_get_under(), name, and mrb_state::object_class.

Referenced by compare_break_method(), method_unbind(), mrb_init_file(), mrb_kernel_method(), mrb_module_instance_method(), mrb_mruby_numeric_ext_gem_init(), mrb_mruby_range_ext_gem_init(), mrb_mruby_string_ext_gem_init(), mrb_stat0(), mrb_sys_fail(), obj_is_kind_of_checked(), and random_default().

◆ mrb_class_get_id()

◆ mrb_class_get_under()

struct RClass* mrb_class_get_under ( mrb_state mrb,
struct RClass outer,
const char *  name 
)

Gets a child class.

Parameters
mrbThe current mruby state.
outerThe name of the parent class.
nameThe name of the class.
Returns
[struct RClass *] A reference to the class.

Definition at line 621 of file class.c.

References class_from_sym(), mrb_intern_cstr, and name.

Referenced by mrb_class_get().

◆ mrb_class_get_under_id()

struct RClass* mrb_class_get_under_id ( mrb_state mrb,
struct RClass outer,
mrb_sym  name 
)

Definition at line 627 of file class.c.

References class_from_sym(), and name.

Referenced by domain_error(), io_set_process_status(), and mrb_class_get_id().

◆ mrb_class_name()

const char* mrb_class_name ( mrb_state mrb,
struct RClass klass 
)

Definition at line 2102 of file class.c.

References c, class_name_str(), name, NULL, and RSTRING_PTR.

Referenced by compare_break_method(), method_to_s(), mrb_class_find_path(), and mrb_obj_classname().

◆ mrb_class_new()

struct RClass* mrb_class_new ( mrb_state mrb,
struct RClass super 
)

Creates a new instance of Class, Class.

Example:

 void
 mrb_example_gem_init(mrb_state* mrb) {
   struct RClass *example_class;

   mrb_value obj;
   example_class = mrb_class_new(mrb, mrb->object_class);
   obj = mrb_obj_new(mrb, example_class, 0, NULL); // => #<#<Class:0x9a945b8>:0x9a94588>
   mrb_p(mrb, obj); // => Kernel#p
  }
Parameters
mrbThe current mruby state.
superThe super class or parent.
Returns
[struct RClass *] Reference to the new class.

Creates a new class.

Parameters
supera class from which the new class derives.
Exceptions
TypeErrorsuper is not inheritable.
TypeErrorsuper is the Class class.

Definition at line 2144 of file class.c.

References boot_defclass(), c, make_metaclass, mrb_check_inheritable(), MRB_INSTANCE_TT, MRB_SET_INSTANCE_TT, and RClass::super.

Referenced by define_class(), make_struct(), and mrb_class_new_class().

◆ mrb_class_new_instance()

static mrb_value mrb_class_new_instance ( mrb_state mrb,
mrb_int  argc,
const mrb_value argv,
struct RClass c 
)
inlinestatic
See also
mrb_obj_new

Definition at line 607 of file mruby.h.

References argc, argv, c, and mrb_obj_new().

◆ mrb_class_path()

mrb_value mrb_class_path ( mrb_state mrb,
struct RClass c 
)

◆ mrb_close()

◆ mrb_cmp()

◆ mrb_convert_to_integer()

◆ mrb_default_allocf()

void* mrb_default_allocf ( mrb_state mrb,
void p,
size_t  size,
void ud 
)

The default allocation function.

See also
mrb_allocf

Definition at line 61 of file state.c.

References free, NULL, p, realloc, and size.

Referenced by main(), mrb_open(), and mrb_open_core().

◆ mrb_define_alias()

void mrb_define_alias ( mrb_state mrb,
struct RClass klass,
const char *  name1,
const char *  name2 
)

Defines an alias of a method.

Parameters
mrbthe mruby state
klassthe class which the original method belongs to
name1a new name for the method
name2the original name of the method

Definition at line 2226 of file class.c.

References mrb_alias_method(), and mrb_intern_cstr.

◆ mrb_define_alias_id()

void mrb_define_alias_id ( mrb_state mrb,
struct RClass c,
mrb_sym  a,
mrb_sym  b 
)

Definition at line 2232 of file class.c.

References a, b, and mrb_alias_method().

◆ mrb_define_class()

struct RClass* mrb_define_class ( mrb_state mrb,
const char *  name,
struct RClass super 
)

Defines a new class.

If you're creating a gem it may look something like this:

 !!!c
 void mrb_example_gem_init(mrb_state* mrb) {
     struct RClass *example_class;
     example_class = mrb_define_class(mrb, "Example_Class", mrb->object_class);
 }

 void mrb_example_gem_final(mrb_state* mrb) {
     //free(TheAnimals);
 }
Parameters
mrbThe current mruby state.
nameThe name of the defined class.
superThe new class parent.
Returns
[struct RClass *] Reference to the newly defined class.
See also
mrb_define_class_under

Definition at line 525 of file class.c.

References mrb_define_class_id(), mrb_intern_cstr, name, and RClass::super.

Referenced by mrb_init_class().

◆ mrb_define_class_id()

struct RClass* mrb_define_class_id ( mrb_state mrb,
mrb_sym  name,
struct RClass super 
)

◆ mrb_define_class_method()

void mrb_define_class_method ( mrb_state mrb,
struct RClass cla,
const char *  name,
mrb_func_t  fun,
mrb_aspec  aspec 
)

Defines a class method.

Example:

# Ruby style
class Foo
  def Foo.bar
  end
end
// C style
mrb_value bar_method(mrb_state* mrb, mrb_value self){
  return mrb_nil_value();
}
void mrb_example_gem_init(mrb_state* mrb){
  struct RClass *foo;
  foo = mrb_define_class(mrb, "Foo", mrb->object_class);
  mrb_define_class_method(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
}
Parameters
mrbThe MRuby state reference.
claThe class where the class method will be defined.
nameThe name of the class method being defined.
funThe function pointer to the class method definition.
aspecThe method parameters declaration.

Definition at line 1682 of file class.c.

References c, func, mrb_define_singleton_method(), and name.

Referenced by mrb_init_class().

◆ mrb_define_class_method_id()

void mrb_define_class_method_id ( mrb_state mrb,
struct RClass cla,
mrb_sym  name,
mrb_func_t  fun,
mrb_aspec  aspec 
)

Definition at line 1688 of file class.c.

References c, func, mrb_define_singleton_method_id(), and name.

Referenced by mrb_define_module_function_id().

◆ mrb_define_class_under()

struct RClass* mrb_define_class_under ( mrb_state mrb,
struct RClass outer,
const char *  name,
struct RClass super 
)

Defines a new class under a given module

Parameters
mrbThe current mruby state.
outerReference to the module under which the new class will be defined
nameThe name of the defined class
superThe new class parent
Returns
[struct RClass *] Reference to the newly defined class
See also
mrb_define_class

Definition at line 719 of file class.c.

References mrb_define_class_under_id(), mrb_intern_cstr, name, and RClass::super.

◆ mrb_define_class_under_id()

struct RClass* mrb_define_class_under_id ( mrb_state mrb,
struct RClass outer,
mrb_sym  name,
struct RClass super 
)

Defines a class under the namespace of outer.

Parameters
outera class which contains the new class.
namename of the new class
supera class from which the new class will derive. NULL means Object class.
Returns
the created class
Exceptions
TypeErrorif the constant name name is already taken but the constant is not a Class.
NameErrorif the class is already defined but the class can not be reopened because its superclass is not super.
Postcondition
top-level constant named name refers the returned class.
Note
if a class named name is already defined and its superclass is super, the function just returns the defined class.

Definition at line 704 of file class.c.

References c, define_class(), mrb_warn(), name, setup_class(), and RClass::super.

Referenced by mrb_define_class_under(), and mrb_mruby_math_gem_init().

◆ mrb_define_const()

void mrb_define_const ( mrb_state mrb,
struct RClass cla,
const char *  name,
mrb_value  val 
)

Defines a constant.

Example:

     # Ruby style
     class ExampleClass
       AGE = 22
     end
     // C style
     #include <stdio.h>
     #include <mruby.h>

     void
     mrb_example_gem_init(mrb_state* mrb){
       mrb_define_const(mrb, mrb->kernel_module, "AGE", mrb_fixnum_value(22));
     }

     mrb_value
     mrb_example_gem_final(mrb_state* mrb){
     }
Parameters
mrbThe MRuby state reference.
claA class or module the constant is defined in.
nameThe name of the constant being defined.
valThe value for the constant.

Definition at line 870 of file variable.c.

References mod(), mrb_intern_cstr, mrb_obj_iv_set(), name, and v.

Referenced by mrb_define_global_const().

◆ mrb_define_const_id()

void mrb_define_const_id ( mrb_state mrb,
struct RClass cla,
mrb_sym  name,
mrb_value  val 
)

◆ mrb_define_global_const()

void mrb_define_global_const ( mrb_state mrb,
const char *  name,
mrb_value  val 
)

Definition at line 876 of file variable.c.

References mrb_define_const(), name, and mrb_state::object_class.

◆ mrb_define_method()

void mrb_define_method ( mrb_state mrb,
struct RClass cla,
const char *  name,
mrb_func_t  func,
mrb_aspec  aspec 
)

Defines a global function in ruby.

If you're creating a gem it may look something like this

Example:

mrb_value example_method(mrb_state* mrb, mrb_value self)
{
     puts("Executing example command!");
     return self;
}

void mrb_example_gem_init(mrb_state* mrb)
{
      mrb_define_method(mrb, mrb->kernel_module, "example_method", example_method, MRB_ARGS_NONE());
}
Parameters
mrbThe MRuby state reference.
claThe class pointer where the method will be defined.
nameThe name of the method being defined.
funcThe function pointer to the method definition.
aspecThe method parameters declaration.

Definition at line 772 of file class.c.

References c, func, mrb_define_method_id(), mrb_intern_cstr, and name.

Referenced by mrb_init_class(), and mrb_mruby_class_ext_gem_init().

◆ mrb_define_method_id()

◆ mrb_define_module()

struct RClass* mrb_define_module ( mrb_state mrb,
const char *  name 
)

Defines a new module.

Parameters
mrbThe current mruby state.
nameThe name of the module.
Returns
[struct RClass *] Reference to the newly defined module.

Definition at line 448 of file class.c.

References define_module(), mrb_intern_cstr, name, and mrb_state::object_class.

◆ mrb_define_module_function()

void mrb_define_module_function ( mrb_state mrb,
struct RClass cla,
const char *  name,
mrb_func_t  fun,
mrb_aspec  aspec 
)

Defines a module function.

Example:

   # Ruby style
   module Foo
     def Foo.bar
     end
   end
   // C style
   mrb_value bar_method(mrb_state* mrb, mrb_value self){
     return mrb_nil_value();
   }
   void mrb_example_gem_init(mrb_state* mrb){
     struct RClass *foo;
     foo = mrb_define_module(mrb, "Foo");
     mrb_define_module_function(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
   }
Parameters
mrbThe MRuby state reference.
claThe module where the module function will be defined.
nameThe name of the module function being defined.
funThe function pointer to the module function definition.
aspecThe method parameters declaration.

Definition at line 1701 of file class.c.

References c, func, mrb_define_module_function_id(), mrb_intern_cstr, and name.

◆ mrb_define_module_function_id()

void mrb_define_module_function_id ( mrb_state mrb,
struct RClass cla,
mrb_sym  name,
mrb_func_t  fun,
mrb_aspec  aspec 
)

Definition at line 1694 of file class.c.

References c, func, mrb_define_class_method_id(), mrb_define_method_id(), and name.

Referenced by mrb_define_module_function().

◆ mrb_define_module_id()

struct RClass* mrb_define_module_id ( mrb_state mrb,
mrb_sym  name 
)

Definition at line 442 of file class.c.

References define_module(), name, and mrb_state::object_class.

◆ mrb_define_module_under()

struct RClass* mrb_define_module_under ( mrb_state mrb,
struct RClass outer,
const char *  name 
)

Definition at line 478 of file class.c.

References c, define_module(), mrb_intern_cstr, name, and setup_class().

◆ mrb_define_module_under_id()

struct RClass* mrb_define_module_under_id ( mrb_state mrb,
struct RClass outer,
mrb_sym  name 
)

Definition at line 469 of file class.c.

References c, define_module(), name, and setup_class().

Referenced by mrb_init_file().

◆ mrb_define_singleton_method()

void mrb_define_singleton_method ( mrb_state mrb,
struct RObject cla,
const char *  name,
mrb_func_t  fun,
mrb_aspec  aspec 
)

Defines a singleton method

See also
mrb_define_class_method

Definition at line 1668 of file class.c.

References RObject::c, func, mrb_define_method_id(), mrb_intern_cstr, name, and prepare_singleton_class().

Referenced by mrb_define_class_method(), and mrb_init_class().

◆ mrb_define_singleton_method_id()

void mrb_define_singleton_method_id ( mrb_state mrb,
struct RObject cla,
mrb_sym  name,
mrb_func_t  fun,
mrb_aspec  aspec 
)

Definition at line 1675 of file class.c.

References RObject::c, func, mrb_define_method_id(), name, and prepare_singleton_class().

Referenced by mrb_define_class_method_id().

◆ mrb_eql()

mrb_bool mrb_eql ( mrb_state mrb,
mrb_value  obj1,
mrb_value  obj2 
)

Definition at line 661 of file object.c.

Referenced by mrb_struct_eql(), obj_eql(), and range_eql().

◆ mrb_equal()

◆ mrb_exc_get_id()

struct RClass* mrb_exc_get_id ( mrb_state mrb,
mrb_sym  name 
)

Gets a exception class.

Parameters
mrbThe current mruby state.
nameThe name of the class.
Returns
[struct RClass *] A reference to the class.

Definition at line 645 of file class.c.

References c, e, mrb_state::eException_class, mrb_class_p, mrb_class_ptr, mrb_const_get(), mrb_obj_value(), mrb_raise(), name, and mrb_state::object_class.

◆ mrb_exc_new()

mrb_value mrb_exc_new ( mrb_state mrb,
struct RClass c,
const char *  ptr,
size_t  len 
)

Definition at line 22 of file error.c.

References c, len, mrb_obj_new(), mrb_str_new(), and ptr.

Referenced by mrb_load_exec(), and mrb_vm_exec().

◆ mrb_exc_raise()

◆ mrb_fiber_alive_p()

mrb_value mrb_fiber_alive_p ( mrb_state mrb,
mrb_value  fib 
)

Check if a Fiber is alive

Implemented in mruby-fiber

Definition at line 288 of file fiber.c.

References c, fiber_check(), mrb_bool_value(), and MRB_FIBER_TERMINATED.

◆ mrb_fiber_resume()

mrb_value mrb_fiber_resume ( mrb_state mrb,
mrb_value  fib,
mrb_int  argc,
const mrb_value argv 
)

Resume a Fiber

Implemented in mruby-fiber

Definition at line 275 of file fiber.c.

References a, mrb_context::fib, fiber_switch(), len, and TRUE.

◆ mrb_fiber_yield()

mrb_value mrb_fiber_yield ( mrb_state mrb,
mrb_int  argc,
const mrb_value argv 
)

◆ mrb_field_write_barrier()

◆ mrb_Float()

◆ mrb_format()

◆ mrb_free()

◆ mrb_frozen_error()

void mrb_frozen_error ( mrb_state mrb,
void frozen_obj 
)

Definition at line 541 of file error.c.

References E_FROZEN_ERROR, mrb_obj_value(), and mrb_raisef().

Referenced by mrb_check_frozen().

◆ mrb_full_gc()

◆ mrb_func_basic_p()

◆ mrb_funcall()

mrb_value mrb_funcall ( mrb_state mrb,
mrb_value  val,
const char *  name,
mrb_int  argc,
  ... 
)

Call existing ruby functions.

Example:

 #include <stdio.h>
 #include <mruby.h>
 #include "mruby/compile.h"

 int
 main()
 {
   mrb_int i = 99;
   mrb_state *mrb = mrb_open();

   if (!mrb) { }
   FILE *fp = fopen("test.rb","r");
   mrb_value obj = mrb_load_file(mrb,fp);
   mrb_funcall(mrb, obj, "method_name", 1, mrb_fixnum_value(i));
   mrb_funcall_id(mrb, obj, MRB_SYM(method_name), 1, mrb_fixnum_value(i));
   fclose(fp);
   mrb_close(mrb);
 }
Parameters
mrbThe current mruby state.
valA reference to an mruby value.
nameThe name of the method.
argcThe number of arguments the method has.
...Variadic values(not type safe!).
Returns
[mrb_value] mruby function value.

Definition at line 317 of file vm.c.

References ap, argc, argv, E_ARGUMENT_ERROR, i, REnv::mid, MRB_FUNCALL_ARGC_MAX, mrb_funcall_argv(), mrb_intern_cstr, mrb_raise(), MRB_STRINGIZE, name, va_arg, va_end, and va_start.

Referenced by mrb_debug_eval(), mrb_obj_ceqq(), and mrb_sys_fail().

◆ mrb_funcall_argv()

mrb_value mrb_funcall_argv ( mrb_state mrb,
mrb_value  val,
mrb_sym  name,
mrb_int  argc,
const mrb_value argv 
)

Call existing ruby functions. This is basically the type safe version of mrb_funcall.

 #include <stdio.h>
 #include <mruby.h>
 #include "mruby/compile.h"
 int
 main()
 {
   mrb_state *mrb = mrb_open();
   mrb_value obj = mrb_fixnum_value(1);

   if (!mrb) { }

   FILE *fp = fopen("test.rb","r");
   mrb_value obj = mrb_load_file(mrb,fp);
   mrb_funcall_argv(mrb, obj, MRB_SYM(method_name), 1, &obj); // Calling ruby function from test.rb.
   fclose(fp);
   mrb_close(mrb);
  }
Parameters
mrbThe current mruby state.
valA reference to an mruby value.
name_symThe symbol representing the method.
argcThe number of arguments the method has.
objPointer to the object.
Returns
[mrb_value] mrb_value mruby function value.
See also
mrb_funcall

Definition at line 481 of file vm.c.

References argc, argv, mrb_funcall_with_block(), and mrb_nil_value().

Referenced by const_get(), convert_type(), mcall(), mrb_class_inherited(), mrb_funcall(), mrb_funcall_id(), mrb_hash_get(), mrb_make_exception(), mrb_obj_ceqq(), mrb_obj_new(), obj_hash_code(), and obj_respond_to().

◆ mrb_funcall_id()

◆ mrb_funcall_with_block()

◆ mrb_garbage_collect()

void mrb_garbage_collect ( mrb_state mrb)

Definition at line 1334 of file gc.c.

References mrb_full_gc().

Referenced by mrb_cloexec_open(), and mrb_pipe().

◆ mrb_gc_arena_restore()

◆ mrb_gc_arena_save()

◆ mrb_gc_mark()

void mrb_gc_mark ( mrb_state mrb,
struct RBasic obj 
)

◆ mrb_gc_protect()

◆ mrb_gc_register()

void mrb_gc_register ( mrb_state mrb,
mrb_value  obj 
)

◆ mrb_gc_unregister()

◆ mrb_get_arg1()

mrb_value mrb_get_arg1 ( mrb_state mrb)

Retrieve the first and only argument from mrb_state. Raises ArgumentError unless the number of arguments is exactly one.

Correctly handles *splat arguments.

Definition at line 840 of file class.c.

References a, mrb_callinfo::argc, argc, ARY_LEN, ARY_PTR, mrb_state::c, mrb_context::ci, mrb_argnum_error(), mrb_ary_ptr, and mrb_callinfo::stack.

Referenced by attr_writer(), complex_div(), exc_set_backtrace(), fiber_eq(), flo_and(), flo_divmod(), flo_eq(), flo_eql(), flo_minus(), flo_mod(), flo_mul(), flo_or(), flo_plus(), flo_pow(), flo_xor(), int_and(), int_divmod(), int_eql(), int_equal(), int_minus(), int_mod(), int_mul(), int_or(), int_plus(), int_pow(), int_xor(), method_eql(), mrb_ary_aget(), mrb_ary_assoc(), mrb_ary_cmp(), mrb_ary_eq(), mrb_ary_index_m(), mrb_ary_rassoc(), mrb_ary_rindex_m(), mrb_ary_slice_bang(), mrb_equal_m(), mrb_f_array(), mrb_f_float(), mrb_f_hash(), mrb_f_string(), mrb_file_truncate(), mrb_filetest_s_directory_p(), mrb_filetest_s_exist_p(), mrb_filetest_s_file_p(), mrb_filetest_s_pipe_p(), mrb_filetest_s_size(), mrb_filetest_s_size_p(), mrb_filetest_s_socket_p(), mrb_filetest_s_symlink_p(), mrb_filetest_s_zero_p(), mrb_hash_aget(), mrb_hash_delete(), mrb_hash_has_key(), mrb_hash_has_value(), mrb_hash_set_default(), mrb_hash_set_default_proc(), mrb_io_initialize_copy(), mrb_mod_const_get(), mrb_mod_eqq(), mrb_mod_extend_object(), mrb_obj_ceqq(), mrb_obj_equal_m(), mrb_obj_init_copy(), mrb_printstr(), mrb_proc_init_copy(), mrb_str_byteslice(), mrb_str_cmp_m(), mrb_str_concat_m(), mrb_str_eql(), mrb_str_equal_m(), mrb_struct_aref(), mrb_struct_eql(), mrb_struct_equal(), mrb_struct_init_copy(), mrb_struct_set_m(), mrb_time_cmp(), mrb_time_eq(), mrb_time_initialize_copy(), mrb_time_minus(), mrb_time_plus(), num_cmp(), num_ge(), num_gt(), num_le(), num_lt(), range_cover(), range_eq(), range_eql(), range_include(), range_initialize_copy(), sym_cmp(), and unbound_method_bind().

◆ mrb_get_argc()

mrb_int mrb_get_argc ( mrb_state mrb)

Retrieve number of arguments from mrb_state.

Correctly handles *splat arguments.

Definition at line 814 of file class.c.

References a, mrb_callinfo::argc, argc, ARY_LEN, mrb_state::c, mrb_context::ci, mrb_ary_ptr, and mrb_callinfo::stack.

Referenced by mrb_ary_aget(), mrb_ary_aset(), mrb_ary_first(), mrb_ary_push_m(), mrb_ary_slice_bang(), mrb_file__gethome(), and mrb_str_byteslice().

◆ mrb_get_args()

mrb_int mrb_get_args ( mrb_state mrb,
mrb_args_format  format,
  ... 
)

Retrieve arguments from mrb_state.

Parameters
mrbThe current MRuby state.
formatis a list of format specifiers
...The passing variadic arguments must be a pointer of retrieving type.
Returns
the number of arguments retrieved.
See also
mrb_args_format
mrb_kwargs

Definition at line 891 of file class.c.

References a, ap, mrb_callinfo::argc, argc, ARGV, argv, ARY_LEN, ARY_PTR, b, bp, mrb_state::c, c, mrb_context::ci, class_ptr_p(), const, E_ARGUMENT_ERROR, E_TYPE_ERROR, FALSE, fmt, format, i, j, k, kname(), mrb_argnum_error(), mrb_ary_new_from_values(), mrb_ary_ptr, mrb_class_ptr, mrb_data_get_ptr(), mrb_gc_protect(), mrb_hash_check_kdict(), mrb_hash_delete_key(), mrb_hash_dup(), mrb_hash_empty_p(), mrb_hash_key_p(), mrb_hash_keys(), mrb_hash_new(), mrb_hash_p, mrb_integer, mrb_istruct_p, mrb_istruct_ptr(), mrb_nil_p, mrb_nil_value(), mrb_raise(), mrb_raisef(), mrb_symbol_value(), mrb_test, mrb_to_flo(), mrb_to_int(), mrb_to_str(), mrb_undef_value(), NULL, mrb_kwargs::num, p, ps, RARRAY, RARRAY_PTR, icutools.databuilder.__main__::required, mrb_kwargs::required, rest, mrb_kwargs::rest, RSTRING_CSTR, RSTRING_LEN, RSTRING_PTR, mrb_callinfo::stack, strchr, mrb_kwargs::table, to_ary(), to_hash(), to_sym, TRUE, type, va_arg, va_end, va_start, gen-indic-table::values, and mrb_kwargs::values.

Referenced by aget_index(), coerce_step_counter(), complex_s_rect(), enum_update_hash(), exc_exception(), exc_initialize(), f_eval(), f_exit(), f_instance_eval(), false_or(), false_xor(), fiber_init(), fiber_resume(), fiber_transfer(), fiber_yield(), flo_div(), flo_idiv(), flo_lshift(), flo_round(), flo_rshift(), gc_generational_mode_set(), gc_interval_ratio_set(), gc_step_ratio_set(), get_opt(), hash_except(), hash_slice(), hash_values_at(), int_div(), int_lshift(), int_pow(), int_quo(), int_rshift(), int_to_s(), math_acos(), math_acosh(), math_asin(), math_asinh(), math_atan(), math_atan2(), math_atanh(), math_cbrt(), math_cos(), math_cosh(), math_erf(), math_erfc(), math_exp(), math_frexp(), math_hypot(), math_ldexp(), math_log(), math_log10(), math_log2(), math_sin(), math_sinh(), math_sqrt(), math_tan(), math_tanh(), method_bcall(), method_call(), mod_attr_define(), mrb_addrinfo_getaddrinfo(), mrb_addrinfo_getnameinfo(), mrb_ary_aget(), mrb_ary_aset(), mrb_ary_at(), mrb_ary_concat_m(), mrb_ary_delete_at(), mrb_ary_first(), mrb_ary_join_m(), mrb_ary_last(), mrb_ary_plus(), mrb_ary_replace_m(), mrb_ary_s_create(), mrb_ary_sample(), mrb_ary_shuffle_bang(), mrb_ary_slice_bang(), mrb_ary_times(), mrb_ary_unshift_m(), mrb_ary_values_at(), mrb_basicsocket_getsockopt(), mrb_basicsocket_recv(), mrb_basicsocket_recvfrom(), mrb_basicsocket_send(), mrb_basicsocket_set_is_socket(), mrb_basicsocket_setnonblock(), mrb_basicsocket_setsockopt(), mrb_basicsocket_shutdown(), mrb_class_initialize(), mrb_class_new_class(), mrb_f_caller(), mrb_f_integer(), mrb_f_raise(), mrb_f_send(), mrb_f_sleep(), mrb_f_sprintf(), mrb_f_usleep(), mrb_file__gethome(), mrb_file_basename(), mrb_file_dirname(), mrb_file_flock(), mrb_file_realpath(), mrb_file_s_chmod(), mrb_file_s_readlink(), mrb_file_s_rename(), mrb_file_s_symlink(), mrb_file_s_umask(), mrb_file_s_unlink(), mrb_hash_aset(), mrb_hash_default(), mrb_hash_init(), mrb_hash_init_copy(), mrb_instance_new(), mrb_int_allbits(), mrb_int_anybits(), mrb_int_chr(), mrb_int_nobits(), mrb_io_bufread(), mrb_io_initialize(), mrb_io_readchar(), mrb_io_s_popen_args(), mrb_io_s_select(), mrb_io_s_sysclose(), mrb_io_s_sysopen(), mrb_io_set_sync(), mrb_io_sysread(), mrb_io_sysseek(), mrb_io_syswrite(), mrb_ipsocket_ntop(), mrb_ipsocket_pton(), mrb_ipsocket_recvfrom(), mrb_kernel_method(), mrb_kernel_proc(), mrb_kpse_brace_expand(), mrb_kpse_find_file(), mrb_kpse_in_name_ok(), mrb_kpse_init_format(), mrb_kpse_init_prog(), mrb_kpse_make_tex(), mrb_kpse_maketex_option(), mrb_kpse_out_name_ok(), mrb_kpse_path_expand(), mrb_kpse_readable_file(), mrb_kpse_reset_program_name(), mrb_kpse_set_program_enabled(), mrb_kpse_set_program_name(), mrb_kpse_tex_hush(), mrb_kpse_var_expand(), mrb_kpse_var_value(), mrb_kpse_xputenv(), mrb_kpse_xputenv_int(), mrb_mod_alias(), mrb_mod_append_features(), mrb_mod_class_variables(), mrb_mod_const_defined(), mrb_mod_const_missing(), mrb_mod_const_set(), mrb_mod_constants(), mrb_mod_cvar_defined(), mrb_mod_cvar_get(), mrb_mod_cvar_set(), mrb_mod_define_method_m(), mrb_mod_include_p(), mrb_mod_initialize(), mrb_mod_instance_methods(), mrb_mod_method_defined(), mrb_mod_module_eval(), mrb_mod_module_exec(), mrb_mod_module_function(), mrb_mod_prepend_features(), mrb_mod_remove_const(), mrb_mod_remove_cvar(), mrb_mod_remove_method(), mrb_mod_undef(), mrb_module_instance_method(), mrb_obj_extend_m(), mrb_obj_instance_eval(), mrb_obj_instance_exec(), mrb_obj_is_kind_of_m(), mrb_obj_ivar_defined(), mrb_obj_ivar_get(), mrb_obj_ivar_set(), mrb_obj_methods_m(), mrb_obj_missing(), mrb_obj_private_methods(), mrb_obj_protected_methods(), mrb_obj_public_methods(), mrb_obj_remove_instance_variable(), mrb_obj_singleton_methods_m(), mrb_print(), mrb_proc_s_new(), mrb_ptexenc_enable_UPTEX(), mrb_ptexenc_fromDVI(), mrb_ptexenc_fromEUC(), mrb_ptexenc_fromJIS(), mrb_ptexenc_fromKUTEN(), mrb_ptexenc_fromSJIS(), mrb_ptexenc_fromUCS(), mrb_ptexenc_set_enc_string(), mrb_ptexenc_toDVI(), mrb_ptexenc_toJIS(), mrb_ptexenc_toUCS(), mrb_ptexenc_UCStoUTF8(), mrb_puts(), mrb_socket_accept(), mrb_socket_accept2(), mrb_socket_bind(), mrb_socket_connect(), mrb_socket_listen(), mrb_socket_sockaddr_family(), mrb_socket_sockaddr_un(), mrb_socket_socket(), mrb_socket_socketpair(), mrb_str_aref_m(), mrb_str_aset_m(), mrb_str_byteslice(), mrb_str_chomp_bang(), mrb_str_count(), mrb_str_del_prefix(), mrb_str_del_prefix_bang(), mrb_str_del_suffix(), mrb_str_del_suffix_bang(), mrb_str_delete(), mrb_str_delete_bang(), mrb_str_end_with(), mrb_str_getbyte(), mrb_str_include(), mrb_str_index_m(), mrb_str_init(), mrb_str_plus_m(), mrb_str_replace(), mrb_str_rindex(), mrb_str_setbyte(), mrb_str_split_m(), mrb_str_squeeze(), mrb_str_squeeze_bang(), mrb_str_start_with(), mrb_str_times(), mrb_str_to_i(), mrb_str_tr(), mrb_str_tr_bang(), mrb_str_tr_s(), mrb_str_tr_s_bang(), mrb_struct_aset(), mrb_struct_initialize(), mrb_struct_s_def(), mrb_struct_values_at(), mrb_time_at_m(), mrb_time_gm(), mrb_time_initialize(), mrb_time_local(), obj_is_instance_of(), obj_respond_to(), os_count_objects(), os_each_object(), os_memsize_of(), os_memsize_of_all(), prepare_tmpl(), proc_lambda(), range_initialize(), rational_m(), rational_s_new(), true_and(), and true_xor().

◆ mrb_get_argv()

const mrb_value* mrb_get_argv ( mrb_state mrb)

Retrieve an array of arguments from mrb_state.

Correctly handles *splat arguments.

Definition at line 827 of file class.c.

References a, mrb_callinfo::argc, argc, ARY_PTR, mrb_state::c, mrb_context::ci, mrb_ary_ptr, and mrb_callinfo::stack.

Referenced by mrb_ary_aset(), and mrb_ary_push_m().

◆ mrb_get_mid()

static mrb_sym mrb_get_mid ( mrb_state mrb)
inlinestatic

Definition at line 980 of file mruby.h.

References mrb_state::c, mrb_context::ci, and mrb_callinfo::mid.

◆ mrb_include_module()

void mrb_include_module ( mrb_state mrb,
struct RClass cla,
struct RClass included 
)

Include a module in another class or module. Equivalent to:

module B include A end

Parameters
mrbThe current mruby state.
claA reference to module or a class.
includedA reference to the module to be included.

Definition at line 1440 of file class.c.

References c, data, E_ARGUMENT_ERROR, find_origin(), fix_include_module(), include_module_at(), m, mrb_check_frozen(), MRB_FL_CLASS_IS_INHERITED, mrb_objspace_each_objects(), mrb_raise(), and MRB_TT_MODULE.

Referenced by mrb_init_io(), mrb_init_kernel(), mrb_mod_append_features(), mrb_mod_extend_object(), and mrb_mruby_time_gem_init().

◆ mrb_incremental_gc()

◆ mrb_inspect()

mrb_value mrb_inspect ( mrb_state mrb,
mrb_value  obj 
)

◆ mrb_Integer()

mrb_value mrb_Integer ( mrb_state mrb,
mrb_value  val 
)

Definition at line 565 of file object.c.

References mrb_convert_to_integer().

Referenced by mrb_str_format().

◆ mrb_intern()

◆ mrb_intern_check()

mrb_sym mrb_intern_check ( mrb_state mrb,
const char *  name,
size_t  len 
)

◆ mrb_intern_check_cstr()

mrb_sym mrb_intern_check_cstr ( mrb_state mrb,
const char *  name 
)

◆ mrb_intern_check_str()

mrb_sym mrb_intern_check_str ( mrb_state mrb,
mrb_value  str 
)

Definition at line 290 of file symbol.c.

References mrb_intern_check(), RSTRING_LEN, RSTRING_PTR, and str.

Referenced by mrb_check_intern_str().

◆ mrb_intern_cstr()

mrb_sym mrb_intern_cstr ( mrb_state mrb,
const char *  str 
)

Create a symbol from C string. But usually it's better to use MRB_SYM, MRB_OPSYM, MRB_CVSYM, MRB_IVSYM, MRB_SYM_B, MRB_SYM_Q, MRB_SYM_E macros.

Example:

# Ruby style:
:pizza # => :pizza

// C style:
mrb_sym sym1 = mrb_intern_lit(mrb, "pizza"); //  => :pizza
mrb_sym sym2 = MRB_SYM(pizza);               //  => :pizza
mrb_sym sym3 = MRB_SYM_Q(pizza);             //  => :pizza?
Parameters
mrbThe current mruby state.
strThe string to be symbolized
Returns
[mrb_sym] mrb_sym A symbol.

Definition at line 245 of file symbol.c.

References mrb_intern(), name, and strlen().

◆ mrb_intern_static()

mrb_sym mrb_intern_static ( mrb_state mrb,
const char *  name,
size_t  len 
)

Definition at line 239 of file symbol.c.

References len, name, sym_intern(), and TRUE.

Referenced by read_irep_record_1(), read_section_debug(), and read_section_lv().

◆ mrb_intern_str()

mrb_sym mrb_intern_str ( mrb_state mrb,
mrb_value  str 
)

◆ mrb_malloc()

◆ mrb_malloc_simple()

void* mrb_malloc_simple ( mrb_state mrb,
size_t  len 
)

Definition at line 262 of file gc.c.

References len, and mrb_realloc_simple().

Referenced by mrb_pool_open(), page_alloc(), and tr_parse_pattern().

◆ mrb_module_get()

struct RClass* mrb_module_get ( mrb_state mrb,
const char *  name 
)

Gets a module.

Parameters
mrbThe current mruby state.
nameThe name of the module.
Returns
[struct RClass *] A reference to the module.

Definition at line 676 of file class.c.

References mrb_module_get_under(), name, and mrb_state::object_class.

Referenced by mrb_init_io(), mrb_mruby_os_memsize_gem_init(), and mrb_mruby_time_gem_init().

◆ mrb_module_get_id()

struct RClass* mrb_module_get_id ( mrb_state mrb,
mrb_sym  name 
)

Definition at line 682 of file class.c.

References mrb_module_get_under_id(), name, and mrb_state::object_class.

Referenced by domain_error(), and io_set_process_status().

◆ mrb_module_get_under()

struct RClass* mrb_module_get_under ( mrb_state mrb,
struct RClass outer,
const char *  name 
)

Gets a module defined under another module.

Parameters
mrbThe current mruby state.
outerThe name of the outer module.
nameThe name of the module.
Returns
[struct RClass *] A reference to the module.

Definition at line 664 of file class.c.

References module_from_sym(), mrb_intern_cstr, and name.

Referenced by mrb_module_get().

◆ mrb_module_get_under_id()

struct RClass* mrb_module_get_under_id ( mrb_state mrb,
struct RClass outer,
mrb_sym  name 
)

Definition at line 670 of file class.c.

References module_from_sym(), and name.

Referenced by mrb_module_get_id().

◆ mrb_module_new()

struct RClass* mrb_module_new ( mrb_state mrb)

Creates a new module, Module.

Example: void mrb_example_gem_init(mrb_state* mrb) { struct RClass *example_module;

example_module = mrb_module_new(mrb); }

Parameters
mrbThe current mruby state.
Returns
[struct RClass *] Reference to the new module.

Creates a new module.

Definition at line 2164 of file class.c.

References boot_initmod(), m, mrb_state::module_class, mrb_obj_alloc(), and MRB_TT_MODULE.

Referenced by define_module().

◆ mrb_name_error()

◆ mrb_notimplement()

void mrb_notimplement ( mrb_state mrb)

Definition at line 779 of file class.c.

References mrb_state::c, mrb_context::ci, E_NOTIMP_ERROR, mrb_callinfo::mid, and mrb_raisef().

Referenced by mrb_notimplement_m().

◆ mrb_notimplement_m()

mrb_value mrb_notimplement_m ( mrb_state mrb,
mrb_value  self 
)

Definition at line 790 of file class.c.

References mrb_nil_value(), and mrb_notimplement().

◆ mrb_obj_alloc()

◆ mrb_obj_class()

◆ mrb_obj_classname()

const char* mrb_obj_classname ( mrb_state mrb,
mrb_value  obj 
)

◆ mrb_obj_clone()

◆ mrb_obj_dup()

mrb_value mrb_obj_dup ( mrb_state mrb,
mrb_value  obj 
)

Duplicate an object.

Equivalent to: Object::dup

Parameters
mrbThe current mruby state.
objObject to be duplicate.
Returns
[mrb_value] The newly duplicated object.

Definition at line 2767 of file class.c.

References dup(), E_TYPE_ERROR, init_copy(), mrb_immediate_p, mrb_obj_alloc(), mrb_obj_class(), mrb_obj_value(), mrb_raise(), mrb_sclass_p, mrb_type(), and p.

Referenced by copy_class(), and mrb_init_kernel().

◆ mrb_obj_eq()

mrb_bool mrb_obj_eq ( mrb_state mrb,
mrb_value  a,
mrb_value  b 
)

◆ mrb_obj_equal()

◆ mrb_obj_freeze()

mrb_value mrb_obj_freeze ( mrb_state mrb,
mrb_value  self 
)

◆ mrb_obj_id()

◆ mrb_obj_inspect()

mrb_value mrb_obj_inspect ( mrb_state mrb,
mrb_value  self 
)

Definition at line 55 of file kernel.c.

References mrb_any_to_s(), mrb_obj_basic_to_s_p(), mrb_obj_iv_inspect(), mrb_obj_ptr, and mrb_object_p.

Referenced by mrb_init_kernel().

◆ mrb_obj_is_instance_of()

mrb_bool mrb_obj_is_instance_of ( mrb_state mrb,
mrb_value  obj,
struct RClass c 
)

◆ mrb_obj_is_kind_of()

◆ mrb_obj_new()

mrb_value mrb_obj_new ( mrb_state mrb,
struct RClass c,
mrb_int  argc,
const mrb_value argv 
)

Initialize a new object instance of c class.

Example:

# Ruby style
class ExampleClass
end

p ExampleClass # => #<ExampleClass:0x9958588>
// C style
#include <stdio.h>
#include <mruby.h>

void
mrb_example_gem_init(mrb_state* mrb) {
  struct RClass *example_class;
  mrb_value obj;
  example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class); # => class ExampleClass; end
  obj = mrb_obj_new(mrb, example_class, 0, NULL); # => ExampleClass.new
  mrb_p(mrb, obj); // => Kernel#p
 }
Parameters
mrbThe current mruby state.
cReference to the class of the new object.
argcNumber of arguments in argv
argvArray of mrb_value to initialize the object
Returns
[mrb_value] The newly initialized object

Definition at line 1940 of file class.c.

References argc, argv, c, initialize(), mrb_bob_init(), mrb_func_basic_p(), mrb_funcall_argv(), mrb_instance_alloc(), mrb_obj_value(), and MRB_SYM.

Referenced by mrb_class_new_instance(), mrb_exc_new(), mrb_exc_new_str(), mrb_mruby_random_gem_init(), mrb_no_method_error(), and raise_va().

◆ mrb_obj_respond_to()

mrb_bool mrb_obj_respond_to ( mrb_state mrb,
struct RClass c,
mrb_sym  mid 
)

Returns true if obj responds to the given method. If the method was defined for that class it returns true, it returns false otherwise.

 Example:
 # Ruby style
 class ExampleClass
   def example_method
   end
 end

 ExampleClass.new.respond_to?(:example_method) # => true

 // C style
 void
 mrb_example_gem_init(mrb_state* mrb) {
   struct RClass *example_class;
   mrb_sym mid;
   mrb_bool obj_resp;

   example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);
   mrb_define_method(mrb, example_class, "example_method", exampleMethod, MRB_ARGS_NONE());
   mid = mrb_intern_str(mrb, mrb_str_new_lit(mrb, "example_method" ));
   obj_resp = mrb_obj_respond_to(mrb, example_class, mid); // => 1(true in Ruby world)

   // If mrb_obj_respond_to returns 1 then puts "True"
   // If mrb_obj_respond_to returns 0 then puts "False"
   if (obj_resp == 1) {
     puts("True");
   }
   else if (obj_resp == 0) {
     puts("False");
   }
 }
Parameters
mrbThe current mruby state.
cA reference to a class.
midA symbol referencing a method id.
Returns
[mrb_bool] A boolean value.

Definition at line 2055 of file class.c.

References c, FALSE, m, mrb_method_search_vm(), MRB_METHOD_UNDEF_P, and TRUE.

Referenced by mrb_mod_method_defined(), mrb_respond_to(), and mrb_undef_method_id().

◆ mrb_obj_to_sym()

mrb_sym mrb_obj_to_sym ( mrb_state mrb,
mrb_value  name 
)

◆ mrb_open()

mrb_state* mrb_open ( void  )

Creates new mrb_state.

Returns
Pointer to the newly created mrb_state.

Definition at line 73 of file state.c.

References mrb_default_allocf(), mrb_open_allocf(), and NULL.

Referenced by aptex_commands_init(), FuzzRB(), LLVMFuzzerTestOneInput(), and main().

◆ mrb_open_allocf()

mrb_state* mrb_open_allocf ( mrb_allocf  f,
void ud 
)

Create new mrb_state with custom allocators.

Parameters
fReference to the allocation function.
udUser data will be passed to custom allocator f. If user data isn't required just pass NULL.
Returns
Pointer to the newly created mrb_state.

Definition at line 89 of file state.c.

References f, init_mrbgems(), mrb_close(), mrb_core_init_protect(), mrb_gc_arena_restore(), mrb_open_core(), and NULL.

Referenced by mrb_open().

◆ mrb_open_core()

mrb_state* mrb_open_core ( mrb_allocf  f,
void ud 
)

Create new mrb_state with just the MRuby core

Parameters
fReference to the allocation function. Use mrb_default_allocf for the default
udUser data will be passed to custom allocator f. If user data isn't required just pass NULL.
Returns
Pointer to the newly created mrb_state.

Definition at line 38 of file state.c.

References mrb_state::allocf, mrb_state::allocf_ud, mrb_state::atexit_stack_len, f, init_gc_and_core(), mrb_close(), mrb_core_init_protect(), mrb_default_allocf(), and NULL.

Referenced by main(), and mrb_open_allocf().

◆ mrb_p()

◆ mrb_pool_alloc()

void* mrb_pool_alloc ( struct mrb_pool pool,
size_t  len 
)

Definition at line 108 of file pool.c.

References ALIGN_PADDING, len, n, NULL, page::page, page, and page_alloc().

Referenced by codegen_palloc(), mrb_parser_new(), mrb_pool_realloc(), parser_palloc(), and scope_new().

◆ mrb_pool_can_realloc()

mrb_bool mrb_pool_can_realloc ( struct mrb_pool pool,
void p,
size_t  len 
)

Definition at line 136 of file pool.c.

References ALIGN_PADDING, FALSE, if, page::len, len, p, page::page, page, and TRUE.

◆ mrb_pool_close()

void mrb_pool_close ( struct mrb_pool pool)

Definition at line 77 of file pool.c.

References mrb_free(), and page.

Referenced by codegen_error(), generate_code(), mrb_parser_free(), and scope_finish().

◆ mrb_pool_open()

struct mrb_pool* mrb_pool_open ( mrb_state mrb)

Definition at line 64 of file pool.c.

References mrb_malloc_simple(), NULL, and pool.

Referenced by mrb_parser_new(), and scope_new().

◆ mrb_pool_realloc()

void* mrb_pool_realloc ( struct mrb_pool pool,
void p,
size_t  oldlen,
size_t  newlen 
)

Definition at line 157 of file pool.c.

References ALIGN_PADDING, if, page::len, memcpy, mrb_pool_alloc(), np, NULL, p, page::page, and page.

Referenced by composite_string_node().

◆ mrb_prepend_module()

void mrb_prepend_module ( mrb_state mrb,
struct RClass cla,
struct RClass prepended 
)

Prepends a module in another class or module.

Equivalent to: module B prepend A end

Parameters
mrbThe current mruby state.
claA reference to module or a class.
prependedA reference to the module to be prepended.

Definition at line 1481 of file class.c.

References c, data, E_ARGUMENT_ERROR, fix_prepend_module(), include_module_at(), RClass::iv, m, mrb_check_frozen(), mrb_field_write_barrier(), MRB_FL_CLASS_IS_INHERITED, MRB_FL_CLASS_IS_ORIGIN, MRB_FL_CLASS_IS_PREPENDED, mrb_obj_alloc(), mrb_objspace_each_objects(), mrb_raise(), MRB_TT_ICLASS, MRB_TT_MODULE, RClass::mt, NULL, and RClass::super.

Referenced by mrb_mod_prepend_features().

◆ mrb_print_backtrace()

void mrb_print_backtrace ( mrb_state mrb)

◆ mrb_print_error()

void mrb_print_error ( mrb_state mrb)

Definition at line 56 of file print.c.

References mrb_print_backtrace().

Referenced by main().

◆ mrb_raise()

void mrb_raise ( mrb_state mrb,
struct RClass c,
const char *  msg 
)

Definition at line 214 of file error.c.

References c, mrb_exc_new_str(), mrb_exc_raise(), and mrb_str_new_cstr().

Referenced by ary_concat(), ary_expand_capa(), ary_new_capa(), bind_check(), change_gen_gc_mode(), check_null_byte(), create_proc_from_string(), current_mrb_time(), dbgcmd_quit(), dbgcmd_run(), eval_under(), fiber_check(), fiber_check_cfunc(), fiber_init(), fiber_switch(), fixnum_minus(), fixnum_mul(), fixnum_plus(), get_hash(), get_num(), ht_set_without_ib_adjustment(), int_divmod(), int_mod(), int_zerodiv(), io_get_open_fptr(), join_ary(), mod_const_check(), mrb_addrinfo_getaddrinfo(), mrb_addrinfo_getnameinfo(), mrb_addrinfo_unix_path(), mrb_ary_first(), mrb_ary_last(), mrb_ary_plus(), mrb_ary_sample(), mrb_ary_splice(), mrb_ary_times(), mrb_ary_unshift_m(), mrb_basicsocket_getpeereid(), mrb_basicsocket_setsockopt(), mrb_check_inheritable(), mrb_check_num_exact(), mrb_convert_to_integer(), mrb_exc_get_id(), mrb_exc_raise(), mrb_f_raise(), mrb_f_sleep(), mrb_f_sprintf(), mrb_f_usleep(), mrb_fiber_yield(), mrb_file__gethome(), mrb_file_flock(), mrb_file_s_readlink(), mrb_file_s_symlink(), mrb_file_size(), mrb_file_truncate(), mrb_filetest_s_pipe_p(), mrb_filetest_s_socket_p(), mrb_filetest_s_symlink_p(), mrb_flo_to_fixnum(), mrb_Float(), mrb_funcall(), mrb_funcall_id(), mrb_get_args(), mrb_hash_check_kdict(), mrb_hash_new_capa(), mrb_include_module(), mrb_instance_alloc(), mrb_io_check_readable(), mrb_io_readchar(), mrb_io_sysread_common(), mrb_io_sysseek(), mrb_io_syswrite_common(), mrb_ipsocket_ntop(), mrb_ipsocket_pton(), mrb_iv_set(), mrb_make_exception(), mrb_mod_define_method_m(), mrb_mod_module_eval(), mrb_mod_s_constants(), mrb_mruby_socket_gem_init(), mrb_num_minus(), mrb_num_mul(), mrb_num_plus(), mrb_obj_alloc(), mrb_obj_clone(), mrb_obj_dup(), mrb_obj_init_copy(), mrb_obj_instance_eval(), mrb_obj_is_kind_of(), mrb_pack_pack(), mrb_prepend_module(), mrb_proc_cfunc_env_get(), mrb_proc_init_copy(), mrb_range_ptr(), mrb_singleton_class(), mrb_socket_sockaddr_family(), mrb_socket_sockaddr_un(), mrb_socket_socketpair(), mrb_stat0(), mrb_state_atexit(), mrb_str_aset(), mrb_str_cat(), mrb_str_format(), mrb_str_len_to_dbl(), mrb_str_len_to_inum(), mrb_str_new_capa(), mrb_str_ord(), mrb_str_resize(), mrb_str_split_m(), mrb_str_strlen(), mrb_str_times(), mrb_struct_init_copy(), mrb_struct_initialize_withArg(), mrb_sys_fail(), mrb_time_initialize_copy(), mrb_to_flo(), mrb_yield_cont(), mrb_yield_with_class(), num_members(), option_to_fd(), pack_unpack(), pack_utf8(), proc_lambda(), r_check(), random_check(), random_default(), random_rand(), range_initialize_copy(), rat_overflow(), rat_zerodiv(), read_tmpl(), sa2addrlist(), set_backtrace(), str_len_ensure(), str_new(), str_new_static(), str_replace_partial(), struct_members(), struct_s_members(), sym_validate_len(), time_get_ptr(), time_mktime(), time_to_s_local(), tr_parse_pattern(), unpack_x(), utf8_to_uv(), and value_int64().

◆ mrb_raisef()

void mrb_raisef ( mrb_state mrb,
struct RClass c,
const char *  fmt,
  ... 
)

◆ mrb_realloc()

◆ mrb_realloc_simple()

void* mrb_realloc_simple ( mrb_state mrb,
void p,
size_t  len 
)

◆ mrb_respond_to()

mrb_bool mrb_respond_to ( mrb_state mrb,
mrb_value  obj,
mrb_sym  mid 
)

◆ mrb_show_copyright()

void mrb_show_copyright ( mrb_state mrb)

◆ mrb_show_version()

void mrb_show_version ( mrb_state mrb)

◆ mrb_singleton_class()

◆ mrb_singleton_class_ptr()

◆ mrb_stack_extend()

◆ mrb_state_atexit()

◆ mrb_str_new()

◆ mrb_str_new_cstr()

◆ mrb_str_new_static()

mrb_value mrb_str_new_static ( mrb_state mrb,
const char *  p,
size_t  len 
)

Definition at line 221 of file string.c.

References len, mrb_obj_value(), p, s, and str_new_static().

Referenced by mrb_sym_str(), mrb_time_zone(), mrb_vm_exec(), and sym_name().

◆ mrb_sym_dump()

const char* mrb_sym_dump ( mrb_state mrb,
mrb_sym  sym 
)

Definition at line 622 of file symbol.c.

References sym, sym_name(), and TRUE.

Referenced by codedump(), mrb_parser_dump(), and print_r().

◆ mrb_sym_name()

const char* mrb_sym_name ( mrb_state mrb,
mrb_sym  sym 
)

◆ mrb_sym_name_len()

◆ mrb_sym_str()

◆ mrb_to_int()

◆ mrb_to_str()

◆ mrb_top_run()

mrb_value mrb_top_run ( mrb_state mrb,
const struct RProc proc,
mrb_value  self,
mrb_int  stack_keep 
)

◆ mrb_top_self()

mrb_value mrb_top_self ( mrb_state mrb)

Definition at line 209 of file state.c.

References mrb_obj_value(), and mrb_state::top_self.

Referenced by decl_lv_underscore(), load_irep(), main(), mrb_load_exec(), and mrb_load_proc().

◆ mrb_type_convert()

mrb_value mrb_type_convert ( mrb_state mrb,
mrb_value  val,
enum mrb_vtype  type,
mrb_sym  method 
)

◆ mrb_type_convert_check()

mrb_value mrb_type_convert_check ( mrb_state mrb,
mrb_value  val,
enum mrb_vtype  type,
mrb_sym  method 
)

Definition at line 389 of file object.c.

References convert_type(), FALSE, mrb_nil_p, mrb_nil_value(), MRB_TT_DATA, MRB_TT_ISTRUCT, mrb_type(), type, type_name(), v, and val.

Referenced by mrb_f_array().

◆ mrb_undef_class_method()

void mrb_undef_class_method ( mrb_state mrb,
struct RClass cls,
const char *  name 
)

Undefine a class method. Example:

 # Ruby style
 class ExampleClass
   def self.example_method
     "example"
   end
 end

ExampleClass.example_method

// C style
#include <stdio.h>
#include <mruby.h>

mrb_value
mrb_example_method(mrb_state *mrb){
  return mrb_str_new_lit(mrb, "example");
}

void
mrb_example_gem_init(mrb_state* mrb){
  struct RClass *example_class;
  example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);
  mrb_define_class_method(mrb, example_class, "example_method", mrb_example_method, MRB_ARGS_NONE());
  mrb_undef_class_method(mrb, example_class, "example_method");
 }

 void
 mrb_example_gem_final(mrb_state* mrb){
 }
Parameters
mrbThe mruby state reference.
clsA class the class method will be undefined from.
nameThe name of the class method to be undefined.

Definition at line 2308 of file class.c.

References c, mrb_class_ptr, mrb_obj_value(), mrb_singleton_class(), mrb_undef_method(), and name.

Referenced by mrb_init_numeric(), mrb_init_object(), mrb_init_symbol(), mrb_mruby_complex_gem_init(), mrb_mruby_method_gem_init(), and mrb_mruby_rational_gem_init().

◆ mrb_undef_class_method_id()

void mrb_undef_class_method_id ( mrb_state mrb,
struct RClass cls,
mrb_sym  name 
)

Definition at line 2302 of file class.c.

References c, mrb_class_ptr, mrb_obj_value(), mrb_singleton_class(), mrb_undef_method_id(), and name.

◆ mrb_undef_method()

void mrb_undef_method ( mrb_state mrb,
struct RClass cla,
const char *  name 
)

Undefines a method.

Example:

# Ruby style

class ExampleClassA
  def example_method
    "example"
  end
end
ExampleClassA.new.example_method # => example

class ExampleClassB < ExampleClassA
  undef_method :example_method
end

ExampleClassB.new.example_method # => undefined method 'example_method' for ExampleClassB (NoMethodError)

// C style
#include <stdio.h>
#include <mruby.h>

mrb_value
mrb_example_method(mrb_state *mrb){
  return mrb_str_new_lit(mrb, "example");
}

void
mrb_example_gem_init(mrb_state* mrb){
  struct RClass *example_class_a;
  struct RClass *example_class_b;
  struct RClass *example_class_c;

  example_class_a = mrb_define_class(mrb, "ExampleClassA", mrb->object_class);
  mrb_define_method(mrb, example_class_a, "example_method", mrb_example_method, MRB_ARGS_NONE());
  example_class_b = mrb_define_class(mrb, "ExampleClassB", example_class_a);
  example_class_c = mrb_define_class(mrb, "ExampleClassC", example_class_b);
  mrb_undef_method(mrb, example_class_c, "example_method");
}

mrb_example_gem_final(mrb_state* mrb){
}
Parameters
mrbThe mruby state reference.
claThe class the method will be undefined from.
nameThe name of the method to be undefined.

Definition at line 2296 of file class.c.

References c, mrb_intern_cstr, name, and undef_method().

Referenced by mrb_init_class(), and mrb_undef_class_method().

◆ mrb_undef_method_id()

void mrb_undef_method_id ( mrb_state mrb,
struct RClass c,
mrb_sym  a 
)

Definition at line 2287 of file class.c.

References a, c, mrb_name_error(), mrb_obj_respond_to(), and undef_method().

Referenced by mrb_mod_undef(), mrb_undef_class_method_id(), and mrb_vm_exec().

◆ mrb_vformat()

◆ mrb_vm_exec()

mrb_value mrb_vm_exec ( mrb_state mrb,
const struct RProc proc,
const mrb_code iseq 
)

Definition at line 998 of file vm.c.

References a, abort(), acc, mrb_callinfo::acc, add, mrb_callinfo::argc, argc, argnum_error(), argv, argv0, RArray::ary, ARY_LEN, ARY_PTR, ARY_SET_LEN, B, b, base, BB, BBB, RProc::body, break_new(), BS, BSS, mrb_state::c, c, CALL_MAXARGS, CASE, catch_handler_find(), ch, check_target_class(), CHECKPOINT_END, CHECKPOINT_LABEL_MAKE, CHECKPOINT_MAIN, CHECKPOINT_RESTORE, mrb_context::ci, CI_ACC_DIRECT, CI_ACC_RESUMED, CI_ACC_SKIP, mrb_context::cibase, cipop(), cipush(), DEBUG, DISPATCH_CHECKPOINTS, div(), link_confs::dst, e, E_ARGUMENT_ERROR, E_FIBER_ERROR, E_LOCALJUMP_ERROR, E_NOMETHOD_ERROR, E_RANGE_ERROR, E_RUNTIME_ERROR, E_TYPE_ERROR, ec, END_DISPATCH, mrb_state::exc, f, FALSE, FETCH_BBB, fprintf, gt, hash, i, idx, INIT_DISPATCH, int(), int16_t, INT32_MAX, INT32_MIN, RProc::irep, IREP_TT_FLOAT, IREP_TT_INT32, IREP_TT_INT64, IREP_TT_NFLAG, IREP_TT_SFLAG, mrb_irep::iseq, mrb_state::jmp, JUMP, k, len, localjump_error(), LOCALJUMP_ERROR_RETURN, LOCALJUMP_ERROR_YIELD, m, mrb_callinfo::mid, REnv::mid, mrb_alias_method(), mrb_array_p, mrb_ary_concat(), mrb_ary_new_capa(), mrb_ary_new_from_values(), mrb_ary_ptr, mrb_ary_push(), mrb_ary_ref(), mrb_ary_set(), mrb_ary_splat(), mrb_ary_unshift(), MRB_ASPEC_KDICT, MRB_ASPEC_KEY, MRB_ASPEC_OPT, MRB_ASPEC_POST, MRB_ASPEC_REQ, MRB_ASPEC_REST, mrb_assert, mrb_bool_value(), mrb_break_p, mrb_break_proc_get, mrb_break_tag_get(), mrb_break_value_get(), MRB_CATCH, MRB_CATCH_FILTER_ALL, MRB_CATCH_FILTER_ENSURE, mrb_class(), mrb_class_ptr, mrb_closure_new(), mrb_const_get(), mrb_const_set(), mrb_define_method_raw(), MRB_END_EXC, mrb_ensure_hash_type(), MRB_ENV_LEN, MRB_ENV_ONSTACK_P, mrb_exc_new(), mrb_exc_new_lit, mrb_exc_new_str(), mrb_exc_set(), MRB_FIBER_RUNNING, MRB_FIBER_TERMINATED, mrb_field_write_barrier(), mrb_fixnum_value(), MRB_FL_CLASS_IS_PREPENDED, mrb_float_value(), mrb_format(), mrb_gc_arena_restore(), mrb_gc_arena_save(), mrb_gc_arena_shrink(), mrb_gc_protect(), mrb_gv_get(), mrb_gv_set(), mrb_hash_check_kdict(), mrb_hash_delete_key(), mrb_hash_dup(), mrb_hash_empty_p(), mrb_hash_get(), mrb_hash_key_p(), mrb_hash_keys(), mrb_hash_merge(), mrb_hash_new(), mrb_hash_new_capa(), mrb_hash_p, mrb_hash_set(), mrb_int_value(), mrb_integer, mrb_integer_p, mrb_intern_str(), mrb_irep_catch_handler_unpack, mrb_iv_get(), mrb_iv_set(), MRB_METHOD_CFUNC, MRB_METHOD_CFUNC_P, MRB_METHOD_FROM_PROC, MRB_METHOD_FUNC, mrb_method_missing(), MRB_METHOD_NOARG_P, MRB_METHOD_PROC, MRB_METHOD_PROC_P, mrb_method_search_vm(), MRB_METHOD_UNDEF_P, mrb_nil_p, mrb_nil_value(), mrb_num_div_flo(), mrb_num_div_int(), mrb_obj_eq(), mrb_obj_is_kind_of(), mrb_obj_ptr, mrb_obj_value(), MRB_OPSYM, MRB_PROC_CFUNC, MRB_PROC_CFUNC_P, MRB_PROC_ENV, MRB_PROC_ENV_P, mrb_proc_new(), MRB_PROC_ORPHAN, MRB_PROC_ORPHAN_P, mrb_proc_p, mrb_proc_ptr, MRB_PROC_SCOPE, MRB_PROC_SET_TARGET_CLASS, MRB_PROC_STRICT, MRB_PROC_STRICT_P, MRB_PROC_TARGET_CLASS, mrb_range_new(), mrb_singleton_class(), mrb_stack_extend(), mrb_str_concat(), mrb_str_new(), mrb_str_new_static(), MRB_SYM, mrb_sym_name(), mrb_symbol_value(), mrb_test, MRB_THROW, MRB_TRY, MRB_TT_BREAK, MRB_TT_CLASS, MRB_TT_EXCEPTION, MRB_TT_FLOAT, MRB_TT_ICLASS, MRB_TT_INTEGER, MRB_TT_MODULE, MRB_TT_PROC, mrb_type(), mrb_type_convert(), mrb_undef_method_id(), mrb_vm_ci_env(), mrb_vm_ci_proc_set(), mrb_vm_ci_target_class(), mrb_vm_const_get(), mrb_vm_const_set(), mrb_vm_cv_get(), mrb_vm_cv_set(), mrb_vm_define_class(), mrb_vm_define_module(), mrb_vm_special_get(), mrb_vm_special_set(), mrb_write_barrier(), NEXT, mrb_irep::nlocals, mrb_irep::nregs, NULL, mrb_state::object_class, OP_ADD, OP_CALL, OP_CMP, OP_DIV, OP_EQ, OP_JMP, OP_L_BLOCK, OP_L_CAPTURE, OP_L_LAMBDA, OP_L_METHOD, OP_L_STRICT, OP_LE, OP_LOADNIL, OP_LT, OP_MATH, OP_MATHI, OP_MOVE, OP_MUL, OP_R_BREAK, OP_R_NORMAL, OP_R_RETURN, OP_RETURN, OP_SUB, optable, p, pc, mrb_callinfo::pc, mrb_irep::pool, pp, pre, printf(), mrb_callinfo::proc, r, RARRAY_LEN, RARRAY_PTR, RBREAK_TAG_BREAK, RBREAK_TAG_BREAK_INTARGET, RBREAK_TAG_BREAK_UPPER, RBREAK_TAG_FOREACH, RBREAK_TAG_JUMP, RBREAK_TAG_RETURN, RBREAK_TAG_RETURN_BLOCK, RBREAK_TAG_RETURN_TOPLEVEL, RBREAK_TAG_STOP, regs, mrb_irep::reps, rest, mrb_state::root_c, S, SET_FALSE_VALUE, SET_FIXNUM_VALUE, SET_FLOAT_VALUE, SET_INT_VALUE, SET_NIL_VALUE, SET_SYM_VALUE, SET_TRUE_VALUE, stack, mrb_callinfo::stack, stack_clear(), stack_copy(), mrb_context::status, mrb_context::stbase, str, sub, RClass::super, sym, mrb_irep::syms, target, mrb_callinfo::target_class, THROW_TAGGED_BREAK, top_proc(), TRUE, RObject::tt, TYPES2, u, mrb_callinfo::u, uint32_t, UNWIND_ENSURE, uvenv(), v, val, value_move(), mrb_context::vmexec, W, cordic::x, y, and Z.

Referenced by fiber_switch(), and mrb_vm_run().

◆ mrb_vm_run()

◆ mrb_warn()

void mrb_warn ( mrb_state mrb,
const char *  fmt,
  ... 
)

◆ mrb_write_barrier()

◆ mrb_yield()

mrb_value mrb_yield ( mrb_state mrb,
mrb_value  b,
mrb_value  arg 
)

Definition at line 726 of file vm.c.

References b, MRB_PROC_ENV, mrb_proc_ptr, MRB_PROC_TARGET_CLASS, mrb_yield_with_class(), and p.

Referenced by os_each_object_cb().

◆ mrb_yield_argv()

mrb_value mrb_yield_argv ( mrb_state mrb,
mrb_value  b,
mrb_int  argc,
const mrb_value argv 
)

Definition at line 718 of file vm.c.

References argc, argv, b, MRB_PROC_ENV, mrb_proc_ptr, MRB_PROC_TARGET_CLASS, mrb_yield_with_class(), and p.

◆ mrb_yield_cont()

◆ mrb_yield_with_class()