XOTcl - Documentation -- ./library/serialize/Serializer.xotcl

# ./library/serialize/Serializer.xotcl

## Package/File Information

No package provided/required
Defined Objects/Classes:

- Serializer: all, deepSerialize, exportMethods, methodSerialize, serialize.

Filename: ./library/serialize/Serializer.xotcl

Description: | This package provides the class Serializer, which can be used to generate a snapshot of the current state of the workspace in the form of XOTcl source code.
Authors: | Gustaf Neumann, Gustaf.Neumann@wu-wien.ac.at
Date: | $Date: 2007/10/05 09:06:00 $

## Class: Serializer

Procs/Instprocs: all, deepSerialize, exportMethods, methodSerialize, serialize.

### Instprocs

- serialize entity

  Arguments: | entity: Object or Class
  Description: | Serialize the specified object or class.
  Return: | Object or Class with all currently defined methods, variables, invariants, filters and mixins

### Procs

- all ?-ignoreVarsRE RE? ?-ignore obj1 obj2 ...?

  Arguments: | ?-ignoreVarsRE RE?: provide regular expression; matching vars are ignored
  | ?-ignore obj1 obj2 ...?: provide a list of objects to be omitted
  Description: | Serialize all objects and classes that are currently defined (except the specified omissions and the current Serializer object). Examples:
      Serializer all -ignoreVarsRE {::b$}
  Do not serialize any instance variable named b (of any object).
      Serializer all -ignoreVarsRE {^::o1::.*text.*$|^::o2::x$}
  Do not serialize any variable of c1 whose name contains the string "text" and do not serialze the variable x of o2.
      Serializer all -ignore obj1 obj2 ...
  do not serizalze the specified objects
  Return: | script

- deepSerialize objs ?-ignoreVarsRE RE? ?-ignore obj1 obj2 ...? ?-map list?

  Arguments: | objs: Objects to be serialized
  | ?-ignoreVarsRE RE?: provide regular expression; matching vars are ignored
  | ?-ignore obj1 obj2 ...?: provide a list of objects to be omitted
  | ?-map list?: translate object names in serialized code
  Description: | Serialize object with all child objects (deep operation) except the specified omissions. For the description of `ignore` and `igonoreVarsRE` see `Serizalizer all`. `map` can be used in addition to provide pairs of old-string and new-string (like in the tcl command `string map`). This option can be used to regenerate the serialized object under a different object or under a different name, or to translate relative object names in the serialized code. Examples:
      Serializer deepSerialize ::a::b::c -map {::a::b ::x::y}
  Serialize the object `c` which is a child of `a::b`; the object will be reinitialized as object `::x::y::c`, all references `::a::b` will be replaced by `::x::y`.
      Serializer deepSerialize ::a::b::c -map {::a::b [self]}
  The serizalized object can be reinstantiated under some current object, under which the script is evaluated.
      Serializer deepSerialize ::a::b::c -map {::a::b::c ${var}}
  The serizalized object will be reinstantiated under a name specified by the variable `var`in the recreation context.``
  Return: | script

- methodSerialize object method prefix

  Arguments: | object: object or class
  | method: name of method
  | prefix: either empty or 'inst' (latter for instprocs)
  Description: | Serialize the specified method. In order to serialize an instproc, `prefix` should be 'inst'; to serialze procs, it should be empty. Examples:
      Serializer methodSerialize Serializer deepSerialize ""
  This command serializes the proc `deepSerialize` of the Class `Serializer`.
      Serializer methodSerialize Serializer serialize inst
  This command serializes the instproc `serialize` of the Class `Serializer`.
  Return: | Script, which can be used to recreate the specified method

- exportMethods list

  Arguments: | list: list of methods of the form 'object proc|instproc methodname'
  Description: | This method can be used to specify methods that should be exported in every `Serializer all`. The rationale behind this is that the serializer does not serialize objects from the ::xotcl:: namespace, which is used for XOTcl internals and volatile objects. It is however often useful to define methods on ::xotcl::Class or ::xotcl::Objects, which should be exported. One can export procs, instprocs, forward and instforward Example:
            Serializer exportMethods {
      	::xotcl::Object instproc __split_arguments
      	::xotcl::Object instproc __make_doc
      	::xotcl::Object instproc ad_proc
      	::xotcl::Class  instproc ad_instproc
      	::xotcl::Object forward  expr
            }

Back to index page.