ext/psych/psych_to_ruby.c

Go to the documentation of this file.
00001 #include <psych.h>
00002 
00003 VALUE cPsychVisitorsToRuby;
00004 
00005 /* call-seq: vis.build_exception(klass, message)
00006  *
00007  * Create an exception with class +klass+ and +message+
00008  */
00009 static VALUE build_exception(VALUE self, VALUE klass, VALUE mesg)
00010 {
00011     VALUE e = rb_obj_alloc(klass);
00012 
00013     rb_iv_set(e, "mesg", mesg);
00014 
00015     return e;
00016 }
00017 
00018 /* call-seq: vis.path2class(path)
00019  *
00020  * Convert +path+ string to a class
00021  */
00022 static VALUE path2class(VALUE self, VALUE path)
00023 {
00024 #ifdef HAVE_RUBY_ENCODING_H
00025     return rb_path_to_class(path);
00026 #else
00027     return rb_path2class(StringValuePtr(path));
00028 #endif
00029 }
00030 
00031 void Init_psych_to_ruby(void)
00032 {
00033     VALUE psych     = rb_define_module("Psych");
00034     VALUE class_loader  = rb_define_class_under(psych, "ClassLoader", rb_cObject);
00035 
00036     VALUE visitors  = rb_define_module_under(psych, "Visitors");
00037     VALUE visitor   = rb_define_class_under(visitors, "Visitor", rb_cObject);
00038     cPsychVisitorsToRuby = rb_define_class_under(visitors, "ToRuby", visitor);
00039 
00040     rb_define_private_method(cPsychVisitorsToRuby, "build_exception", build_exception, 2);
00041     rb_define_private_method(class_loader, "path2class", path2class, 1);
00042 }
00043 /* vim: set noet sws=4 sw=4: */
00044 

Generated on 19 Jul 2016 for Ruby by  doxygen 1.4.7