Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 82 lines (64 sloc) 1.655 kB
817a62d 2000-05-01
matz authored
1 /**********************************************************************
07bb9f2 1.4.0
matz authored
2
21d0b07 1.4.1
matz authored
3 prec.c -
07bb9f2 1.4.0
matz authored
4
5 $Author$
6 $Date$
56e60da 20000105
matz authored
7 created at: Tue Jan 26 02:40:41 2000
07bb9f2 1.4.0
matz authored
8
60dec36 * dir.c (dir_s_glob): supprt backslash escape of metacharacters
matz authored
9 Copyright (C) 1993-2001 Yukihiro Matsumoto
07bb9f2 1.4.0
matz authored
10
817a62d 2000-05-01
matz authored
11 **********************************************************************/
07bb9f2 1.4.0
matz authored
12
13 #include "ruby.h"
14
15 VALUE rb_mPrecision;
16
17 static ID prc_pr, prc_if;
18
19 static VALUE
20 prec_prec(x, klass)
21 VALUE x, klass;
22 {
23 return rb_funcall(klass, prc_if, 1, x);
24 }
25
26 static VALUE
27 prec_prec_i(x)
28 VALUE x;
29 {
30 VALUE klass = rb_cInteger;
31
32 return rb_funcall(x, prc_pr, 1, klass);
33 }
34
35 static VALUE
36 prec_prec_f(x)
37 VALUE x;
38 {
39 VALUE klass = rb_cFloat;
40
41 return rb_funcall(x, prc_pr, 1, klass);
42 }
43
44 static VALUE
45 prec_induced_from(module, x)
0c27272 Mon Jan 15 16:00:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
matz authored
46 VALUE module, x;
07bb9f2 1.4.0
matz authored
47 {
48 rb_raise(rb_eTypeError, "undefined conversion from %s into %s",
49 rb_class2name(CLASS_OF(x)), rb_class2name(module));
3b94766 * object.c (rb_str2cstr): warn if string contains \0 and length
matz authored
50 return Qnil; /* not reached */
07bb9f2 1.4.0
matz authored
51 }
52
53 static VALUE
73a5993 * parse.y (yylex): ternary ? can be followed by newline.
matz authored
54 prec_included(module, include)
07bb9f2 1.4.0
matz authored
55 VALUE module, include;
56 {
57 switch (TYPE(include)) {
58 case T_CLASS:
59 case T_MODULE:
60 break;
61 default:
62 Check_Type(include, T_CLASS);
63 break;
64 }
65 rb_define_singleton_method(include, "induced_from", prec_induced_from, 1);
66 return module;
67 }
68
69
70 void
71 Init_Precision()
72 {
73 rb_mPrecision = rb_define_module("Precision");
73a5993 * parse.y (yylex): ternary ? can be followed by newline.
matz authored
74 rb_define_singleton_method(rb_mPrecision, "included", prec_included, 1);
07bb9f2 1.4.0
matz authored
75 rb_define_method(rb_mPrecision, "prec", prec_prec, 1);
76 rb_define_method(rb_mPrecision, "prec_i", prec_prec_i, 0);
77 rb_define_method(rb_mPrecision, "prec_f", prec_prec_f, 0);
78
79 prc_pr = rb_intern("prec");
80 prc_if = rb_intern("induced_from");
81 }
Something went wrong with that request. Please try again.