summaryrefslogtreecommitdiff
path: root/marshal.c
diff options
context:
space:
mode:
authordave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-27 16:07:43 +0000
committerdave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-27 16:07:43 +0000
commit9bd926ee88340fe234e4e76d082658a909b24884 (patch)
tree1cf036e776b5248f820d5d4b2da6eda6641b23f8 /marshal.c
parent879d623e8e75cba0b535cb94b4146224638dcf2e (diff)
RDoc comments added by Elliott Hughes
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@5321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/marshal.c b/marshal.c
index 1a30ee0..c9e3c74 100644
--- a/marshal.c
+++ b/marshal.c
@@ -691,6 +691,32 @@ dump_ensure(arg)
return 0;
}
+/*
+ * call-seq:
+ * dump( obj [, anIO] , limit=--1 ) => anIO
+ *
+ * Serializes obj and all descendent objects. If anIO is
+ * specified, the serialized data will be written to it, otherwise the
+ * data will be returned as a String. If limit is specified, the
+ * traversal of subobjects will be limited to that depth. If limit is
+ * negative, no checking of depth will be performed.
+ *
+ * class Klass
+ * def initialize(str)
+ * @str = str
+ * end
+ * def sayHello
+ * @str
+ * end
+ * end
+ *
+ * (produces no output)
+ *
+ * o = Klass.new("hello\n")
+ * data = Marshal.dump(o)
+ * obj = Marshal.load(data)
+ * obj.sayHello #=> "hello\n"
+ */
static VALUE
marshal_dump(argc, argv)
int argc;
@@ -1332,6 +1358,17 @@ load_ensure(arg)
return 0;
}
+/*
+ * call-seq:
+ * load( source [, proc] ) => obj
+ * restore( source [, proc] ) => obj
+ *
+ * Returns the result of converting the serialized data in source into a
+ * Ruby object (possibly with associated subordinate objects). source
+ * may be either an instance of IO or an object that responds to
+ * to_str. If proc is specified, it will be passed each object as it
+ * is deserialized.
+ */
static VALUE
marshal_load(argc, argv)
int argc;
@@ -1383,6 +1420,39 @@ marshal_load(argc, argv)
return v;
}
+/*
+ * The marshaling library converts collections of Ruby objects into a
+ * byte stream, allowing them to be stored outside the currently
+ * active script. This data may subsequently be read and the original
+ * objects reconstituted.
+ * Marshaled data has major and minor version numbers stored along
+ * with the object information. In normal use, marshaling can only
+ * load data written with the same major version number and an equal
+ * or lower minor version number. If Ruby's ``verbose'' flag is set
+ * (normally using -d, -v, -w, or --verbose) the major and minor
+ * numbers must match exactly. Marshal versioning is independent of
+ * Ruby's version numbers. You can extract the version by reading the
+ * first two bytes of marshaled data.
+ *
+ * str = Marshal.dump("thing")
+ * RUBY_VERSION #=> "1.8.0"
+ * str[0] #=> 4
+ * str[1] #=> 8
+ *
+ * Some objects cannot be dumped: if the objects to be dumped include
+ * bindings, procedure or method objects, instances of class IO, or
+ * singleton objects, a TypeError will be raised.
+ * If your class has special serialization needs (for example, if you
+ * want to serialize in some specific format), or if it contains
+ * objects that would otherwise not be serializable, you can implement
+ * your own serialization strategy by defining two methods, _dump and
+ * _load:
+ * The instance method _dump should return a String object containing
+ * all the information necessary to reconstitute objects of this class
+ * and all referenced objects up to a maximum depth given as an integer
+ * parameter (a value of -1 implies that you should disable depth checking).
+ * The class method _load should take a String and return an object of this class.
+ */
void
Init_marshal()
{