Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

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 return rb_path_to_class(path);
25 }
26
27 void Init_psych_to_ruby(void)
28 {
29 VALUE psych = rb_define_module("Psych");
30 VALUE class_loader = rb_define_class_under(psych, "ClassLoader", rb_cObject);
31
32 VALUE visitors = rb_define_module_under(psych, "Visitors");
33 VALUE visitor = rb_define_class_under(visitors, "Visitor", rb_cObject);
34 cPsychVisitorsToRuby = rb_define_class_under(visitors, "ToRuby", visitor);
35
36 rb_define_private_method(cPsychVisitorsToRuby, "build_exception", build_exception, 2);
37 rb_define_private_method(class_loader, "path2class", path2class, 1);
38 }
39 /* vim: set noet sws=4 sw=4: */
path
VALUE path
Definition: rb_mjit_min_header-2.7.0.h:7351
rb_define_module_under
VALUE rb_define_module_under(VALUE outer, const char *name)
Definition: class.c:797
VALUE
unsigned long VALUE
Definition: ruby.h:102
rb_define_module
VALUE rb_define_module(const char *name)
Definition: class.c:772
Init_psych_to_ruby
void Init_psych_to_ruby(void)
Definition: psych_to_ruby.c:27
cPsychVisitorsToRuby
VALUE cPsychVisitorsToRuby
Definition: psych_to_ruby.c:3
psych.h
rb_cObject
RUBY_EXTERN VALUE rb_cObject
Definition: ruby.h:2010
klass
VALUE klass
Definition: rb_mjit_min_header-2.7.0.h:13254
rb_obj_alloc
VALUE rb_obj_alloc(VALUE)
Allocates an instance of klass.
Definition: object.c:1895
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:698
rb_path_to_class
VALUE rb_path_to_class(VALUE)
Definition: variable.c:226
rb_define_private_method
void rb_define_private_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
Definition: class.c:1569
rb_iv_set
VALUE rb_iv_set(VALUE, const char *, VALUE)
Definition: variable.c:3307