Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

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 visitors = rb_define_module_under(psych, "Visitors");
35 VALUE visitor = rb_define_class_under(visitors, "Visitor", rb_cObject);
36 cPsychVisitorsToRuby = rb_define_class_under(visitors, "ToRuby", visitor);
37
38 rb_define_private_method(cPsychVisitorsToRuby, "build_exception", build_exception, 2);
39 rb_define_private_method(cPsychVisitorsToRuby, "path2class", path2class, 1);
40 }
41 /* vim: set noet sws=4 sw=4: */
rb_iv_set
VALUE rb_iv_set(VALUE, const char *, VALUE)
Definition: variable.c:2591
rb_define_private_method
void rb_define_private_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
Definition: class.c:1356
path
gz path
Definition: zlib.c:2279
rb_define_class_under
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
Definition: class.c:545
rb_path2class
VALUE rb_path2class(const char *)
Definition: variable.c:371
rb_path_to_class
VALUE rb_path_to_class(VALUE)
Definition: variable.c:331
psych.h
cPsychVisitorsToRuby
VALUE cPsychVisitorsToRuby
Definition: psych_to_ruby.c:3
path2class
static VALUE path2class(VALUE self, VALUE path)
Definition: psych_to_ruby.c:22
StringValuePtr
#define StringValuePtr(v)
Init_psych_to_ruby
void Init_psych_to_ruby(void)
Definition: psych_to_ruby.c:31
rb_define_module_under
VALUE rb_define_module_under(VALUE outer, const char *name)
Definition: class.c:637
rb_cObject
RUBY_EXTERN VALUE rb_cObject
Definition: ripper.y:1426
klass
klass
Definition: tcltklib.c:3504
rb_obj_alloc
VALUE rb_obj_alloc(VALUE)
Definition: object.c:1721
e
BDIGIT e
Definition: bigdecimal.c:5085
VALUE
unsigned long VALUE
Definition: ripper.y:104
rb_define_module
VALUE rb_define_module(const char *name)
Definition: class.c:617
build_exception
static VALUE build_exception(VALUE self, VALUE klass, VALUE mesg)
Definition: psych_to_ruby.c:9