summaryrefslogtreecommitdiff
path: root/psycopg
diff options
context:
space:
mode:
authorFederico Di Gregorio <fog@initd.org>2005-03-22 14:20:20 +0000
committerFederico Di Gregorio <fog@initd.org>2005-03-22 14:20:20 +0000
commit07a38c31cd881f786930c2268210fe1c6ddc5950 (patch)
tree9f30ed86c3a62c990f1bd60cb3b9853a09998fab /psycopg
parent30b2ba6ebf30f54b02b649a4d6a8b1c23de4345b (diff)
downloadpsycopg2-07a38c31cd881f786930c2268210fe1c6ddc5950.tar.gz
Starting array work.
Diffstat (limited to 'psycopg')
-rw-r--r--psycopg/typecast.c2
-rw-r--r--psycopg/typecast.h3
-rw-r--r--psycopg/typecast_array.c55
-rw-r--r--psycopg/typecast_builtins.c36
4 files changed, 81 insertions, 15 deletions
diff --git a/psycopg/typecast.c b/psycopg/typecast.c
index 82367b3..78e873c 100644
--- a/psycopg/typecast.c
+++ b/psycopg/typecast.c
@@ -50,6 +50,8 @@ skip_until_space(char *s)
#include "psycopg/typecast_datetime.c"
#endif
+#include "psycopg/typecast_array.c"
+
#include "psycopg/typecast_builtins.c"
/* a list of initializers, used to make the typecasters accessible anyway */
diff --git a/psycopg/typecast.h b/psycopg/typecast.h
index 3cf5018..3e5a4c4 100644
--- a/psycopg/typecast.h
+++ b/psycopg/typecast.h
@@ -51,6 +51,9 @@ typedef struct {
char *name;
long int *values;
typecast_function cast;
+
+ /* base is the base typecaster for arrays */
+ char *base;
} typecastObject_initlist;
/* the type dictionary, much faster to access it globally */
diff --git a/psycopg/typecast_array.c b/psycopg/typecast_array.c
new file mode 100644
index 0000000..d4a982a
--- /dev/null
+++ b/psycopg/typecast_array.c
@@ -0,0 +1,55 @@
+/* typecast_array.c - array typecasters
+ *
+ * Copyright (C) 2005 Federico Di Gregorio <fog@debian.org>
+ *
+ * This file is part of the psycopg module.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+/* the pointer to the datetime module API is initialized by the module init
+ code, we just need to grab it */
+extern PyObject* pyDateTimeModuleP;
+extern PyObject *pyDateTypeP;
+extern PyObject *pyTimeTypeP;
+extern PyObject *pyDateTimeTypeP;
+extern PyObject *pyDeltaTypeP;
+
+/** LONGINTEGERARRAY and INTEGERARRAY - cast integers arrays **/
+
+static PyObject *
+typecast_INTEGERARRAY_cast(unsigned char *str, int len, PyObject *curs)
+{
+ PyObject* obj = NULL;
+
+ if (str == NULL) {Py_INCREF(Py_None); return Py_None;}
+
+ return obj;
+}
+
+#define typecast_LONGINTEGERARRAY_cast typecast_INTEGERARRAY_cast
+
+/** STRINGARRAY - cast integers arrays **/
+
+static PyObject *
+typecast_STRINGARRAY_cast(unsigned char *str, int len, PyObject *curs)
+{
+ PyObject* obj = NULL;
+
+ if (str == NULL) {Py_INCREF(Py_None); return Py_None;}
+
+ return obj;
+}
diff --git a/psycopg/typecast_builtins.c b/psycopg/typecast_builtins.c
index c554a37..0cea385 100644
--- a/psycopg/typecast_builtins.c
+++ b/psycopg/typecast_builtins.c
@@ -12,23 +12,29 @@ static long int typecast_DATE_types[] = {1082, 0};
static long int typecast_INTERVAL_types[] = {704, 1186, 0};
static long int typecast_BINARY_types[] = {17, 0};
static long int typecast_ROWID_types[] = {26, 0};
+static long int typecast_LONGINTEGERARRAY_types[] = {1016, 0};
+static long int typecast_INTEGERARRAY_types[] = {1005, 1006, 1007, 0};
+static long int typecast_STRINGARRAY_types[] = {1002, 1003, 1009, 1014, 1015, 0};
typecastObject_initlist typecast_builtins[] = {
- {"NUMBER", typecast_NUMBER_types, typecast_NUMBER_cast},
- {"LONGINTEGER", typecast_LONGINTEGER_types, typecast_LONGINTEGER_cast},
- {"INTEGER", typecast_INTEGER_types, typecast_INTEGER_cast},
- {"FLOAT", typecast_FLOAT_types, typecast_FLOAT_cast},
- {"DECIMAL", typecast_DECIMAL_types, typecast_DECIMAL_cast},
- {"UNICODE", typecast_UNICODE_types, typecast_UNICODE_cast},
- {"STRING", typecast_STRING_types, typecast_STRING_cast},
- {"BOOLEAN", typecast_BOOLEAN_types, typecast_BOOLEAN_cast},
- {"DATETIME", typecast_DATETIME_types, typecast_DATETIME_cast},
- {"TIME", typecast_TIME_types, typecast_TIME_cast},
- {"DATE", typecast_DATE_types, typecast_DATE_cast},
- {"INTERVAL", typecast_INTERVAL_types, typecast_INTERVAL_cast},
- {"BINARY", typecast_BINARY_types, typecast_BINARY_cast},
- {"ROWID", typecast_ROWID_types, typecast_ROWID_cast},
- {NULL, NULL, NULL}
+ {"NUMBER", typecast_NUMBER_types, typecast_NUMBER_cast, NULL},
+ {"LONGINTEGER", typecast_LONGINTEGER_types, typecast_LONGINTEGER_cast, NULL},
+ {"INTEGER", typecast_INTEGER_types, typecast_INTEGER_cast, NULL},
+ {"FLOAT", typecast_FLOAT_types, typecast_FLOAT_cast, NULL},
+ {"DECIMAL", typecast_DECIMAL_types, typecast_DECIMAL_cast, NULL},
+ {"UNICODE", typecast_UNICODE_types, typecast_UNICODE_cast, NULL},
+ {"STRING", typecast_STRING_types, typecast_STRING_cast, NULL},
+ {"BOOLEAN", typecast_BOOLEAN_types, typecast_BOOLEAN_cast, NULL},
+ {"DATETIME", typecast_DATETIME_types, typecast_DATETIME_cast, NULL},
+ {"TIME", typecast_TIME_types, typecast_TIME_cast, NULL},
+ {"DATE", typecast_DATE_types, typecast_DATE_cast, NULL},
+ {"INTERVAL", typecast_INTERVAL_types, typecast_INTERVAL_cast, NULL},
+ {"BINARY", typecast_BINARY_types, typecast_BINARY_cast, NULL},
+ {"ROWID", typecast_ROWID_types, typecast_ROWID_cast, NULL},
+ {"LONGINTEGERARRAY", typecast_LONGINTEGERARRAY_types, typecast_LONGINTEGERARRAY_cast, "LONGINTEGER"},
+ {"INTEGERARRAY", typecast_INTEGERARRAY_types, typecast_INTEGERARRAY_cast, "INTEGER"},
+ {"STRINGARRAY", typecast_STRINGARRAY_types, typecast_STRINGARRAY_cast, "STRING"},
+ {NULL, NULL, NULL, NULL}
};