Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 83 lines (65 sloc) 1.716 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
54 prec_append_features(module, include)
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_include_module(include, module);
66 rb_define_singleton_method(include, "induced_from", prec_induced_from, 1);
67 return module;
68 }
69
70
71 void
72 Init_Precision()
73 {
74 rb_mPrecision = rb_define_module("Precision");
75 rb_define_singleton_method(rb_mPrecision, "append_features", prec_append_features, 1);
76 rb_define_method(rb_mPrecision, "prec", prec_prec, 1);
77 rb_define_method(rb_mPrecision, "prec_i", prec_prec_i, 0);
78 rb_define_method(rb_mPrecision, "prec_f", prec_prec_f, 0);
79
80 prc_pr = rb_intern("prec");
81 prc_if = rb_intern("induced_from");
82 }
Something went wrong with that request. Please try again.