[前][次][番号順一覧][スレッド一覧]

ruby-changes:25862

From: tenderlove <ko1@a...>
Date: Wed, 28 Nov 2012 13:34:56 +0900 (JST)
Subject: [ruby-changes:25862] tenderlove:r37919 (trunk): * ext/psych/extconf.rb: use embedded libyaml if no system libyaml is

tenderlove	2012-11-28 13:34:41 +0900 (Wed, 28 Nov 2012)

  New Revision: 37919

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37919

  Log:
    * ext/psych/extconf.rb: use embedded libyaml if no system libyaml is
      found. [ruby-core:49463]
    * ext/psych/lib/psych.rb: updating to psych 2.0.0
    * ext/psych/lib/psych/deprecated.rb: updated docs
    * ext/psych/psych.gemspec: updated to psych 2.0.0
    * ext/psych/psych.h: fixing header file include for rename
    * ext/psych/psych_emitter.c: renamed to avoid libyaml conflict.
    * ext/psych/psych_emitter.h: ditto
    * ext/psych/psych_parser.c: ditto
    * ext/psych/psych_parser.h: ditto
    * ext/psych/psych_to_ruby.c: ditto
    * ext/psych/psych_to_ruby.h: ditto
    * ext/psych/psych_yaml_tree.c: ditto
    * ext/psych/psych_yaml_tree.h: ditto
    * ext/psych/yaml/LICENSE: embedding libyaml 0.1.4
    * ext/psych/yaml/api.c: ditto
    * ext/psych/yaml/config.h: ditto
    * ext/psych/yaml/dumper.c: ditto
    * ext/psych/yaml/emitter.c: ditto
    * ext/psych/yaml/loader.c: ditto
    * ext/psych/yaml/parser.c: ditto
    * ext/psych/yaml/reader.c: ditto
    * ext/psych/yaml/scanner.c: ditto
    * ext/psych/yaml/writer.c: ditto
    * ext/psych/yaml/yaml.h: ditto
    * ext/psych/yaml/yaml_private.h: ditto

  Added directories:
    trunk/ext/psych/yaml/
  Added files:
    trunk/ext/psych/.gitignore
    trunk/ext/psych/psych_emitter.c
    trunk/ext/psych/psych_emitter.h
    trunk/ext/psych/psych_parser.c
    trunk/ext/psych/psych_parser.h
    trunk/ext/psych/psych_to_ruby.c
    trunk/ext/psych/psych_to_ruby.h
    trunk/ext/psych/psych_yaml_tree.c
    trunk/ext/psych/psych_yaml_tree.h
    trunk/ext/psych/yaml/LICENSE
    trunk/ext/psych/yaml/api.c
    trunk/ext/psych/yaml/config.h
    trunk/ext/psych/yaml/dumper.c
    trunk/ext/psych/yaml/emitter.c
    trunk/ext/psych/yaml/loader.c
    trunk/ext/psych/yaml/parser.c
    trunk/ext/psych/yaml/reader.c
    trunk/ext/psych/yaml/scanner.c
    trunk/ext/psych/yaml/writer.c
    trunk/ext/psych/yaml/yaml.h
    trunk/ext/psych/yaml/yaml_private.h
  Removed files:
    trunk/ext/psych/emitter.c
    trunk/ext/psych/emitter.h
    trunk/ext/psych/parser.c
    trunk/ext/psych/parser.h
    trunk/ext/psych/to_ruby.c
    trunk/ext/psych/to_ruby.h
    trunk/ext/psych/yaml_tree.c
    trunk/ext/psych/yaml_tree.h
  Modified files:
    trunk/ChangeLog
    trunk/ext/psych/extconf.rb
    trunk/ext/psych/lib/psych/deprecated.rb
    trunk/ext/psych/lib/psych.rb
    trunk/ext/psych/psych.gemspec
    trunk/ext/psych/psych.h

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37918)
+++ ChangeLog	(revision 37919)
@@ -1,3 +1,32 @@
+Wed Nov 28 13:27:29 2012  Aaron Patterson <aaron@t...>
+
+	* ext/psych/extconf.rb: use embedded libyaml if no system libyaml is
+	  found. [ruby-core:49463]
+	* ext/psych/lib/psych.rb: updating to psych 2.0.0
+	* ext/psych/lib/psych/deprecated.rb: updated docs
+	* ext/psych/psych.gemspec: updated to psych 2.0.0
+	* ext/psych/psych.h: fixing header file include for rename
+	* ext/psych/psych_emitter.c: renamed to avoid libyaml conflict.
+	* ext/psych/psych_emitter.h: ditto
+	* ext/psych/psych_parser.c: ditto
+	* ext/psych/psych_parser.h: ditto
+	* ext/psych/psych_to_ruby.c: ditto
+	* ext/psych/psych_to_ruby.h: ditto
+	* ext/psych/psych_yaml_tree.c: ditto
+	* ext/psych/psych_yaml_tree.h: ditto
+	* ext/psych/yaml/LICENSE: embedding libyaml 0.1.4
+	* ext/psych/yaml/api.c: ditto
+	* ext/psych/yaml/config.h: ditto
+	* ext/psych/yaml/dumper.c: ditto
+	* ext/psych/yaml/emitter.c: ditto
+	* ext/psych/yaml/loader.c: ditto
+	* ext/psych/yaml/parser.c: ditto
+	* ext/psych/yaml/reader.c: ditto
+	* ext/psych/yaml/scanner.c: ditto
+	* ext/psych/yaml/writer.c: ditto
+	* ext/psych/yaml/yaml.h: ditto
+	* ext/psych/yaml/yaml_private.h: ditto
+
 Wed Nov 28 12:54:59 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* thread.c (thread_join): A trap handler check was moved from
Index: ext/psych/emitter.h
===================================================================
--- ext/psych/emitter.h	(revision 37918)
+++ ext/psych/emitter.h	(revision 37919)
@@ -1,8 +0,0 @@
-#ifndef PSYCH_EMITTER_H
-#define PSYCH_EMITTER_H
-
-#include <psych.h>
-
-void Init_psych_emitter();
-
-#endif
Index: ext/psych/parser.h
===================================================================
--- ext/psych/parser.h	(revision 37918)
+++ ext/psych/parser.h	(revision 37919)
@@ -1,6 +0,0 @@
-#ifndef PSYCH_PARSER_H
-#define PSYCH_PARSER_H
-
-void Init_psych_parser();
-
-#endif
Index: ext/psych/yaml_tree.c
===================================================================
--- ext/psych/yaml_tree.c	(revision 37918)
+++ ext/psych/yaml_tree.c	(revision 37919)
@@ -1,24 +0,0 @@
-#include <psych.h>
-
-VALUE cPsychVisitorsYamlTree;
-
-/*
- * call-seq: private_iv_get(target, prop)
- *
- * Get the private instance variable +prop+ from +target+
- */
-static VALUE private_iv_get(VALUE self, VALUE target, VALUE prop)
-{
-    return rb_attr_get(target, rb_intern(StringValuePtr(prop)));
-}
-
-void Init_psych_yaml_tree(void)
-{
-    VALUE psych     = rb_define_module("Psych");
-    VALUE visitors  = rb_define_module_under(psych, "Visitors");
-    VALUE visitor   = rb_define_class_under(visitors, "Visitor", rb_cObject);
-    cPsychVisitorsYamlTree = rb_define_class_under(visitors, "YAMLTree", visitor);
-
-    rb_define_private_method(cPsychVisitorsYamlTree, "private_iv_get", private_iv_get, 2);
-}
-/* vim: set noet sws=4 sw=4: */
Index: ext/psych/to_ruby.c
===================================================================
--- ext/psych/to_ruby.c	(revision 37918)
+++ ext/psych/to_ruby.c	(revision 37919)
@@ -1,41 +0,0 @@
-#include <psych.h>
-
-VALUE cPsychVisitorsToRuby;
-
-/* call-seq: vis.build_exception(klass, message)
- *
- * Create an exception with class +klass+ and +message+
- */
-static VALUE build_exception(VALUE self, VALUE klass, VALUE mesg)
-{
-    VALUE e = rb_obj_alloc(klass);
-
-    rb_iv_set(e, "mesg", mesg);
-
-    return e;
-}
-
-/* call-seq: vis.path2class(path)
- *
- * Convert +path+ string to a class
- */
-static VALUE path2class(VALUE self, VALUE path)
-{
-#ifdef HAVE_RUBY_ENCODING_H
-    return rb_path_to_class(path);
-#else
-    return rb_path2class(StringValuePtr(path));
-#endif
-}
-
-void Init_psych_to_ruby(void)
-{
-    VALUE psych     = rb_define_module("Psych");
-    VALUE visitors  = rb_define_module_under(psych, "Visitors");
-    VALUE visitor   = rb_define_class_under(visitors, "Visitor", rb_cObject);
-    cPsychVisitorsToRuby = rb_define_class_under(visitors, "ToRuby", visitor);
-
-    rb_define_private_method(cPsychVisitorsToRuby, "build_exception", build_exception, 2);
-    rb_define_private_method(cPsychVisitorsToRuby, "path2class", path2class, 1);
-}
-/* vim: set noet sws=4 sw=4: */
Index: ext/psych/yaml_tree.h
===================================================================
--- ext/psych/yaml_tree.h	(revision 37918)
+++ ext/psych/yaml_tree.h	(revision 37919)
@@ -1,8 +0,0 @@
-#ifndef PSYCH_YAML_TREE_H
-#define PSYCH_YAML_TREE_H
-
-#include <psych.h>
-
-void Init_psych_yaml_tree(void);
-
-#endif
Index: ext/psych/to_ruby.h
===================================================================
--- ext/psych/to_ruby.h	(revision 37918)
+++ ext/psych/to_ruby.h	(revision 37919)
@@ -1,8 +0,0 @@
-#ifndef PSYCH_TO_RUBY_H
-#define PSYCH_TO_RUBY_H
-
-#include <psych.h>
-
-void Init_psych_to_ruby(void);
-
-#endif
Index: ext/psych/emitter.c
===================================================================
--- ext/psych/emitter.c	(revision 37918)
+++ ext/psych/emitter.c	(revision 37919)
@@ -1,538 +0,0 @@
-#include <psych.h>
-
-VALUE cPsychEmitter;
-static ID id_write;
-static ID id_line_width;
-static ID id_indentation;
-static ID id_canonical;
-
-static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
-{
-    if(!yaml_emitter_emit(emitter, event))
-	rb_raise(rb_eRuntimeError, "%s", emitter->problem);
-}
-
-static int writer(void *ctx, unsigned char *buffer, size_t size)
-{
-    VALUE io = (VALUE)ctx;
-    VALUE str = rb_str_new((const char *)buffer, (long)size);
-    VALUE wrote = rb_funcall(io, id_write, 1, str);
-    return (int)NUM2INT(wrote);
-}
-
-static void dealloc(void * ptr)
-{
-    yaml_emitter_t * emitter;
-
-    emitter = (yaml_emitter_t *)ptr;
-    yaml_emitter_delete(emitter);
-    xfree(emitter);
-}
-
-static VALUE allocate(VALUE klass)
-{
-    yaml_emitter_t * emitter;
-
-    emitter = xmalloc(sizeof(yaml_emitter_t));
-
-    yaml_emitter_initialize(emitter);
-    yaml_emitter_set_unicode(emitter, 1);
-    yaml_emitter_set_indent(emitter, 2);
-
-    return Data_Wrap_Struct(klass, 0, dealloc, emitter);
-}
-
-/* call-seq: Psych::Emitter.new(io, options = Psych::Emitter::OPTIONS)
- *
- * Create a new Psych::Emitter that writes to +io+.
- */
-static VALUE initialize(int argc, VALUE *argv, VALUE self)
-{
-    yaml_emitter_t * emitter;
-    VALUE io, options;
-    VALUE line_width;
-    VALUE indent;
-    VALUE canonical;
-
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-    if (rb_scan_args(argc, argv, "11", &io, &options) == 2) {
-	line_width = rb_funcall(options, id_line_width, 0);
-	indent     = rb_funcall(options, id_indentation, 0);
-	canonical  = rb_funcall(options, id_canonical, 0);
-
-	yaml_emitter_set_width(emitter, NUM2INT(line_width));
-	yaml_emitter_set_indent(emitter, NUM2INT(indent));
-	yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0);
-    }
-
-    yaml_emitter_set_output(emitter, writer, (void *)io);
-
-    return self;
-}
-
-/* call-seq: emitter.start_stream(encoding)
- *
- * Start a stream emission with +encoding+
- *
- * See Psych::Handler#start_stream
- */
-static VALUE start_stream(VALUE self, VALUE encoding)
-{
-    yaml_emitter_t * emitter;
-    yaml_event_t event;
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-    Check_Type(encoding, T_FIXNUM);
-
-    yaml_stream_start_event_initialize(&event, (yaml_encoding_t)NUM2INT(encoding));
-
-    emit(emitter, &event);
-
-    return self;
-}
-
-/* call-seq: emitter.end_stream
- *
- * End a stream emission
- *
- * See Psych::Handler#end_stream
- */
-static VALUE end_stream(VALUE self)
-{
-    yaml_emitter_t * emitter;
-    yaml_event_t event;
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-    yaml_stream_end_event_initialize(&event);
-
-    emit(emitter, &event);
-
-    return self;
-}
-
-/* call-seq: emitter.start_document(version, tags, implicit)
- *
- * Start a document emission with YAML +version+, +tags+, and an +implicit+
- * start.
- *
- * See Psych::Handler#start_document
- */
-static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
-{
-    yaml_emitter_t * emitter;
-    yaml_tag_directive_t * head = NULL;
-    yaml_tag_directive_t * tail = NULL;
-    yaml_event_t event;
-    yaml_version_directive_t version_directive;
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-
-    Check_Type(version, T_ARRAY);
-
-    if(RARRAY_LEN(version) > 0) {
-	VALUE major = rb_ary_entry(version, (long)0);
-	VALUE minor = rb_ary_entry(version, (long)1);
-
-	version_directive.major = NUM2INT(major);
-	version_directive.minor = NUM2INT(minor);
-    }
-
-    if(RTEST(tags)) {
-	int i = 0;
-#ifdef HAVE_RUBY_ENCODING_H
-	rb_encoding * encoding = rb_utf8_encoding();
-#endif
-
-	Check_Type(tags, T_ARRAY);
-
-	head  = xcalloc((size_t)RARRAY_LEN(tags), sizeof(yaml_tag_directive_t));
-	tail  = head;
-
-	for(i = 0; i < RARRAY_LEN(tags); i++) {
-	    VALUE tuple = RARRAY_PTR(tags)[i];
-	    VALUE name;
-	    VALUE value;
-
-	    Check_Type(tuple, T_ARRAY);
-
-	    if(RARRAY_LEN(tuple) < 2) {
-		xfree(head);
-		rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
-	    }
-	    name  = RARRAY_PTR(tuple)[0];
-	    value = RARRAY_PTR(tuple)[1];
-#ifdef HAVE_RUBY_ENCODING_H
-	    name = rb_str_export_to_enc(name, encoding);
-	    value = rb_str_export_to_enc(value, encoding);
-#endif
-
-	    tail->handle = (yaml_char_t *)StringValuePtr(name);
-	    tail->prefix = (yaml_char_t *)StringValuePtr(value);
-
-	    tail++;
-	}
-    }
-
-    yaml_document_start_event_initialize(
-	    &event,
-	    (RARRAY_LEN(version) > 0) ? &version_directive : NULL,
-	    head,
-	    tail,
-	    imp ? 1 : 0
-	    );
-
-    emit(emitter, &event);
-
-    if(head) xfree(head);
-
-    return self;
-}
-
-/* call-seq: emitter.end_document(implicit)
- *
- * End a document emission with an +implicit+ ending.
- *
- * See Psych::Handler#end_document
- */
-static VALUE end_document(VALUE self, VALUE imp)
-{
-    yaml_emitter_t * emitter;
-    yaml_event_t event;
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-    yaml_document_end_event_initialize(&event, imp ? 1 : 0);
-
-    emit(emitter, &event);
-
-    return self;
-}
-
-/* call-seq: emitter.scalar(value, anchor, tag, plain, quoted, style)
- *
- * Emit a scalar with +value+, +anchor+, +tag+, and a +plain+ or +quoted+
- * string type with +style+.
- *
- * See Psych::Handler#scalar
- */
-static VALUE scalar(
-	VALUE self,
-	VALUE value,
-	VALUE anchor,
-	VALUE tag,
-	VALUE plain,
-	VALUE quoted,
-	VALUE style
-	) {
-    yaml_emitter_t * emitter;
-    yaml_event_t event;
-#ifdef HAVE_RUBY_ENCODING_H
-    rb_encoding *encoding;
-#endif
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-    Check_Type(value, T_STRING);
-
-#ifdef HAVE_RUBY_ENCODING_H
-    encoding = rb_utf8_encoding();
-
-    value = rb_str_export_to_enc(value, encoding);
-
-    if(!NIL_P(anchor)) {
-	Check_Type(anchor, T_STRING);
-	anchor = rb_str_export_to_enc(anchor, encoding);
-    }
-
-    if(!NIL_P(tag)) {
-	Check_Type(tag, T_STRING);
-	tag = rb_str_export_to_enc(tag, encoding);
-    }
-#endif
-
-    yaml_scalar_event_initialize(
-	    &event,
-	    (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValuePtr(anchor)),
-	    (yaml_char_t *)(NIL_P(tag) ? NULL : StringValuePtr(tag)),
-	    (yaml_char_t*)StringValuePtr(value),
-	    (int)RSTRING_LEN(value),
-	    plain ? 1 : 0,
-	    quoted ? 1 : 0,
-	    (yaml_scalar_style_t)NUM2INT(style)
-	    );
-
-    emit(emitter, &event);
-
-    return self;
-}
-
-/* call-seq: emitter.start_sequence(anchor, tag, implicit, style)
- *
- * Start emitting a sequence with +anchor+, a +tag+, +implicit+ sequence
- * start and end, along with +style+.
- *
- * See Psych::Handler#start_sequence
- */
-static VALUE start_sequence(
-	VALUE self,
-	VALUE anchor,
-	VALUE tag,
-	VALUE implicit,
-	VALUE style
-	) {
-    yaml_emitter_t * emitter;
-    yaml_event_t event;
-
-#ifdef HAVE_RUBY_ENCODING_H
-    rb_encoding * encoding = rb_utf8_encoding();
-
-    if(!NIL_P(anchor)) {
-	Check_Type(anchor, T_STRING);
-	anchor = rb_str_export_to_enc(anchor, encoding);
-    }
-
-    if(!NIL_P(tag)) {
-	Check_Type(tag, T_STRING);
-	tag = rb_str_export_to_enc(tag, encoding);
-    }
-#endif
-
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-    yaml_sequence_start_event_initialize(
-	    &event,
-	    (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValuePtr(anchor)),
-	    (yaml_char_t *)(NIL_P(tag) ? NULL : StringValuePtr(tag)),
-	    implicit ? 1 : 0,
-	    (yaml_sequence_style_t)NUM2INT(style)
-	    );
-
-    emit(emitter, &event);
-
-    return self;
-}
-
-/* call-seq: emitter.end_sequence
- *
- * End sequence emission.
- *
- * See Psych::Handler#end_sequence
- */
-static VALUE end_sequence(VALUE self)
-{
-    yaml_emitter_t * emitter;
-    yaml_event_t event;
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-    yaml_sequence_end_event_initialize(&event);
-
-    emit(emitter, &event);
-
-    return self;
-}
-
-/* call-seq: emitter.start_mapping(anchor, tag, implicit, style)
- *
- * Start emitting a YAML map with +anchor+, +tag+, an +implicit+ start
- * and end, and +style+.
- *
- * See Psych::Handler#start_mapping
- */
-static VALUE start_mapping(
-	VALUE self,
-	VALUE anchor,
-	VALUE tag,
-	VALUE implicit,
-	VALUE style
-	) {
-    yaml_emitter_t * emitter;
-    yaml_event_t event;
-#ifdef HAVE_RUBY_ENCODING_H
-    rb_encoding *encoding;
-#endif
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-#ifdef HAVE_RUBY_ENCODING_H
-    encoding = rb_utf8_encoding();
-
-    if(!NIL_P(anchor)) {
-	Check_Type(anchor, T_STRING);
-	anchor = rb_str_export_to_enc(anchor, encoding);
-    }
-
-    if(!NIL_P(tag)) {
-	Check_Type(tag, T_STRING);
-	tag = rb_str_export_to_enc(tag, encoding);
-    }
-#endif
-
-    yaml_mapping_start_event_initialize(
-	    &event,
-	    (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValuePtr(anchor)),
-	    (yaml_char_t *)(NIL_P(tag) ? NULL : StringValuePtr(tag)),
-	    implicit ? 1 : 0,
-	    (yaml_mapping_style_t)NUM2INT(style)
-	    );
-
-    emit(emitter, &event);
-
-    return self;
-}
-
-/* call-seq: emitter.end_mapping
- *
- * Emit the end of a mapping.
- *
- * See Psych::Handler#end_mapping
- */
-static VALUE end_mapping(VALUE self)
-{
-    yaml_emitter_t * emitter;
-    yaml_event_t event;
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-    yaml_mapping_end_event_initialize(&event);
-
-    emit(emitter, &event);
-
-    return self;
-}
-
-/* call-seq: emitter.alias(anchor)
- *
- * Emit an alias with +anchor+.
- *
- * See Psych::Handler#alias
- */
-static VALUE alias(VALUE self, VALUE anchor)
-{
-    yaml_emitter_t * emitter;
-    yaml_event_t event;
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-#ifdef HAVE_RUBY_ENCODING_H
-    if(!NIL_P(anchor)) {
-	Check_Type(anchor, T_STRING);
-	anchor = rb_str_export_to_enc(anchor, rb_utf8_encoding());
-    }
-#endif
-
-    yaml_alias_event_initialize(
-	    &event,
-	    (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValuePtr(anchor))
-	    );
-
-    emit(emitter, &event);
-
-    return self;
-}
-
-/* call-seq: emitter.canonical = true
- *
- * Set the output style to canonical, or not.
- */
-static VALUE set_canonical(VALUE self, VALUE style)
-{
-    yaml_emitter_t * emitter;
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-    yaml_emitter_set_canonical(emitter, Qtrue == style ? 1 : 0);
-
-    return style;
-}
-
-/* call-seq: emitter.canonical
- *
- * Get the output style, canonical or not.
- */
-static VALUE canonical(VALUE self)
-{
-    yaml_emitter_t * emitter;
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-    return (emitter->canonical == 0) ? Qfalse : Qtrue;
-}
-
-/* call-seq: emitter.indentation = level
- *
- * Set the indentation level to +level+.  The level must be less than 10 and
- * greater than 1.
- */
-static VALUE set_indentation(VALUE self, VALUE level)
-{
-    yaml_emitter_t * emitter;
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-    yaml_emitter_set_indent(emitter, NUM2INT(level));
-
-    return level;
-}
-
-/* call-seq: emitter.indentation
- *
- * Get the indentation level.
- */
-static VALUE indentation(VALUE self)
-{
-    yaml_emitter_t * emitter;
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-    return INT2NUM(emitter->best_indent);
-}
-
-/* call-seq: emitter.line_width
- *
- * Get the preferred line width.
- */
-static VALUE line_width(VALUE self)
-{
-    yaml_emitter_t * emitter;
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-    return INT2NUM(emitter->best_width);
-}
-
-/* call-seq: emitter.line_width = width
- *
- * Set the preferred line with to +width+.
- */
-static VALUE set_line_width(VALUE self, VALUE width)
-{
-    yaml_emitter_t * emitter;
-    Data_Get_Struct(self, yaml_emitter_t, emitter);
-
-    yaml_emitter_set_width(emitter, NUM2INT(width));
-
-    return width;
-}
-
-void Init_psych_emitter()
-{
-    VALUE psych     = rb_define_module("Psych");
-    VALUE handler   = rb_define_class_under(psych, "Handler", rb_cObject);
-    cPsychEmitter   = rb_define_class_under(psych, "Emitter", handler);
-
-    rb_define_alloc_func(cPsychEmitter, allocate);
-
-    rb_define_method(cPsychEmitter, "initialize", initialize, -1);
-    rb_define_method(cPsychEmitter, "start_stream", start_stream, 1);
-    rb_define_method(cPsychEmitter, "end_stream", end_stream, 0);
-    rb_define_method(cPsychEmitter, "start_document", start_document, 3);
-    rb_define_method(cPsychEmitter, "end_document", end_document, 1);
-    rb_define_method(cPsychEmitter, "scalar", scalar, 6);
-    rb_define_method(cPsychEmitter, "start_sequence", start_sequence, 4);
-    rb_define_method(cPsychEmitter, "end_sequence", end_sequence, 0);
-    rb_define_method(cPsychEmitter, "start_mapping", start_mapping, 4);
-    rb_define_method(cPsychEmitter, "end_mapping", end_mapping, 0);
-    rb_define_method(cPsychEmitter, "alias", alias, 1);
-    rb_define_method(cPsychEmitter, "canonical", canonical, 0);
-    rb_define_method(cPsychEmitter, "canonical=", set_canonical, 1);
-    rb_define_method(cPsychEmitter, "indentation", indentation, 0);
-    rb_define_method(cPsychEmitter, "indentation=", set_indentation, 1);
-    rb_define_method(cPsychEmitter, "line_width", line_width, 0);
-    rb_define_method(cPsychEmitter, "line_width=", set_line_width, 1);
-
-    id_write       = rb_intern("write");
-    id_line_width  = rb_intern("line_width");
-    id_indentation = rb_intern("indentation");
-    id_canonical   = rb_intern("canonical");
-}
-/* vim: set noet sws=4 sw=4: */
Index: ext/psych/parser.c
===================================================================
--- ext/psych/parser.c	(revision 37918)
+++ ext/psych/parser.c	(revision 37919)
@@ -1,579 +0,0 @@
-#include <psych.h>
-
-VALUE cPsychParser;
-VALUE ePsychSyntaxError;
-
-static ID id_read;
-static ID id_path;
-static ID id_empty;
-static ID id_start_stream;
-static ID id_end_stream;
-static ID id_start_document;
-static ID id_end_document;
-static ID id_alias;
-static ID id_scalar;
-static ID id_start_sequence;
-static ID id_end_sequence;
-static ID id_start_mapping;
-static ID id_end_mapping;
-
-#define PSYCH_TRANSCODE(_str, _yaml_enc, _internal_enc) \
-  do { \
-    rb_enc_associate_index((_str), (_yaml_enc)); \
-    if(_internal_enc) \
-      (_str) = rb_str_export_to_enc((_str), (_internal_enc)); \
-  } while (0)
-
-static int io_reader(void * data, unsigned char *buf, size_t size, size_t *read)
-{
-    VALUE io = (VALUE)data;
-    VALUE string = rb_funcall(io, id_read, 1, INT2NUM(size));
-
-    *read = 0;
-
-    if(! NIL_P(string)) {
-	void * str = (void *)StringValuePtr(string);
-	*read = (size_t)RSTRING_LEN(string);
-	memcpy(buf, str, *read);
-    }
-
-    return 1;
-}
-
-static void dealloc(void * ptr)
-{
-    yaml_parser_t * parser;
-
-    parser = (yaml_parser_t *)ptr;
-    yaml_parser_delete(parser);
-    xfree(parser);
-}
-
-static VALUE allocate(VALUE klass) (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]