MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
jtie_tconv_vwidth.hpp
1 /*
2  Copyright 2010 Sun Microsystems, Inc.
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 /*
19  * jtie_tconv_vwidth.hpp
20  */
21 
22 #ifndef jtie_tconv_vwidth_hpp
23 #define jtie_tconv_vwidth_hpp
24 
25 #include <jni.h>
26 
27 #include "jtie_tconv.hpp"
28 #include "jtie_tconv_value.hpp"
29 
30 // ---------------------------------------------------------------------------
31 // Java <-> C variable-width type mappings
32 // ---------------------------------------------------------------------------
33 
34 // No definitions are given here for [[un]signed] char types; instead
35 // char is treated as an exact-width type of 8 bits.
36 #if 0 // use a static_assert() when made available in upcoming C++0x
37 #include <limits.h> // not using namespaces yet
38 static_assert(CHAR_BIT == 8);
39 #endif // use a static_assert() when made available in upcoming C++0x
40 
41 /*
42  * If defined, provides a default Java type mapping for the variable-width
43  * C++ types: short, int, long, long long, long double.
44  *
45  * Examples (for the ILP32 data model):
46  * #define JTIE_JNI_SHORT_T jshort
47  * #define JTIE_JNI_INT_T jint
48  * #define JTIE_JNI_LONG_T jint
49  * #define JTIE_JNI_LONGLONG_T jlong
50  * #define JTIE_JNI_LONGDOUBLE_T jdouble
51  */
52 
53 #ifdef JTIE_JNI_SHORT_T
54 JTIE_DEFINE_BASIC_TYPE_MAPPING(JTIE_JNI_SHORT_T, signed short, short);
55 JTIE_DEFINE_BASIC_TYPE_MAPPING(JTIE_JNI_SHORT_T, unsigned short, ushort);
56 #endif
57 #ifdef JTIE_JNI_INT_T
58 JTIE_DEFINE_BASIC_TYPE_MAPPING(JTIE_JNI_INT_T, signed int, int);
59 JTIE_DEFINE_BASIC_TYPE_MAPPING(JTIE_JNI_INT_T, unsigned int, uint);
60 #endif
61 #ifdef JTIE_JNI_LONG_T
62 JTIE_DEFINE_BASIC_TYPE_MAPPING(JTIE_JNI_LONG_T, signed long, long);
63 JTIE_DEFINE_BASIC_TYPE_MAPPING(JTIE_JNI_LONG_T, unsigned long, ulong);
64 #endif
65 #ifdef JTIE_JNI_LONGLONG_T
66 JTIE_DEFINE_BASIC_TYPE_MAPPING(JTIE_JNI_LONGLONG_T, signed long long, longlong);
67 JTIE_DEFINE_BASIC_TYPE_MAPPING(JTIE_JNI_LONGLONG_T, unsigned long long, ulonglong);
68 #endif
69 #ifdef JTIE_JNI_LONGDOUBLE_T
70 JTIE_DEFINE_BASIC_TYPE_MAPPING(JTIE_JNI_LONGDOUBLE_T, long double, longdouble);
71 #endif
72 
73 // ---------------------------------------------------------------------------
74 
75 /*
76 // XXX variable-width type ByteBuffer conversions not supported yet
77 // - operational but no unit-tests yet
78 
79 JTIE_DEFINE_BYTEBUFFER_REF_TYPE_MAPPING(signed short, short)
80 JTIE_DEFINE_BYTEBUFFER_REF_TYPE_MAPPING(unsigned short, ushort)
81 JTIE_DEFINE_BYTEBUFFER_REF_TYPE_MAPPING(signed int, int)
82 JTIE_DEFINE_BYTEBUFFER_REF_TYPE_MAPPING(unsigned int, uint)
83 JTIE_DEFINE_BYTEBUFFER_REF_TYPE_MAPPING(signed long, long)
84 JTIE_DEFINE_BYTEBUFFER_REF_TYPE_MAPPING(unsigned long, ulong)
85 JTIE_DEFINE_BYTEBUFFER_REF_TYPE_MAPPING(signed long long, longlong)
86 JTIE_DEFINE_BYTEBUFFER_REF_TYPE_MAPPING(unsigned long long, ulonglong)
87 JTIE_DEFINE_BYTEBUFFER_REF_TYPE_MAPPING(long double, longdouble)
88 
89 JTIE_DEFINE_BYTEBUFFER_PTR_TYPE_MAPPING(signed short, short)
90 JTIE_DEFINE_BYTEBUFFER_PTR_TYPE_MAPPING(unsigned short, ushort)
91 JTIE_DEFINE_BYTEBUFFER_PTR_TYPE_MAPPING(signed int, int)
92 JTIE_DEFINE_BYTEBUFFER_PTR_TYPE_MAPPING(unsigned int, uint)
93 JTIE_DEFINE_BYTEBUFFER_PTR_TYPE_MAPPING(signed long, long)
94 JTIE_DEFINE_BYTEBUFFER_PTR_TYPE_MAPPING(unsigned long, ulong)
95 JTIE_DEFINE_BYTEBUFFER_PTR_TYPE_MAPPING(signed long long, longlong)
96 JTIE_DEFINE_BYTEBUFFER_PTR_TYPE_MAPPING(unsigned long long, ulonglong)
97 JTIE_DEFINE_BYTEBUFFER_PTR_TYPE_MAPPING(long double, longdouble)
98 
99 JTIE_DEFINE_BYTEBUFFER_PTR_LENGTH1_TYPE_MAPPING(signed short, short)
100 JTIE_DEFINE_BYTEBUFFER_PTR_LENGTH1_TYPE_MAPPING(unsigned short, ushort)
101 JTIE_DEFINE_BYTEBUFFER_PTR_LENGTH1_TYPE_MAPPING(signed int, int)
102 JTIE_DEFINE_BYTEBUFFER_PTR_LENGTH1_TYPE_MAPPING(unsigned int, uint)
103 JTIE_DEFINE_BYTEBUFFER_PTR_LENGTH1_TYPE_MAPPING(signed long, long)
104 JTIE_DEFINE_BYTEBUFFER_PTR_LENGTH1_TYPE_MAPPING(unsigned long, ulong)
105 JTIE_DEFINE_BYTEBUFFER_PTR_LENGTH1_TYPE_MAPPING(signed long long, longlong)
106 JTIE_DEFINE_BYTEBUFFER_PTR_LENGTH1_TYPE_MAPPING(unsigned long long, ulonglong)
107 JTIE_DEFINE_BYTEBUFFER_PTR_LENGTH1_TYPE_MAPPING(long double, longdouble)
108 */
109 
110 // ---------------------------------------------------------------------------
111 
112 /*
113 // XXX variable-width type array conversions not supported yet
114 // - default implementation would only support same-width types
115 // - no unit tests yet
116 
117 #define JTIE_JNI_SHORT_ARRAY_T _jshortArray
118 #define JTIE_JNI_INT_ARRAY_T _jintArray
119 #define JTIE_JNI_LONG_ARRAY_T _jintArray
120 #define JTIE_JNI_LONGLONG_ARRAY_T _jlongArray
121 #define JTIE_JNI_LONGDOUBLE_ARRAY_T _jdoubleArray
122 */
123 
124 // ---------------------------------------------------------------------------
125 
126 #endif // jtie_tconv_vwidth_hpp