Mailinglist Archive: yast-commit (535 mails)

< Previous Next >
[yast-commit] r41219 - in /trunk/python-bindings/src/YCPTypes: Path.cc Symbol.cc Term.cc YCPTypesInternal.cc YCPTypesInternal.h
  • From: dfiser@xxxxxxxxxxxxxxxx
  • Date: Wed, 03 Oct 2007 08:55:50 -0000
  • Message-id: <20071003085551.1182C2FC30@xxxxxxxxxxxxxxxx>
Author: dfiser
Date: Wed Oct  3 10:55:50 2007
New Revision: 41219

URL: http://svn.opensuse.org/viewcvs/yast?rev=41219&view=rev
Log:
 - Added some methods to YCP Types (isSymbol, isTerm, isPath, len, str, ...)


Modified:
    trunk/python-bindings/src/YCPTypes/Path.cc
    trunk/python-bindings/src/YCPTypes/Symbol.cc
    trunk/python-bindings/src/YCPTypes/Term.cc
    trunk/python-bindings/src/YCPTypes/YCPTypesInternal.cc
    trunk/python-bindings/src/YCPTypes/YCPTypesInternal.h

Modified: trunk/python-bindings/src/YCPTypes/Path.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/python-bindings/src/YCPTypes/Path.cc?rev=41219&r1=41218&r2=41219&view=diff
==============================================================================
--- trunk/python-bindings/src/YCPTypes/Path.cc (original)
+++ trunk/python-bindings/src/YCPTypes/Path.cc Wed Oct  3 10:55:50 2007
@@ -24,6 +24,14 @@
     return ret;
 }
 
+static PyObject *Path_str(PyObject *self)
+{
+    if (isPath(self)){
+        Py_INCREF(((Path *)self)->value);
+        return ((Path *)self)->value;
+    }
+    return Py_None;
+}
 
 /**
  * Returns New Reference!
@@ -71,6 +79,9 @@
 static PyMethodDef Path_methods[] = {
     {"append", (PyCFunction)Path_append, METH_O, "Return new Path object with appended path given in argument."},
     {"prepend", (PyCFunction)Path_prepend, METH_O, "Return new Path object with perpended path given in argument."},
+    {"isSymbol", (PyCFunction)YCPType_isSymbol, METH_NOARGS, "Return true if object is Symbol."},
+    {"isPath", (PyCFunction)YCPType_isPath, METH_NOARGS, "Return true if object is Path."},
+    {"isTerm", (PyCFunction)YCPType_isTerm, METH_NOARGS, "Return true if object is Term."},
     {NULL}  /* Sentinel */
 };
 
@@ -100,7 +111,7 @@
     0,                         /*tp_as_mapping*/
     (hashfunc)YCPTypeString_hash,/*tp_hash */
     0,                         /*tp_call*/
-    0,                         /*tp_str*/
+    (reprfunc)Path_str,        /*tp_str*/
     0,                         /*tp_getattro*/
     0,                         /*tp_setattro*/
     0,                         /*tp_as_buffer*/

Modified: trunk/python-bindings/src/YCPTypes/Symbol.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/python-bindings/src/YCPTypes/Symbol.cc?rev=41219&r1=41218&r2=41219&view=diff
==============================================================================
--- trunk/python-bindings/src/YCPTypes/Symbol.cc (original)
+++ trunk/python-bindings/src/YCPTypes/Symbol.cc Wed Oct  3 10:55:50 2007
@@ -24,7 +24,21 @@
 }
 
 
+static PyObject *Symbol_str(PyObject *self)
+{
+    if (isSymbol(self)){
+        Py_INCREF(((Symbol *)self)->value);
+        return ((Symbol *)self)->value;
+    }
+
+    return Py_None;
+}
+
+
 static PyMethodDef Symbol_methods[] = {
+    {"isSymbol", (PyCFunction)YCPType_isSymbol, METH_NOARGS, "Return true if object is Symbol."},
+    {"isPath", (PyCFunction)YCPType_isPath, METH_NOARGS, "Return true if object is Path."},
+    {"isTerm", (PyCFunction)YCPType_isTerm, METH_NOARGS, "Return true if object is Term."},
     {NULL}  /* Sentinel */
 };
 
@@ -54,7 +68,7 @@
     0,                         /*tp_as_mapping*/
     (hashfunc)YCPTypeString_hash,     /*tp_hash */
     0,                         /*tp_call*/
-    0,                         /*tp_str*/
+    (reprfunc)Symbol_str,      /*tp_str*/
     0,                         /*tp_getattro*/
     0,                         /*tp_setattro*/
     0,                         /*tp_as_buffer*/

Modified: trunk/python-bindings/src/YCPTypes/Term.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/python-bindings/src/YCPTypes/Term.cc?rev=41219&r1=41218&r2=41219&view=diff
==============================================================================
--- trunk/python-bindings/src/YCPTypes/Term.cc (original)
+++ trunk/python-bindings/src/YCPTypes/Term.cc Wed Oct  3 10:55:50 2007
@@ -110,8 +110,23 @@
 }
 
 
+static PyObject *Term_len(PyObject *self, PyObject *)
+{
+    int size;
+
+    if (!isTerm(self))
+        return Py_None;
+
+    size = PyTuple_Size(((Term *)self)->value);
+    return Py_BuildValue("i", size);
+}
+
 
 static PyMethodDef Term_methods[] = {
+    {"len", (PyCFunction)Term_len, METH_NOARGS, "Return number of Terms\' parameters."},
+    {"isSymbol", (PyCFunction)YCPType_isSymbol, METH_NOARGS, "Return true if object is Symbol."},
+    {"isPath", (PyCFunction)YCPType_isPath, METH_NOARGS, "Return true if object is Path."},
+    {"isTerm", (PyCFunction)YCPType_isTerm, METH_NOARGS, "Return true if object is Term."},
     {NULL}  /* Sentinel */
 };
 

Modified: trunk/python-bindings/src/YCPTypes/YCPTypesInternal.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/python-bindings/src/YCPTypes/YCPTypesInternal.cc?rev=41219&r1=41218&r2=41219&view=diff
==============================================================================
--- trunk/python-bindings/src/YCPTypes/YCPTypesInternal.cc (original)
+++ trunk/python-bindings/src/YCPTypes/YCPTypesInternal.cc Wed Oct  3 10:55:50 2007
@@ -85,3 +85,29 @@
     return ret;
 }
 
+PyObject *YCPType_isSymbol(PyObject *self, PyObject *)
+{
+    if (isSymbol(self)){
+        Py_RETURN_TRUE;
+    }else{
+        Py_RETURN_FALSE;
+    }
+}
+
+PyObject *YCPType_isPath(PyObject *self, PyObject *)
+{
+    if (isPath(self)){
+        Py_RETURN_TRUE;
+    }else{
+        Py_RETURN_FALSE;
+    }
+}
+
+PyObject *YCPType_isTerm(PyObject *self, PyObject *)
+{
+    if (isTerm(self)){
+        Py_RETURN_TRUE;
+    }else{
+        Py_RETURN_FALSE;
+    }
+}

Modified: trunk/python-bindings/src/YCPTypes/YCPTypesInternal.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/python-bindings/src/YCPTypes/YCPTypesInternal.h?rev=41219&r1=41218&r2=41219&view=diff
==============================================================================
--- trunk/python-bindings/src/YCPTypes/YCPTypesInternal.h (original)
+++ trunk/python-bindings/src/YCPTypes/YCPTypesInternal.h Wed Oct  3 10:55:50 2007
@@ -38,4 +38,9 @@
 
 PyObject *Term_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
 int Term_init(Term *self, PyObject *args, PyObject *kwds);
+
+
+PyObject *YCPType_isSymbol(PyObject *self, PyObject *);
+PyObject *YCPType_isPath(PyObject *self, PyObject *);
+PyObject *YCPType_isTerm(PyObject *self, PyObject *);
 #endif

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages