Changeset: 1e9d782e14a2 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1e9d782e14a2 Modified Files: gdk/gdk.h gdk/gdk_atoms.c gdk/gdk_atoms.h gdk/gdk_atoms.mx gdk/gdk_value.c gdk/gdk_value.mx Branch: headless Log Message:
Pass through gdk_atoms and gdk_value. diffs (truncated from 2571 to 300 lines): diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -745,8 +745,6 @@ /* interface definitions */ gdk_export ValPtr VALnew(void); gdk_export ptr VALconvert(int typ, ValPtr t); -gdk_export ptr VALconvert1(int typ, ValPtr src, ValPtr dst); -gdk_export ptr VALconvert2(int typ, ValPtr src, ValPtr dst); gdk_export int VALformat(char **buf, ValPtr res); gdk_export int VALprint(stream *fd, ValPtr res); gdk_export ValPtr VALcopy(ValPtr dst, ValPtr src); diff --git a/gdk/gdk_atoms.mx b/gdk/gdk_atoms.c rename from gdk/gdk_atoms.mx rename to gdk/gdk_atoms.c --- a/gdk/gdk_atoms.mx +++ b/gdk/gdk_atoms.c @@ -1,194 +1,38 @@ -@/ -The contents of this file are subject to the MonetDB Public License -Version 1.1 (the "License"); you may not use this file except in -compliance with the License. You may obtain a copy of the License at -http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html +/* + * The contents of this file are subject to the MonetDB Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is the MonetDB Database System. + * + * The Initial Developer of the Original Code is CWI. + * Portions created by CWI are Copyright (C) 1997-July 2008 CWI. + * Copyright August 2008-2011 MonetDB B.V. + * All Rights Reserved. + */ -Software distributed under the License is distributed on an "AS IS" -basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -License for the specific language governing rights and limitations -under the License. - -The Original Code is the MonetDB Database System. - -The Initial Developer of the Original Code is CWI. -Portions created by CWI are Copyright (C) 1997-July 2008 CWI. -Copyright August 2008-2011 MonetDB B.V. -All Rights Reserved. -@ - -@f gdk_atoms -@a M. L. Kersten, P. Boncz -@* Atomic types -The Binary Association Table library assumes efficient implementation of -the atoms making up the binary association. -This section describes the preliminaries for handling -both built-in and user-defined atomic types. -New types, such as point and polygons, can be readily added to this -collection. -@- -@{ -@h -#ifndef _GDK_ATOMS_H_ -#define _GDK_ATOMS_H_ -#include "gdk.h" - -#define MAXATOMS 128 - -@- comparison macro's -In order to get maximum performance, we extensively use out-factoring -of typechecks using Mx macros. To catch diverging code in one Mx macro -we use the following #defines for comparing atoms: -@h -#define simple_CMP(x,y,tpe) (simple_LT(x,y,tpe)?-1:simple_GT(x,y,tpe)) -#define simple_EQ(x,y,tpe) ((*(tpe*) (x)) == (*(tpe*) (y))) -#define simple_NE(x,y,tpe,nl) ((*(tpe*)(y)) != nl && (*(tpe*) (x)) != (*(tpe*) (y))) -#define simple_LT(x,y,tpe) ((*(tpe*) (x)) < (*(tpe*) (y))) -#define simple_GT(x,y,tpe) ((*(tpe*) (x)) > (*(tpe*) (y))) -#define simple_LE(x,y,tpe) ((*(tpe*) (x)) <= (*(tpe*) (y))) -#define simple_GE(x,y,tpe) ((*(tpe*) (x)) >= (*(tpe*) (y))) -#define atom_CMP(x,y,id) (*BATatoms[id].atomCmp)(x,y) -#define atom_EQ(x,y,id) ((*BATatoms[id].atomCmp)(x,y) == 0) -#define atom_NE(x,y,id,nl) ((*BATatoms[id].atomCmp)(y,BATatoms[id].atomNull) != 0 && (*BATatoms[id].atomCmp)(x,y) != 0) -#define atom_LT(x,y,id) ((*BATatoms[id].atomCmp)(x,y) < 0) -#define atom_GT(x,y,id) ((*BATatoms[id].atomCmp)(x,y) > 0) -#define atom_LE(x,y,id) ((*BATatoms[id].atomCmp)(x,y) <= 0) -#define atom_GE(x,y,id) ((*BATatoms[id].atomCmp)(x,y) >= 0) -#define simple_HASH(v,tpe,dst) ((dst) *(tpe *) (v)) -#define atom_HASH(v,id,dst) ((dst) (*BATatoms[id].atomHash)(v)) - -@- maximum atomic string lengths -@h -#define bitStrlen 8 -#define chrStrlen 8 -#define bteStrlen 8 -#define shtStrlen 12 -#define intStrlen 24 -#if SIZEOF_OID == SIZEOF_INT -#define oidStrlen 24 -#else -#define oidStrlen 48 -#endif -#if SIZEOF_WRD == SIZEOF_INT -#define wrdStrlen 24 -#else -#define wrdStrlen 48 -#endif -#if SIZEOF_PTR == SIZEOF_INT -#define ptrStrlen 24 -#else -#define ptrStrlen 48 -#endif -#define lngStrlen 48 -#define fltStrlen 48 -#define dblStrlen 96 - -@- -The system comes with the traditional atomic types: int (4 bytes), bool(1 -byte) and str (variable). In addition, we support the notion of an OID -type, which ensures uniqueness of its members. -This leads to the following type descriptor table. -@h - -#ifdef __cplusplus -extern "C" { -#endif -gdk_export int voidFromStr(str src, int *len, void **dst); -gdk_export int voidToStr(str *dst, int *len, void *src); -gdk_export void *voidRead(void *a, stream *s, size_t cnt); -gdk_export int voidWrite(void *a, stream *s, size_t cnt); - -gdk_export int lngFromStr(str src, int *len, lng **dst); -gdk_export int lngToStr(str *dst, int *len, lng *src); -gdk_export lng *lngRead(lng *a, stream *s, size_t cnt); -gdk_export int lngWrite(lng *a, stream *s, size_t cnt); -gdk_export int lngCmp(lng *r, lng *l); -BUN lngHash(lng *l); - -gdk_export int intFromStr(str src, int *len, int **dst); -gdk_export int intToStr(str *dst, int *len, int *src); -gdk_export int *intRead(int *a, stream *s, size_t cnt); -gdk_export int intWrite(int *a, stream *s, size_t cnt); -gdk_export int intCmp(int *r, int *l); -BUN intHash(int *i); - -gdk_export int batFromStr(str src, int *len, bat **dst); -gdk_export int batToStr(str *dst, int *len, bat *src); -gdk_export bat *batRead(bat *a, stream *s, size_t cnt); -gdk_export int batWrite(bat *a, stream *s, size_t cnt); - -gdk_export int ptrFromStr(str src, int *len, ptr **dst); -gdk_export int ptrToStr(str *dst, int *len, ptr *src); -gdk_export ptr *ptrRead(ptr *a, stream *s, size_t cnt); -gdk_export int ptrWrite(ptr *a, stream *s, size_t cnt); - -gdk_export int bitFromStr(str src, int *len, bit **dst); -gdk_export int bitToStr(str *dst, int *len, bit *src); -gdk_export bit *bitRead(bit *a, stream *s, size_t cnt); -gdk_export int bitWrite(bit *a, stream *s, size_t cnt); - -gdk_export int OIDfromStr(str src, int *len, oid **dst); -gdk_export int OIDtoStr(str *dst, int *len, oid *src); -gdk_export oid *oidRead(oid *a, stream *s, size_t cnt); -gdk_export int oidWrite(oid *a, stream *s, size_t cnt); - -gdk_export int shtFromStr(str src, int *len, sht **dst); -gdk_export int shtToStr(str *dst, int *len, sht *src); -gdk_export sht *shtRead(sht *a, stream *s, size_t cnt); -gdk_export int shtWrite(sht *a, stream *s, size_t cnt); -int shtCmp(sht *r, sht *l); -BUN shtHash(sht *s); - -gdk_export int bteFromStr(str src, int *len, bte **dst); -gdk_export int bteToStr(str *dst, int *len, bte *src); -gdk_export bte *bteRead(bte *a, stream *s, size_t cnt); -gdk_export int bteWrite(bte *a, stream *s, size_t cnt); -int bteCmp(bte *r, bte *l); -BUN bteHash(bte *c); - -gdk_export int chrFromStr(str src, int *len, chr **dst); -gdk_export int chrToStr(str *dst, int *len, chr *src); -gdk_export chr *chrRead(chr *a, stream *s, size_t cnt); -gdk_export int chrWrite(chr *a, stream *s, size_t cnt); -int chrCmp(chr *r, chr *l); -BUN chrHash(chr *c); - -gdk_export int fltFromStr(str src, int *len, flt **dst); -gdk_export int fltToStr(str *dst, int *len, flt *src); -gdk_export flt *fltRead(flt *a, stream *s, size_t cnt); -gdk_export int fltWrite(flt *a, stream *s, size_t cnt); -int fltCmp(flt *r, flt *l); - -gdk_export int dblFromStr(str src, int *len, dbl **dst); -gdk_export int dblToStr(str *dst, int *len, dbl *src); -gdk_export dbl *dblRead(dbl *a, stream *s, size_t cnt); -gdk_export int dblWrite(dbl *a, stream *s, size_t cnt); -int dblCmp(dbl *r, dbl *l); - -gdk_export ssize_t GDKstrFromStr(unsigned char *src, unsigned char *dst, ssize_t len); -gdk_export int strFromStr(str src, int *len, str *dst); -gdk_export int strToStr(str *dst, int *len, str src); -gdk_export str strRead(str a, stream *s, size_t cnt); -gdk_export int strWrite(str a, stream *s, size_t cnt); -gdk_export BUN strHash(const char *s); -gdk_export void strCleanHash(Heap *hp, int rebuild); -gdk_export var_t strPut(Heap *b, var_t *off, const char *src); -gdk_export void strHeap(Heap *d, size_t cap); -gdk_export int strLen(const char *s); -gdk_export int strCmp(const char *l, const char *r); -gdk_export int strNil(const char *s); -gdk_export int strElimDoubles(Heap *h); -gdk_export var_t strLocate(Heap *h, const char *v); -gdk_export int strCmpNoNil(const unsigned char *l, const unsigned char *r); -gdk_export int escapedStrlen(const char *src); -gdk_export int escapedStr(char *dst, const char *src, int dstlen); - -#ifdef __cplusplus -} -#endif -@- inline comparison routines -Return 0 on l==r, < 0 iff l < r, >0 iff l > r -@c +/* + * @f gdk_atoms + * @a M. L. Kersten, P. Boncz + * @* Atomic types + * The Binary Association Table library assumes efficient implementation of + * the atoms making up the binary association. + * This section describes the preliminaries for handling + * both built-in and user-defined atomic types. + * New types, such as point and polygons, can be readily added to this + * collection. + * @- + */ +/* + * @- inline comparison routines + * Return 0 on l==r, < 0 iff l < r, >0 iff l > r + */ #include "monetdb_config.h" #include "gdk.h" #include <math.h> /* for INFINITY and NAN */ @@ -235,9 +79,10 @@ return simple_CMP(l, r, dbl); } -@- inline hash routines -Return some positive integer derived from one atom value. -@c +/* + * @- inline hash routines + * Return some positive integer derived from one atom value. + */ BUN chrHash(chr *v) { @@ -268,8 +113,9 @@ return (BUN) mix_int(((unsigned int *) v)[0] ^ ((unsigned int *) v)[1]); } -@+ Standard Atoms -@c +/* + * @+ Standard Atoms + */ static inline void shtConvert(sht *s) { @@ -303,13 +149,13 @@ atomDesc BATatoms[MAXATOMS] = { {"void", #if SIZEOF_OID == SIZEOF_INT - TYPE_void, 1, 0, /* sizeof(@`void@7) */ 0, 0, 1, (ptr) &int_nil, + TYPE_void, 1, 0, /* sizeof(void) */ 0, 0, 1, (ptr) &int_nil, (int (*)(str, int *, ptr *)) OIDfromStr, (int (*)(str *, int *, ptr)) OIDtoStr, (void *(*)(void *, stream *, size_t)) voidRead, (int (*)(void *, stream *, size_t)) voidWrite, (int (*)(ptr, ptr)) intCmp, (BUN (*)(ptr)) intHash, 0, #else - TYPE_void, 1, 0, /* sizeof(@`void@7) */ 0, 0, 1, (ptr) &lng_nil, + TYPE_void, 1, 0, /* sizeof(void) */ 0, 0, 1, (ptr) &lng_nil, (int (*)(str, int *, ptr *)) OIDfromStr, (int (*)(str *, int *, ptr)) OIDtoStr, (void *(*)(void *, stream *, size_t)) voidRead, (int (*)(void *, stream *, size_t)) voidWrite, (int (*)(ptr, ptr)) lngCmp, @@ -319,7 +165,7 @@ 0, 0, 0, 0, 0, 0}, - {"bit", TYPE_chr, 1, sizeof(bit), sizeof(@`bit@7), 0, 0, (ptr) &chr_nil, + {"bit", TYPE_chr, 1, sizeof(bit), sizeof(bit), 0, 0, (ptr) &chr_nil, (int (*)(str, int *, ptr *)) bitFromStr, (int (*)(str *, int *, ptr)) bitToStr, (void *(*)(void *, stream *, size_t)) bitRead, (int (*)(void *, stream *, size_t)) bitWrite, (int (*)(ptr, ptr)) chrCmp, @@ -328,8 +174,8 @@ 0, 0, 0, 0, _______________________________________________ Checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
