Ruby
2.1.3p242(2014-09-19revision47630)
Main Page
Modules
Data Structures
Files
File List
Globals
ext
psych
psych_to_ruby.c
Go to the documentation of this file.
1
#include <
psych.h
>
2
3
VALUE
cPsychVisitorsToRuby
;
4
5
/* call-seq: vis.build_exception(klass, message)
6
*
7
* Create an exception with class +klass+ and +message+
8
*/
9
static
VALUE
build_exception
(
VALUE
self
,
VALUE
klass,
VALUE
mesg)
10
{
11
VALUE
e =
rb_obj_alloc
(klass);
12
13
rb_iv_set
(e,
"mesg"
, mesg);
14
15
return
e;
16
}
17
18
/* call-seq: vis.path2class(path)
19
*
20
* Convert +path+ string to a class
21
*/
22
static
VALUE
path2class
(
VALUE
self
,
VALUE
path)
23
{
24
#ifdef HAVE_RUBY_ENCODING_H
25
return
rb_path_to_class
(path);
26
#else
27
return
rb_path2class
(
StringValuePtr
(path));
28
#endif
29
}
30
31
void
Init_psych_to_ruby
(
void
)
32
{
33
VALUE
psych =
rb_define_module
(
"Psych"
);
34
VALUE
class_loader =
rb_define_class_under
(psych,
"ClassLoader"
,
rb_cObject
);
35
36
VALUE
visitors =
rb_define_module_under
(psych,
"Visitors"
);
37
VALUE
visitor =
rb_define_class_under
(visitors,
"Visitor"
,
rb_cObject
);
38
cPsychVisitorsToRuby
=
rb_define_class_under
(visitors,
"ToRuby"
, visitor);
39
40
rb_define_private_method
(
cPsychVisitorsToRuby
,
"build_exception"
,
build_exception
, 2);
41
rb_define_private_method
(class_loader,
"path2class"
,
path2class
, 1);
42
}
43
/* vim: set noet sws=4 sw=4: */
44
Generated on Mon Sep 22 2014 11:05:26 for Ruby by
1.8.2