• Main Page
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

ext/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 visitors  = rb_define_module_under(psych, "Visitors");
00035     VALUE visitor   = rb_define_class_under(visitors, "Visitor", rb_cObject);
00036     cPsychVisitorsToRuby = rb_define_class_under(visitors, "ToRuby", visitor);
00037 
00038     rb_define_private_method(cPsychVisitorsToRuby, "build_exception", build_exception, 2);
00039     rb_define_private_method(cPsychVisitorsToRuby, "path2class", path2class, 1);
00040 }
00041 /* vim: set noet sws=4 sw=4: */
00042 

Generated on Wed Sep 8 2010 21:54:15 for Ruby by  doxygen 1.7.1