diff options
author | Federico Di Gregorio <fog@initd.org> | 2005-03-22 14:20:20 +0000 |
---|---|---|
committer | Federico Di Gregorio <fog@initd.org> | 2005-03-22 14:20:20 +0000 |
commit | 07a38c31cd881f786930c2268210fe1c6ddc5950 (patch) | |
tree | 9f30ed86c3a62c990f1bd60cb3b9853a09998fab /scripts | |
parent | 30b2ba6ebf30f54b02b649a4d6a8b1c23de4345b (diff) | |
download | psycopg2-07a38c31cd881f786930c2268210fe1c6ddc5950.tar.gz |
Starting array work.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/buildtypes.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/scripts/buildtypes.py b/scripts/buildtypes.py index a09a0cc..5d41498 100644 --- a/scripts/buildtypes.py +++ b/scripts/buildtypes.py @@ -49,13 +49,19 @@ basic_types = (['NUMBER', ['INT8', 'INT4', 'INT2', 'FLOAT8', 'FLOAT4', ['BINARY', ['BYTEA']], ['ROWID', ['OID']]) +# unfortunately we don't have a nice way to extract array information +# from postgresql headers; we'll have to do it hard-coding :/ +array_types = (['LONGINTEGER', [1016]], + ['INTEGER', [1005, 1006, 1007]], + ['STRING', [1002, 1003, 1009, 1014, 1015]]) + # this is the header used to compile the data in the C module HEADER = """ typecastObject_initlist typecast_builtins[] = { """ # then comes the footer -FOOTER = """ {NULL, NULL, NULL}\n};\n""" +FOOTER = """ {NULL, NULL, NULL, NULL}\n};\n""" # usefull error reporting function @@ -92,8 +98,16 @@ for t in basic_types: s = str(found_types[k]) s = '{' + s[1:-1] + ', 0}' stypes = stypes + ('static long int typecast_%s_types[] = %s;\n' % (k, s)) - sstruct = sstruct + (' {"%s", typecast_%s_types, typecast_%s_cast},\n' - % (k, k, k)) + sstruct += (' {"%s", typecast_%s_types, typecast_%s_cast, NULL},\n' + % (k, k, k)) +for t in array_types: + kt = t[0] + ka = t[0]+'ARRAY' + s = str(t[1]) + s = '{' + s[1:-1] + ', 0}' + stypes = stypes + ('static long int typecast_%s_types[] = %s;\n' % (ka, s)) + sstruct += (' {"%s", typecast_%s_types, typecast_%s_cast, "%s"},\n' + % (ka, ka, ka, kt)) sstruct = HEADER + sstruct + FOOTER print stypes |