MySQL 5.6.14 Source Code Document
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
jtie_tconv_object.hpp
1
/*
2
Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; version 2 of the License.
7
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
12
13
You should have received a copy of the GNU General Public License
14
along with this program; if not, write to the Free Software
15
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16
*/
17
/*
18
* jtie_tconv_object.hpp
19
*/
20
21
#ifndef jtie_tconv_object_hpp
22
#define jtie_tconv_object_hpp
23
24
#include <jni.h>
25
26
#include "jtie_tconv.hpp"
27
#include "jtie_tconv_idcache_impl.hpp"
28
29
// ---------------------------------------------------------------------------
30
// Java object <-> C class object type conversions
31
// ---------------------------------------------------------------------------
32
41
struct
_jtie_Object
: _jobject {
42
};
43
44
// XXX, document: type specifying an Object mapping with a class name
45
46
// trait type wrapping named-parametrized Object mappings for specialization
47
// XXX make use of
48
// JTIE_DEFINE_METHOD_MEMBER_INFO( _jtie_ObjectMapper< T > )
49
// to replace
50
// static const char * const class_name;
51
// static const char * const member_name;
52
// static const char * const member_descriptor;
53
// typedef _jmethodID * memberID_t;
54
template
<
typename
J >
55
struct
_jtie_ObjectMapper
:
_jtie_Object
{
56
// the name of the Java peer class in the JVM format (i.e., '/'-separated)
57
static
const
char
*
const
class_name;
58
59
// the name, descriptor, and JNI type of the class's no-arg c'tor
60
static
const
char
*
const
member_name;
61
static
const
char
*
const
member_descriptor;
62
typedef
_jmethodID * memberID_t;
63
};
64
65
// XXX static initialization <-> multiple compilation units <-> jtie_lib.hpp
66
template
<
typename
J >
67
const
char
*
const
_jtie_ObjectMapper< J >::class_name
68
= J::class_name;
// XXX static initialization order dependency?
69
70
template
<
typename
J >
71
const
char
*
const
_jtie_ObjectMapper< J >::member_name
72
=
"<init>"
;
73
74
template
<
typename
J >
75
const
char
*
const
_jtie_ObjectMapper< J >::member_descriptor
76
=
"()V"
;
77
78
// Design note:
79
//
80
// As of pre-C++0x, string literals cannot be used as template arguments
81
// which must be integral constants with external linkage.
82
//
83
// So, we cannot declare:
84
//
85
// template< const char * >
86
// struct _jtie_ClassNamedObject : _jtie_Object {
87
// static const char * const java_internal_class_name;
88
// };
89
//
90
// As a feasible workaround, we require the application to provide a
91
// trait type for each class, e.g.
92
//
93
// struct _m_A : _jobject {
94
// static const char * const java_internal_class_name;
95
// };
96
// const char * const _m_A::java_internal_class_name = "myjapi/A";
97
//
98
// and we retrieve the class name from there.
99
129
#define JTIE_DEFINE_PEER_CLASS_MAPPING( C, T ) \
130
struct T { \
131
static const char * const class_name; \
132
}; \
133
typedef ttrait< jobject, C, _jtie_ObjectMapper< T > * \
134
> ttrait_##T##_t; \
135
typedef ttrait< jobject, const C, _jtie_ObjectMapper< T > * \
136
> ttrait_##T##_ct; \
137
typedef ttrait< jobject, C &, _jtie_ObjectMapper< T > * \
138
> ttrait_##T##_r; \
139
typedef ttrait< jobject, const C &, _jtie_ObjectMapper< T > * \
140
> ttrait_##T##_cr; \
141
typedef ttrait< jobject, C *, _jtie_ObjectMapper< T > * \
142
> ttrait_##T##_p; \
143
typedef ttrait< jobject, const C *, _jtie_ObjectMapper< T > * \
144
> ttrait_##T##_cp; \
145
typedef ttrait< jobject, C * const, _jtie_ObjectMapper< T > * \
146
> ttrait_##T##_pc; \
147
typedef ttrait< jobject, const C * const, _jtie_ObjectMapper< T > * \
148
> ttrait_##T##_cpc;
149
150
#if 0 // XXX cleanup this unsupported mapping
151
152
* Naming convention:
153
*
type
alias: specifies a mapping:
154
* ttrait_<T>_a J <-> C *
155
* ttrait_<T>_ca J <->
const
C *
156
* ttrait_<T>_ac J <-> C *
const
157
* ttrait_<T>_cac J <->
const
C *
const
158
175
#define JTIE_DEFINE_ARRAY_PTR_TYPE_MAPPING( J, C, T ) \
176
typedef ttrait< J *, C * \
177
> ttrait_##T##_0p_a; \
178
typedef ttrait< J *, const C * \
179
> ttrait_##T##_0cp_a; \
180
typedef ttrait< J *, C * const \
181
> ttrait_##T##_0pc_a; \
182
typedef ttrait< J *, const C * const \
183
> ttrait_##T##_0cpc_a;
184
201
#define JTIE_DEFINE_ARRAY_PTR_LENGTH1_TYPE_MAPPING( J, C, T ) \
202
typedef ttrait< J *, C *, _jtie_j_ArrayMapper< _jtie_j_BoundedArray< J, 1 > > * \
203
> ttrait_##T##_1p_a; \
204
typedef ttrait< J *, const C *, _jtie_j_ArrayMapper< _jtie_j_BoundedArray< J, 1 > > * \
205
> ttrait_##T##_1cp_a; \
206
typedef ttrait< J *, C * const, _jtie_j_ArrayMapper< _jtie_j_BoundedArray< J, 1 > > * \
207
> ttrait_##T##_1pc_a; \
208
typedef ttrait< J *, const C * const, _jtie_j_ArrayMapper< _jtie_j_BoundedArray< J, 1 > > * \
209
> ttrait_##T##_1cpc_a;
210
211
// XXX and this is how it's done
212
typedef
ttrait
< jobjectArray, C *,
\
213
_jtie_j_ArrayMapper
<
\
214
_jtie_j_BoundedArray
<
\
215
_jtie_ObjectMapper< J >
, \
216
1 > \
217
> * \
218
> ttrait_##J##_1a; \
219
220
#endif // XXX cleanup this unsupported mapping
221
222
// XXX to document
223
// XXX static initialization <-> multiple compilation units <-> jtie_lib.hpp
224
// XXX replace
225
// template struct MemberId< _jtie_ObjectMapper< T > >;
226
// template struct MemberIdCache< _jtie_ObjectMapper< T > >;
227
// with
228
// JTIE_INSTANTIATE_CLASS_MEMBER_INFO_X(_jtie_ObjectMapper< T >,
229
// JCN, "<init>", "()V")
230
#define JTIE_INSTANTIATE_PEER_CLASS_MAPPING( T, JCN ) \
231
const char * const T::class_name = JCN; \
232
template struct _jtie_ObjectMapper< T >; \
233
template struct MemberId< _jtie_ObjectMapper< T > >; \
234
template struct MemberIdCache< _jtie_ObjectMapper< T > >;
235
236
// ---------------------------------------------------------------------------
237
238
#endif // jtie_tconv_object_hpp
storage
ndb
src
ndbjtie
jtie
jtie_tconv_object.hpp
Generated on Sat Nov 9 2013 01:28:11 for MySQL 5.6.14 Source Code Document by
1.8.1.2