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)  

object.c
Go to the documentation of this file.
1 /*
2 ** object.c - Object, NilClass, TrueClass, FalseClass class
3 **
4 ** See Copyright Notice in mruby.h
5 */
6 
7 #include <mruby.h>
8 #include <mruby/class.h>
9 #include <mruby/numeric.h>
10 #include <mruby/string.h>
11 #include <mruby/class.h>
12 #include <mruby/presym.h>
13 
16 {
17  if (mrb_type(v1) != mrb_type(v2)) return FALSE;
18  switch (mrb_type(v1)) {
19  case MRB_TT_TRUE:
20  return TRUE;
21 
22  case MRB_TT_FALSE:
23  case MRB_TT_INTEGER:
24  return (mrb_integer(v1) == mrb_integer(v2));
25  case MRB_TT_SYMBOL:
26  return (mrb_symbol(v1) == mrb_symbol(v2));
27 
28 #ifndef MRB_NO_FLOAT
29  case MRB_TT_FLOAT:
30  return (mrb_float(v1) == mrb_float(v2));
31 #endif
32 
33  default:
34  return (mrb_ptr(v1) == mrb_ptr(v2));
35  }
36 }
37 
40 {
41  /* temporary definition */
42  return mrb_obj_eq(mrb, v1, v2);
43 }
44 
47 {
49 
50  if (mrb_obj_eq(mrb, obj1, obj2)) return TRUE;
51 #ifndef MRB_NO_FLOAT
52  /* value mixing with integer and float */
53  if (mrb_integer_p(obj1)) {
54  if (mrb_float_p(obj2) && (mrb_float)mrb_integer(obj1) == mrb_float(obj2))
55  return TRUE;
56  }
57  else if (mrb_float_p(obj1)) {
58  if (mrb_integer_p(obj2) && mrb_float(obj1) == (mrb_float)mrb_integer(obj2))
59  return TRUE;
60  }
61 #endif
62  result = mrb_funcall_id(mrb, obj1, MRB_OPSYM(eq), 1, obj2);
63  if (mrb_test(result)) return TRUE;
64  return FALSE;
65 }
66 
67 /*
68  * Document-class: NilClass
69  *
70  * The class of the singleton object <code>nil</code>.
71  */
72 
73 /* 15.2.4.3.4 */
74 /*
75  * call_seq:
76  * nil.nil? -> true
77  *
78  * Only the object <i>nil</i> responds <code>true</code> to <code>nil?</code>.
79  */
80 
81 static mrb_value
83 {
84  return mrb_true_value();
85 }
86 
87 /* 15.2.4.3.5 */
88 /*
89  * call-seq:
90  * nil.to_s -> ""
91  *
92  * Always returns the empty string.
93  */
94 
95 static mrb_value
97 {
100  return str;
101 }
102 
103 static mrb_value
105 {
106  mrb_value str = mrb_str_new_lit_frozen(mrb, "nil");
108  return str;
109 }
110 
111 /***********************************************************************
112  * Document-class: TrueClass
113  *
114  * The global value <code>true</code> is the only instance of class
115  * <code>TrueClass</code> and represents a logically true value in
116  * boolean expressions. The class provides operators allowing
117  * <code>true</code> to be used in logical expressions.
118  */
119 
120 /* 15.2.5.3.1 */
121 /*
122  * call-seq:
123  * true & obj -> true or false
124  *
125  * And---Returns <code>false</code> if <i>obj</i> is
126  * <code>nil</code> or <code>false</code>, <code>true</code> otherwise.
127  */
128 
129 static mrb_value
131 {
132  mrb_bool obj2;
133 
134  mrb_get_args(mrb, "b", &obj2);
135 
136  return mrb_bool_value(obj2);
137 }
138 
139 /* 15.2.5.3.2 */
140 /*
141  * call-seq:
142  * true ^ obj -> !obj
143  *
144  * Exclusive Or---Returns <code>true</code> if <i>obj</i> is
145  * <code>nil</code> or <code>false</code>, <code>false</code>
146  * otherwise.
147  */
148 
149 static mrb_value
151 {
152  mrb_bool obj2;
153 
154  mrb_get_args(mrb, "b", &obj2);
155  return mrb_bool_value(!obj2);
156 }
157 
158 /* 15.2.5.3.3 */
159 /*
160  * call-seq:
161  * true.to_s -> "true"
162  *
163  * The string representation of <code>true</code> is "true".
164  */
165 
166 static mrb_value
168 {
169  mrb_value str = mrb_str_new_lit_frozen(mrb, "true");
171  return str;
172 }
173 
174 /* 15.2.5.3.4 */
175 /*
176  * call-seq:
177  * true | obj -> true
178  *
179  * Or---Returns <code>true</code>. As <i>anObject</i> is an argument to
180  * a method call, it is always evaluated; there is no short-circuit
181  * evaluation in this case.
182  *
183  * true | puts("or")
184  * true || puts("logical or")
185  *
186  * <em>produces:</em>
187  *
188  * or
189  */
190 
191 static mrb_value
193 {
194  return mrb_true_value();
195 }
196 
197 /*
198  * Document-class: FalseClass
199  *
200  * The global value <code>false</code> is the only instance of class
201  * <code>FalseClass</code> and represents a logically false value in
202  * boolean expressions. The class provides operators allowing
203  * <code>false</code> to participate correctly in logical expressions.
204  *
205  */
206 
207 /* 15.2.4.3.1 */
208 /* 15.2.6.3.1 */
209 /*
210  * call-seq:
211  * false & obj -> false
212  * nil & obj -> false
213  *
214  * And---Returns <code>false</code>. <i>obj</i> is always
215  * evaluated as it is the argument to a method call---there is no
216  * short-circuit evaluation in this case.
217  */
218 
219 static mrb_value
221 {
222  return mrb_false_value();
223 }
224 
225 /* 15.2.4.3.2 */
226 /* 15.2.6.3.2 */
227 /*
228  * call-seq:
229  * false ^ obj -> true or false
230  * nil ^ obj -> true or false
231  *
232  * Exclusive Or---If <i>obj</i> is <code>nil</code> or
233  * <code>false</code>, returns <code>false</code>; otherwise, returns
234  * <code>true</code>.
235  *
236  */
237 
238 static mrb_value
240 {
241  mrb_bool obj2;
242 
243  mrb_get_args(mrb, "b", &obj2);
244  return mrb_bool_value(obj2);
245 }
246 
247 /* 15.2.4.3.3 */
248 /* 15.2.6.3.4 */
249 /*
250  * call-seq:
251  * false | obj -> true or false
252  * nil | obj -> true or false
253  *
254  * Or---Returns <code>false</code> if <i>obj</i> is
255  * <code>nil</code> or <code>false</code>; <code>true</code> otherwise.
256  */
257 
258 static mrb_value
260 {
261  mrb_bool obj2;
262 
263  mrb_get_args(mrb, "b", &obj2);
264  return mrb_bool_value(obj2);
265 }
266 
267 /* 15.2.6.3.3 */
268 /*
269  * call-seq:
270  * false.to_s -> "false"
271  *
272  * 'nuf said...
273  */
274 
275 static mrb_value
277 {
278  mrb_value str = mrb_str_new_lit_frozen(mrb, "false");
280  return str;
281 }
282 
283 void
285 {
286  struct RClass *n;
287  struct RClass *t;
288  struct RClass *f;
289 
290  mrb->nil_class = n = mrb_define_class(mrb, "NilClass", mrb->object_class);
292  mrb_undef_class_method(mrb, n, "new");
293  mrb_define_method(mrb, n, "&", false_and, MRB_ARGS_REQ(1)); /* 15.2.4.3.1 */
294  mrb_define_method(mrb, n, "^", false_xor, MRB_ARGS_REQ(1)); /* 15.2.4.3.2 */
295  mrb_define_method(mrb, n, "|", false_or, MRB_ARGS_REQ(1)); /* 15.2.4.3.3 */
296  mrb_define_method(mrb, n, "nil?", mrb_true, MRB_ARGS_NONE()); /* 15.2.4.3.4 */
297  mrb_define_method(mrb, n, "to_s", nil_to_s, MRB_ARGS_NONE()); /* 15.2.4.3.5 */
298  mrb_define_method(mrb, n, "inspect", nil_inspect, MRB_ARGS_NONE());
299 
300  mrb->true_class = t = mrb_define_class(mrb, "TrueClass", mrb->object_class);
302  mrb_undef_class_method(mrb, t, "new");
303  mrb_define_method(mrb, t, "&", true_and, MRB_ARGS_REQ(1)); /* 15.2.5.3.1 */
304  mrb_define_method(mrb, t, "^", true_xor, MRB_ARGS_REQ(1)); /* 15.2.5.3.2 */
305  mrb_define_method(mrb, t, "to_s", true_to_s, MRB_ARGS_NONE()); /* 15.2.5.3.3 */
306  mrb_define_method(mrb, t, "|", true_or, MRB_ARGS_REQ(1)); /* 15.2.5.3.4 */
307  mrb_define_method(mrb, t, "inspect", true_to_s, MRB_ARGS_NONE());
308 
309  mrb->false_class = f = mrb_define_class(mrb, "FalseClass", mrb->object_class);
311  mrb_undef_class_method(mrb, f, "new");
312  mrb_define_method(mrb, f, "&", false_and, MRB_ARGS_REQ(1)); /* 15.2.6.3.1 */
313  mrb_define_method(mrb, f, "^", false_xor, MRB_ARGS_REQ(1)); /* 15.2.6.3.2 */
314  mrb_define_method(mrb, f, "to_s", false_to_s, MRB_ARGS_NONE()); /* 15.2.6.3.3 */
315  mrb_define_method(mrb, f, "|", false_or, MRB_ARGS_REQ(1)); /* 15.2.6.3.4 */
316  mrb_define_method(mrb, f, "inspect", false_to_s, MRB_ARGS_NONE());
317 }
318 
319 static const struct types {
320  const enum mrb_vtype type;
321  const char *name;
322 } builtin_types[] = {
323 /* {MRB_TT_NIL, "nil"}, */
324  {MRB_TT_FALSE, "false"},
325  {MRB_TT_TRUE, "true"},
326  {MRB_TT_INTEGER,"Integer"},
327  {MRB_TT_SYMBOL, "Symbol"}, /* :symbol */
328  {MRB_TT_MODULE, "Module"},
329  {MRB_TT_OBJECT, "Object"},
330  {MRB_TT_CLASS, "Class"},
331  {MRB_TT_ICLASS, "iClass"}, /* internal use: mixed-in module holder */
332  {MRB_TT_SCLASS, "SClass"},
333  {MRB_TT_PROC, "Proc"},
334 #ifndef MRB_NO_FLOAT
335  {MRB_TT_FLOAT, "Float"},
336 #endif
337  {MRB_TT_ARRAY, "Array"},
338  {MRB_TT_HASH, "Hash"},
339  {MRB_TT_STRING, "String"},
340  {MRB_TT_RANGE, "Range"},
341 /* {MRB_TT_BIGNUM, "Bignum"}, */
342  {MRB_TT_DATA, "Data"}, /* internal use: wrapped C pointers */
343 /* {MRB_TT_UNDEF, "undef"}, */ /* internal use: #undef; should not happen */
344  {MRB_TT_MAXDEFINE, 0}
345 };
346 
347 static const char*
349 {
350  const struct types *type = builtin_types;
351 
352  while (type->type < MRB_TT_MAXDEFINE) {
353  if (type->type == t) return type->name;
354  type++;
355  }
356  return NULL;
357 }
358 
359 static mrb_value
360 convert_type(mrb_state *mrb, mrb_value val, const char *tname, mrb_sym method, mrb_bool raise)
361 {
362  if (!mrb_respond_to(mrb, val, method)) {
363  if (raise) {
364  if (tname) mrb_raisef(mrb, E_TYPE_ERROR, "can't convert %Y into %s", val, tname);
365  mrb_raisef(mrb, E_TYPE_ERROR, "can't convert %Y", val);
366  }
367  return mrb_nil_value();
368  }
369  return mrb_funcall_argv(mrb, val, method, 0, 0);
370 }
371 
374 {
375  mrb_value v;
376  const char *tname;
377 
378  if (mrb_type(val) == type) return val;
379  tname = type_name(type);
380  v = convert_type(mrb, val, tname, method, TRUE);
381  if (mrb_type(v) != type) {
382  if (type == MRB_TT_STRING) return mrb_any_to_s(mrb, val);
383  mrb_raisef(mrb, E_TYPE_ERROR, "%v cannot be converted to %s by #%n", val, tname, method);
384  }
385  return v;
386 }
387 
390 {
391  mrb_value v;
392 
393  if (mrb_type(val) == type && type != MRB_TT_DATA && type != MRB_TT_ISTRUCT) return val;
394  v = convert_type(mrb, val, type_name(type), method, FALSE);
395  if (mrb_nil_p(v) || mrb_type(v) != type) return mrb_nil_value();
396  return v;
397 }
398 
399 MRB_API void
401 {
402  enum mrb_vtype xt = mrb_type(x);
403  const char *tname, *ename;
404 
405  if (t == xt) return;
406 
407  tname = type_name(t);
408  if (mrb_nil_p(x)) {
409  ename = "nil";
410  }
411  else if (mrb_integer_p(x)) {
412  ename = "Fixnum";
413  }
414  else if (mrb_symbol_p(x)) {
415  ename = "Symbol";
416  }
417  else if (mrb_immediate_p(x)) {
418  ename = RSTRING_PTR(mrb_obj_as_string(mrb, x));
419  }
420  else {
421  ename = mrb_obj_classname(mrb, x);
422  }
423  if (tname) {
424  mrb_raisef(mrb, E_TYPE_ERROR, "wrong argument type %s (expected %s)",
425  ename, tname);
426  }
427  mrb_raisef(mrb, E_TYPE_ERROR, "unknown type %d (%s given)", t, ename);
428 }
429 
430 /* 15.3.1.3.46 */
431 /*
432  * call-seq:
433  * obj.to_s => string
434  *
435  * Returns a string representing <i>obj</i>. The default
436  * <code>to_s</code> prints the object's class and an encoding of the
437  * object id. As a special case, the top-level object that is the
438  * initial execution context of Ruby programs returns "main."
439  */
440 
443 {
444  mrb_value str = mrb_str_new_capa(mrb, 20);
445  const char *cname = mrb_obj_classname(mrb, obj);
446 
447  mrb_str_cat_lit(mrb, str, "#<");
448  mrb_str_cat_cstr(mrb, str, cname);
449  if (!mrb_immediate_p(obj)) {
450  mrb_str_cat_lit(mrb, str, ":");
451  mrb_str_cat_str(mrb, str, mrb_ptr_to_str(mrb, mrb_ptr(obj)));
452  }
453  mrb_str_cat_lit(mrb, str, ">");
454 
455  return str;
456 }
457 
458 /*
459  * call-seq:
460  * obj.is_a?(class) => true or false
461  * obj.kind_of?(class) => true or false
462  *
463  * Returns <code>true</code> if <i>class</i> is the class of
464  * <i>obj</i>, or if <i>class</i> is one of the superclasses of
465  * <i>obj</i> or modules included in <i>obj</i>.
466  *
467  * module M; end
468  * class A
469  * include M
470  * end
471  * class B < A; end
472  * class C < B; end
473  * b = B.new
474  * b.instance_of? A #=> false
475  * b.instance_of? B #=> true
476  * b.instance_of? C #=> false
477  * b.instance_of? M #=> false
478  * b.kind_of? A #=> true
479  * b.kind_of? B #=> true
480  * b.kind_of? C #=> false
481  * b.kind_of? M #=> true
482  */
483 
486 {
487  struct RClass *cl = mrb_class(mrb, obj);
488 
489  switch (c->tt) {
490  case MRB_TT_MODULE:
491  case MRB_TT_CLASS:
492  case MRB_TT_ICLASS:
493  case MRB_TT_SCLASS:
494  break;
495 
496  default:
497  mrb_raise(mrb, E_TYPE_ERROR, "class or module required");
498  }
499 
501  while (cl) {
502  if (cl == c || cl->mt == c->mt)
503  return TRUE;
504  cl = cl->super;
505  }
506  return FALSE;
507 }
508 
511 {
512 
513  if (!mrb_integer_p(val)) {
514 #ifndef MRB_NO_FLOAT
515  if (mrb_float_p(val)) {
516  return mrb_flo_to_fixnum(mrb, val);
517  }
518 #endif
519  mrb_raisef(mrb, E_TYPE_ERROR, "can't convert %Y to Integer", val);
520  }
521  return val;
522 }
523 
526 {
527  mrb_value tmp;
528 
529  if (mrb_nil_p(val)) {
530  if (base != 0) goto arg_error;
531  mrb_raise(mrb, E_TYPE_ERROR, "can't convert nil into Integer");
532  }
533  switch (mrb_type(val)) {
534 #ifndef MRB_NO_FLOAT
535  case MRB_TT_FLOAT:
536  if (base != 0) goto arg_error;
537  return mrb_flo_to_fixnum(mrb, val);
538 #endif
539 
540  case MRB_TT_INTEGER:
541  if (base != 0) goto arg_error;
542  return val;
543 
544  case MRB_TT_STRING:
545  string_conv:
546  return mrb_str_to_inum(mrb, val, base, TRUE);
547 
548  default:
549  break;
550  }
551  if (base != 0) {
552  tmp = mrb_check_string_type(mrb, val);
553  if (!mrb_nil_p(tmp)) {
554  val = tmp;
555  goto string_conv;
556  }
557 arg_error:
558  mrb_raise(mrb, E_ARGUMENT_ERROR, "base specified for non string value");
559  }
560  /* to raise TypeError */
561  return mrb_to_int(mrb, val);
562 }
563 
566 {
567  return mrb_convert_to_integer(mrb, val, 0);
568 }
569 
570 #ifndef MRB_NO_FLOAT
573 {
574  if (mrb_nil_p(val)) {
575  mrb_raise(mrb, E_TYPE_ERROR, "can't convert nil into Float");
576  }
577  switch (mrb_type(val)) {
578  case MRB_TT_INTEGER:
579  return mrb_float_value(mrb, (mrb_float)mrb_integer(val));
580 
581  case MRB_TT_FLOAT:
582  return val;
583 
584  case MRB_TT_STRING:
585  return mrb_float_value(mrb, mrb_str_to_dbl(mrb, val, TRUE));
586 
587  default:
588  return mrb_type_convert(mrb, val, MRB_TT_FLOAT, MRB_SYM(to_f));
589  }
590 }
591 #endif
592 
595 {
596  return mrb_ensure_string_type(mrb, val);
597 }
598 
599 /* obsolete: use mrb_ensure_string_type() instead */
602 {
603  return mrb_ensure_string_type(mrb, str);
604 }
605 
608 {
609  if (!mrb_string_p(str)) {
610  mrb_raisef(mrb, E_TYPE_ERROR, "%Y cannot be converted to String", str);
611  }
612  return str;
613 }
614 
617 {
618  if (!mrb_string_p(str)) return mrb_nil_value();
619  return str;
620 }
621 
624 {
625  if (!mrb_array_p(ary)) {
626  mrb_raisef(mrb, E_TYPE_ERROR, "%Y cannot be converted to Array", ary);
627  }
628  return ary;
629 }
630 
633 {
634  if (!mrb_array_p(ary)) return mrb_nil_value();
635  return ary;
636 }
637 
640 {
641  if (!mrb_hash_p(hash)) {
642  mrb_raisef(mrb, E_TYPE_ERROR, "%Y cannot be converted to Hash", hash);
643  }
644  return hash;
645 }
646 
649 {
650  if (!mrb_hash_p(hash)) return mrb_nil_value();
651  return hash;
652 }
653 
656 {
657  return mrb_obj_as_string(mrb, mrb_funcall_id(mrb, obj, MRB_SYM(inspect), 0));
658 }
659 
662 {
663  if (mrb_obj_eq(mrb, obj1, obj2)) return TRUE;
664  return mrb_test(mrb_funcall_id(mrb, obj1, MRB_SYM_Q(eql), 1, obj2));
665 }
#define type(a)
Definition: aptex-macros.h:171
#define hash
Definition: aptex.h:388
#define mrb_symbol(o)
Definition: boxing_nan.h:72
#define mrb_integer(o)
Definition: boxing_nan.h:71
#define mrb_ptr(o)
Definition: boxing_nan.h:79
#define mrb_string_p(o)
Definition: boxing_word.h:153
#define mrb_integer_p(o)
Definition: boxing_word.h:139
#define mrb_symbol_p(o)
Definition: boxing_word.h:143
#define mrb_array_p(o)
Definition: boxing_word.h:152
#define mrb_immediate_p(o)
Definition: boxing_word.h:117
#define mrb_float_p(o)
Definition: boxing_word.h:150
#define mrb_nil_p(o)
Definition: boxing_word.h:146
#define mrb_hash_p(o)
Definition: boxing_word.h:154
MRB_INLINE enum mrb_vtype mrb_type(mrb_value o)
Definition: boxing_word.h:195
#define MRB_SET_INSTANCE_TT(c, tt)
Definition: class.h:73
#define MRB_CLASS_ORIGIN(c)
Definition: class.h:63
static struct RClass * mrb_class(mrb_state *mrb, mrb_value v)
Definition: class.h:27
#define n
Definition: t4ht.c:1290
@ FALSE
Definition: dd.h:101
@ TRUE
Definition: dd.h:102
#define MRB_OPSYM(name)
Definition: disable.h:14
#define MRB_SYM(name)
Definition: disable.h:20
#define MRB_SYM_Q(name)
Definition: disable.h:18
int v
Definition: dviconv.c:10
mpz_t * f
Definition: gen-fib.c:34
#define v1
#define v2
#define t
Definition: afcover.h:96
#define c(n)
Definition: gpos-common.c:150
int base
Definition: gsftopk.c:1502
#define NULL
Definition: ftobjs.h:61
#define E_TYPE_ERROR
Definition: mruby.h:1308
void mrb_raisef(mrb_state *mrb, struct RClass *c, const char *fmt,...)
Definition: error.c:400
mrb_value mrb_funcall_id(mrb_state *mrb, mrb_value val, mrb_sym mid, mrb_int argc,...)
Definition: vm.c:337
#define mrb_str_new_frozen(mrb, p, len)
Definition: mruby.h:1139
mrb_value mrb_funcall_argv(mrb_state *mrb, mrb_value val, mrb_sym name, mrb_int argc, const mrb_value *argv)
Definition: vm.c:481
mrb_int mrb_get_args(mrb_state *mrb, mrb_args_format format,...)
Definition: class.c:891
#define mrb_str_new_lit_frozen(mrb, lit)
Definition: mruby.h:1142
void mrb_raise(mrb_state *mrb, struct RClass *c, const char *msg)
Definition: error.c:214
mrb_bool mrb_respond_to(mrb_state *mrb, mrb_value obj, mrb_sym mid)
Definition: class.c:2067
#define MRB_ARGS_NONE()
Definition: mruby.h:879
#define MRB_ARGS_REQ(n)
Definition: mruby.h:837
void mrb_undef_class_method(mrb_state *mrb, struct RClass *cls, const char *name)
Definition: class.c:2308
const char * mrb_obj_classname(mrb_state *mrb, mrb_value obj)
Definition: class.c:2112
#define E_ARGUMENT_ERROR
Definition: mruby.h:1310
float x
Definition: cordic.py:15
mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val)
Definition: numeric.c:1259
#define MRB_API
Definition: common.h:73
#define mrb_define_method(mrb, c, name, f, a)
Definition: scanning.h:15
#define mrb_define_class(mrb, name, s)
Definition: scanning.h:18
#define str(s)
Definition: sh6.c:399
mrb_bool mrb_obj_is_kind_of(mrb_state *mrb, mrb_value obj, struct RClass *c)
Definition: object.c:485
static mrb_value true_and(mrb_state *mrb, mrb_value obj)
Definition: object.c:130
static mrb_value false_to_s(mrb_state *mrb, mrb_value obj)
Definition: object.c:276
static mrb_value true_xor(mrb_state *mrb, mrb_value obj)
Definition: object.c:150
mrb_value mrb_to_str(mrb_state *mrb, mrb_value val)
Definition: object.c:594
static mrb_value true_or(mrb_state *mrb, mrb_value obj)
Definition: object.c:192
static mrb_value convert_type(mrb_state *mrb, mrb_value val, const char *tname, mrb_sym method, mrb_bool raise)
Definition: object.c:360
static const struct types builtin_types[]
mrb_value mrb_Integer(mrb_state *mrb, mrb_value val)
Definition: object.c:565
static mrb_value mrb_true(mrb_state *mrb, mrb_value obj)
Definition: object.c:82
void mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t)
Definition: object.c:400
mrb_value mrb_any_to_s(mrb_state *mrb, mrb_value obj)
Definition: object.c:442
static mrb_value false_and(mrb_state *mrb, mrb_value obj)
Definition: object.c:220
static const char * type_name(enum mrb_vtype t)
Definition: object.c:348
mrb_bool mrb_obj_eq(mrb_state *mrb, mrb_value v1, mrb_value v2)
Definition: object.c:15
mrb_value mrb_ensure_array_type(mrb_state *mrb, mrb_value ary)
Definition: object.c:623
void mrb_init_object(mrb_state *mrb)
Definition: object.c:284
mrb_value mrb_inspect(mrb_state *mrb, mrb_value obj)
Definition: object.c:655
mrb_value mrb_check_string_type(mrb_state *mrb, mrb_value str)
Definition: object.c:616
mrb_value mrb_ensure_hash_type(mrb_state *mrb, mrb_value hash)
Definition: object.c:639
static mrb_value false_xor(mrb_state *mrb, mrb_value obj)
Definition: object.c:239
mrb_value mrb_string_type(mrb_state *mrb, mrb_value str)
Definition: object.c:601
mrb_value mrb_check_array_type(mrb_state *mrb, mrb_value ary)
Definition: object.c:632
mrb_value mrb_ensure_string_type(mrb_state *mrb, mrb_value str)
Definition: object.c:607
mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash)
Definition: object.c:648
static mrb_value nil_to_s(mrb_state *mrb, mrb_value obj)
Definition: object.c:96
mrb_bool mrb_equal(mrb_state *mrb, mrb_value obj1, mrb_value obj2)
Definition: object.c:46
mrb_value mrb_convert_to_integer(mrb_state *mrb, mrb_value val, mrb_int base)
Definition: object.c:525
static mrb_value true_to_s(mrb_state *mrb, mrb_value obj)
Definition: object.c:167
mrb_value mrb_to_int(mrb_state *mrb, mrb_value val)
Definition: object.c:510
static mrb_value false_or(mrb_state *mrb, mrb_value obj)
Definition: object.c:259
mrb_value mrb_type_convert(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method)
Definition: object.c:373
static mrb_value nil_inspect(mrb_state *mrb, mrb_value obj)
Definition: object.c:104
mrb_bool mrb_eql(mrb_state *mrb, mrb_value obj1, mrb_value obj2)
Definition: object.c:661
mrb_value mrb_Float(mrb_state *mrb, mrb_value val)
Definition: object.c:572
mrb_bool mrb_obj_equal(mrb_state *mrb, mrb_value v1, mrb_value v2)
Definition: object.c:39
mrb_value mrb_type_convert_check(mrb_state *mrb, mrb_value val, enum mrb_vtype type, mrb_sym method)
Definition: object.c:389
#define mrb_str_ptr(s)
Definition: string.h:98
mrb_value mrb_str_to_inum(mrb_state *mrb, mrb_value str, mrb_int base, mrb_bool badcheck)
Definition: string.c:2421
mrb_value mrb_str_cat_cstr(mrb_state *mrb, mrb_value str, const char *ptr)
Definition: string.c:2714
mrb_value mrb_obj_as_string(mrb_state *mrb, mrb_value obj)
Definition: string.c:1913
#define mrb_str_cat_lit(mrb, str, lit)
Definition: string.h:417
#define RSTRING_PTR(s)
Definition: string.h:100
mrb_value mrb_str_new_capa(mrb_state *mrb, size_t capa)
Definition: string.c:160
#define RSTR_SET_ASCII_FLAG(s)
Definition: string.h:89
mrb_value mrb_ptr_to_str(mrb_state *mrb, void *p)
Definition: string.c:1932
mrb_value mrb_str_cat_str(mrb_state *mrb, mrb_value str, mrb_value str2)
Definition: string.c:2720
double mrb_str_to_dbl(mrb_state *mrb, mrb_value str, mrb_bool badcheck)
Definition: string.c:2562
Definition: class.h:17
struct RClass * super
Definition: class.h:21
struct mt_tbl * mt
Definition: class.h:20
struct RClass * true_class
Definition: mruby.h:255
struct RClass * object_class
Definition: mruby.h:242
struct RClass * false_class
Definition: mruby.h:256
struct RClass * nil_class
Definition: mruby.h:257
Definition: dvips.h:235
Definition: object.c:319
const char * name
Definition: object.c:321
enum mrb_vtype type
Definition: object.c:320
Definition: strexpr.c:21
val
Definition: tex4ht.c:3227
#define mrb_test(o)
Definition: value.h:265
static mrb_value mrb_true_value(void)
Definition: value.h:352
int32_t mrb_int
Definition: value.h:35
static mrb_value mrb_false_value(void)
Definition: value.h:342
static mrb_value mrb_nil_value(void)
Definition: value.h:332
static mrb_value mrb_bool_value(mrb_bool boolean)
Definition: value.h:360
static mrb_value mrb_float_value(struct mrb_state *mrb, mrb_float f)
Definition: value.h:273
double mrb_float
Definition: value.h:85
mrb_vtype
Definition: value.h:107
@ MRB_TT_DATA
Definition: value.h:128
@ MRB_TT_TRUE
Definition: value.h:109
@ MRB_TT_SCLASS
Definition: value.h:120
@ MRB_TT_CLASS
Definition: value.h:117
@ MRB_TT_OBJECT
Definition: value.h:116
@ MRB_TT_STRING
Definition: value.h:124
@ MRB_TT_RANGE
Definition: value.h:125
@ MRB_TT_FALSE
Definition: value.h:108
@ MRB_TT_MODULE
Definition: value.h:118
@ MRB_TT_HASH
Definition: value.h:123
@ MRB_TT_SYMBOL
Definition: value.h:112
@ MRB_TT_ICLASS
Definition: value.h:119
@ MRB_TT_ARRAY
Definition: value.h:122
@ MRB_TT_FLOAT
Definition: value.h:110
@ MRB_TT_PROC
Definition: value.h:121
@ MRB_TT_MAXDEFINE
Definition: value.h:132
@ MRB_TT_INTEGER
Definition: value.h:111
@ MRB_TT_ISTRUCT
Definition: value.h:130