Skip to content

Commit e651da0

Browse files
committed
Merge branch 'api-cleanup' into wl10980-row-locking
# Conflicts: # devapi/tests/crud-t.cc # include/devapi/collection_crud.h # include/devapi/statement.h # xapi/tests/xapi_crud-t.cc
2 parents a78546b + d6bbd9e commit e651da0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+6627
-4820
lines changed

CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,14 @@ else()
204204
add_definitions(-DCONCPP_BUILD_SHARED)
205205
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
206206

207+
# Hide all symbols that are not explicitly exported.
207208
# Note: setting target property CXX_VISIBILITY did not work for
208209
# object libraries that we use to build the connector.
209210

210-
if(CMAKE_COMPILER_IS_GNUCXX)
211-
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
212-
add_compile_options(-fvisibility-ms-compat)
213-
elseif()
214-
add_compile_options(-fvisibility=hidden)
215-
endif()
211+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
212+
add_compile_options(-fvisibility-ms-compat)
213+
elseif(CMAKE_COMPILER_IS_GNUCXX)
214+
add_compile_options(-fvisibility=hidden)
216215
endif()
217216

218217
endif()

cdk/cmake/headers.cmake

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,29 @@ SET(headers_dir "${headers_dir}/headers")
5959
#MESSAGE("headers.cmake: ${headers_dir}")
6060

6161

62+
#
63+
# Check if given list of headers includes all headers that can be found in
64+
# the current directory.
65+
#
66+
67+
function(check_headers)
68+
69+
file(GLOB all_headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
70+
71+
foreach(header IN LISTS ARGV)
72+
#message("- checking header: ${header}\n")
73+
list(REMOVE_ITEM all_headers ${header})
74+
endforeach()
75+
76+
list(LENGTH all_headers remains)
77+
78+
if(remains GREATER 0)
79+
message(WARNING "Extra headers found in ${CMAKE_CURRENT_SOURCE_DIR}: ${all_headers}")
80+
endif()
81+
82+
endfunction()
83+
84+
6285
#
6386
# Set-up header declarations with given folder as a base location for all
6487
# public headers.

cdk/include/mysql/cdk/api/document.h

Lines changed: 79 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class Doc_base : public Expr_base< Doc_processor<PRC> >
170170
with Doc_path_processor to describe one element of the path.
171171
*/
172172

173-
class Doc_path_processor
173+
class Doc_path_element_processor
174174
{
175175
public:
176176

@@ -198,7 +198,20 @@ class Doc_path_processor
198198
virtual void any_path() =0;
199199
};
200200

201-
typedef Expr_list< Expr_base<Doc_path_processor> > Doc_path;
201+
202+
class Doc_path_processor
203+
: public List_processor< Doc_path_element_processor >
204+
{
205+
public:
206+
207+
typedef Element_prc::string string;
208+
typedef Element_prc::index_t index_t;
209+
210+
// The "$" path which denotes the whole document.
211+
virtual void whole_document() = 0;
212+
};
213+
214+
typedef Expr_base<Doc_path_processor> Doc_path;
202215

203216

204217
}} // cdk::api
@@ -209,7 +222,7 @@ namespace cdk {
209222
class Doc_path_storage
210223
: public api::Doc_path
211224
, public api::Doc_path::Processor
212-
, api::Doc_path_processor
225+
, api::Doc_path_element_processor
213226
{
214227
public:
215228

@@ -221,6 +234,9 @@ class Doc_path_storage
221234
DOUBLE_ASTERISK
222235
};
223236

237+
using api::Doc_path_element_processor::string;
238+
using api::Doc_path_element_processor::index_t;
239+
224240
protected:
225241

226242
struct Path_el
@@ -243,7 +259,12 @@ class Doc_path_storage
243259

244260
bool is_empty() const
245261
{
246-
return 0 == length();
262+
return m_whole_document ? false : 0 == length();
263+
}
264+
265+
bool is_whole_document() const
266+
{
267+
return m_whole_document;
247268
}
248269

249270
const Path_el& get_el(size_t pos) const
@@ -260,11 +281,17 @@ class Doc_path_storage
260281

261282
void process(Processor &prc) const
262283
{
284+
if (m_whole_document)
285+
{
286+
prc.whole_document();
287+
return;
288+
}
289+
263290
prc.list_begin();
264291

265292
for (size_t pos = 0; pos < m_path.size(); ++pos)
266293
{
267-
api::Doc_path_processor *eprc = prc.list_el();
294+
api::Doc_path_element_processor *eprc = prc.list_el();
268295
if (eprc)
269296
{
270297
const Path_el &el = m_path[pos];
@@ -285,10 +312,12 @@ class Doc_path_storage
285312

286313
// List_processor
287314

288-
Path_el *m_el;
315+
bool m_whole_document = false;
316+
Path_el *m_el = NULL;
289317

290318
Element_prc* list_el()
291319
{
320+
assert(!m_whole_document);
292321
m_path.push_back(Path_el());
293322
m_el = &m_path.back();
294323
return this;
@@ -298,6 +327,11 @@ class Doc_path_storage
298327

299328
// Doc_path_processor
300329

330+
void whole_document()
331+
{
332+
m_whole_document = true;
333+
}
334+
301335
void member(const string &name)
302336
{
303337
assert(m_el);
@@ -398,10 +432,10 @@ struct Safe_prc< cdk::api::Doc_processor<PRC> >
398432

399433

400434
template<>
401-
struct Safe_prc<api::Doc_path_processor>
402-
: Safe_prc_base<api::Doc_path_processor>
435+
struct Safe_prc<api::Doc_path_element_processor>
436+
: Safe_prc_base<api::Doc_path_element_processor>
403437
{
404-
typedef Safe_prc_base<api::Doc_path_processor> Base;
438+
typedef Safe_prc_base<api::Doc_path_element_processor> Base;
405439
using Base::Processor;
406440
typedef Processor::string string;
407441
typedef Processor::index_t index_t;
@@ -430,6 +464,42 @@ struct Safe_prc<api::Doc_path_processor>
430464
{ return m_prc ? m_prc->any_path() : (void)NULL; }
431465
};
432466

467+
template<>
468+
struct Safe_prc<api::Doc_path_processor>
469+
: Safe_prc_base<api::Doc_path_processor>
470+
{
471+
472+
typedef Safe_prc_base<api::Doc_path_processor> Base;
473+
using Base::Processor;
474+
typedef Processor::string string;
475+
typedef Processor::index_t index_t;
476+
477+
Safe_prc(Processor *prc) : Base(prc)
478+
{}
479+
480+
Safe_prc(Processor &prc) : Base(&prc)
481+
{}
482+
483+
void list_begin()
484+
{
485+
if (m_prc)
486+
m_prc->list_begin();
487+
}
488+
489+
void list_end()
490+
{
491+
if (m_prc)
492+
m_prc->list_end();
493+
}
494+
495+
api::Doc_path_processor::Element_prc* list_el()
496+
{ return m_prc ? m_prc->list_el() : NULL; }
497+
498+
void whole_document()
499+
{ return m_prc ? m_prc->whole_document() : (void)NULL; }
500+
501+
};
502+
433503
}
434504

435505
#endif

cdk/include/mysql/cdk/protocol/mysqlx/expr.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,14 @@ class Doc_path
235235
MEMBER_ASTERISK = 2,
236236
ARRAY_INDEX = 3,
237237
ARRAY_INDEX_ASTERISK = 4,
238-
DOUBLE_ASTERISK = 5
238+
DOUBLE_ASTERISK = 5,
239239
};
240240

241241
virtual ~Doc_path() {}
242242

243+
// The "$" path which denotes the whole document.
244+
virtual bool is_whole_document() const = 0;
245+
243246
virtual unsigned length() const =0;
244247
virtual Type get_type(unsigned pos) const =0;
245248
virtual const string* get_name(unsigned pos) const =0;

cdk/mysqlx/converters.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ struct Doc_path_storage
170170

171171
// Proto_path interface
172172

173+
bool is_whole_document() const
174+
{
175+
return cdk::Doc_path_storage::is_whole_document();
176+
}
177+
173178
unsigned length() const
174179
{
175180
size_t len = cdk::Doc_path_storage::length();

0 commit comments

Comments
 (0)