Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ext/_syckmodule.c

    r20 r25  
    4343PyDoc_STRVAR(PySyckNode_doc, 
    4444    "_syck.Node() -> TypeError\n\n" 
    45     "_syck.Node is an abstract type. It is a base type for _syck.Scalar,\n" 
     45    "_syck.Node is an abstract type. It is the base type for _syck.Scalar,\n" 
    4646    "_syck.Seq, and _syck.Map. You cannot create an instance of _syck.Node\n" 
    4747    "directly. You may use _syck.Node for type checking or subclassing.\n"); 
     
    220220    "      -> a Scalar node\n\n" 
    221221    "_syck.Scalar represents a scalar node in Syck parser and emitter\n" 
    222     "graphs. A scalar node points to a single string value.\n"); 
     222    "trees. A scalar node points to a single string value.\n"); 
    223223 
    224224typedef struct { 
     
    549549    "Seq(value=[], tag=None, inline=False) -> a Seq node\n\n" 
    550550    "_syck.Seq represents a sequence node in Syck parser and emitter\n" 
    551     "graphs. A sequence node points to an ordered set of subnodes.\n"); 
     551    "trees. A sequence node points to an ordered set of subnodes.\n"); 
    552552 
    553553typedef struct { 
     
    718718 
    719719PyDoc_STRVAR(PySyckMap_doc, 
    720     "Map(value='', tag=None, inline=False) -> a Map node\n\n" 
     720    "Map(value={}, tag=None, inline=False) -> a Map node\n\n" 
    721721    "_syck.Map represents a mapping node in Syck parser and emitter\n" 
    722     "graphs. A mapping node points to an unordered collections of pairs.\n"); 
     722    "trees. A mapping node points to an unordered collections of pairs.\n"); 
    723723 
    724724typedef struct { 
     
    833833        PyDoc_STR("the node kind, always 'map', read-only"), &PySyck_MapKind}, 
    834834    {"value", (getter)PySyckNode_getvalue, (setter)PySyckMap_setvalue, 
    835         PyDoc_STR("the node value, a mapping"), NULL}, 
     835        PyDoc_STR("the node value, a list of pairs or a dictionary"), NULL}, 
    836836    {"tag", (getter)PySyckNode_gettag, (setter)PySyckNode_settag, 
    837837        PyDoc_STR("the node tag, a string or None"), NULL}, 
     
    893893    "      -> a Parser object\n\n" 
    894894    "_syck.Parser is a low-lever wrapper of the Syck parser. It parses\n" 
    895     "a YAML stream and produces a graph of Nodes.\n"); 
     895    "a YAML stream and produces a tree of Nodes.\n"); 
    896896 
    897897typedef struct { 
     
    10171017static PyGetSetDef PySyckParser_getsetters[] = { 
    10181018    {"source", (getter)PySyckParser_getsource, NULL, 
    1019         PyDoc_STR("IO source, a string or file-like object"), NULL}, 
     1019        PyDoc_STR("IO source, a string or a file-like object"), NULL}, 
    10201020    {"implicit_typing", (getter)PySyckParser_getimplicit_typing, NULL, 
    10211021        PyDoc_STR("implicit typing of builtin YAML types"), NULL}, 
     
    12531253 
    12541254    if (self->parsing) { 
    1255         PyErr_SetString(PyExc_RuntimeError, "do not call Parser.parse while it is already parsing"); 
     1255        PyErr_SetString(PyExc_RuntimeError, 
     1256                "do not call Parser.parse while it is already running"); 
    12561257        return NULL; 
    12571258    } 
     
    12921293PyDoc_STRVAR(PySyckParser_parse_doc, 
    12931294    "parse() -> the root Node object\n\n" 
    1294     "Parses the source and returns the next document. On EOF, returns None\n" 
    1295     "and sets the 'eof' attribute on.\n"); 
     1295    "Parses the source and returns the root of the Node tree. Call it\n" 
     1296    "several times to retrieve all documents from the source. On EOF,\n" 
     1297    "returns None and sets the 'eof' attribute on.\n"); 
    12961298 
    12971299static PyMethodDef PySyckParser_methods[] = { 
     
    13481350 
    13491351PyDoc_STRVAR(PySyckEmitter_doc, 
    1350     "Emitter(output, headless=False, use_header=True, explicit_typing=True," 
    1351     "        style=None, best_width=80, indent=2) -> an Emitter object\n\n" 
    1352     "_syck.Emitter is a low-lever wrapper of the Syck emitter. It emit\n" 
     1352    "Emitter(output, headless=False, use_header=False, use_version=False,\n" 
     1353    "        explicit_typing=True, style=None, best_width=80, indent=2)\n" 
     1354    "                -> an Emitter object\n\n" 
     1355    "_syck.Emitter is a low-lever wrapper of the Syck emitter. It emits\n" 
    13531356    "a tree of Nodes into a YAML stream.\n"); 
    13541357 
     
    15301533        PyDoc_STR("headerless document flag"), NULL}, 
    15311534    {"use_header", (getter)PySyckEmitter_getuse_header, NULL, 
    1532         PyDoc_STR("force header"), NULL}, 
     1535        PyDoc_STR("force header flag"), NULL}, 
    15331536    {"use_version", (getter)PySyckEmitter_getuse_version, NULL, 
    1534         PyDoc_STR("force version"), NULL}, 
     1537        PyDoc_STR("force version flag"), NULL}, 
    15351538    {"explicit_typing", (getter)PySyckEmitter_getexplicit_typing, NULL, 
    15361539        PyDoc_STR("explicit typing for all collections"), NULL}, 
     
    17521755    Py_INCREF(output); 
    17531756    self->output = output; 
    1754  
    1755 /* 
    1756     self->emitter = syck_new_emitter(); 
    1757     self->emitter->bonus = self; 
    1758     self->emitter->headless = self->headless; 
    1759     self->emitter->use_header = use_header; 
    1760     self->emitter->use_version = use_version; 
    1761     self->emitter->explicit_typing = explicit_typing; 
    1762     self->emitter->style = self->style; 
    1763     self->emitter->best_width = self->best_width; 
    1764     self->emitter->indent = self->indent; 
    1765  
    1766     syck_emitter_handler(self->emitter, PySyckEmitter_node_handler); 
    1767     syck_output_handler(self->emitter, PySyckEmitter_write_handler); 
    1768 */ 
    17691757 
    17701758    self->emitting = 0; 
     
    19741962PyDoc_STRVAR(PySyckEmitter_emit_doc, 
    19751963    "emit(root_node) -> None\n\n" 
    1976     "Emit the Node tree to the output.\n"); 
     1964    "Emits the Node tree to the output.\n"); 
    19771965 
    19781966static PyMethodDef PySyckEmitter_methods[] = { 
     
    20332021 
    20342022PyDoc_STRVAR(PySyck_doc, 
    2035     "low-level wrapper for the Syck YAML parser and emitter"); 
     2023    "_syck is a low-level wrapper for the Syck YAML parser and emitter.\n" 
     2024    "Do not use it directly, use the module 'syck' instead.\n"); 
     2025 
     2026static int 
     2027add_slotnames(PyTypeObject *type) 
     2028{ 
     2029    PyObject *slotnames; 
     2030    PyObject *name; 
     2031    PyGetSetDef *getsetter; 
     2032 
     2033    if (!type->tp_getset) return 0; 
     2034    if (!type->tp_dict) return 0; 
     2035 
     2036    slotnames = PyList_New(0); 
     2037    if (!slotnames) return -1; 
     2038 
     2039    for (getsetter = type->tp_getset; getsetter->name; getsetter++) { 
     2040        if (!getsetter->set) continue; 
     2041        name = PyString_FromString(getsetter->name); 
     2042        if (!name) { 
     2043           Py_DECREF(slotnames); 
     2044           return -1; 
     2045        } 
     2046        if (PyList_Append(slotnames, name) < 0) { 
     2047            Py_DECREF(name); 
     2048            Py_DECREF(slotnames); 
     2049            return -1; 
     2050        } 
     2051        Py_DECREF(name); 
     2052    } 
     2053 
     2054    if (PyDict_SetItemString(type->tp_dict, "__slotnames__", slotnames) < 0) { 
     2055        Py_DECREF(slotnames); 
     2056        return -1; 
     2057    } 
     2058 
     2059    Py_DECREF(slotnames); 
     2060    return 0; 
     2061} 
    20362062 
    20372063PyMODINIT_FUNC 
     
    20442070    if (PyType_Ready(&PySyckScalar_Type) < 0) 
    20452071        return; 
     2072    if (add_slotnames(&PySyckScalar_Type) < 0) 
     2073        return; 
    20462074    if (PyType_Ready(&PySyckSeq_Type) < 0) 
    20472075        return; 
     2076    if (add_slotnames(&PySyckSeq_Type) < 0) 
     2077        return; 
    20482078    if (PyType_Ready(&PySyckMap_Type) < 0) 
     2079        return; 
     2080    if (add_slotnames(&PySyckMap_Type) < 0) 
    20492081        return; 
    20502082    if (PyType_Ready(&PySyckParser_Type) < 0) 
Note: See TracChangeset for help on using the changeset viewer.