diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2010-10-22 20:05:54 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2010-10-22 20:05:54 +0000 |
commit | 948cb037aec073255d71a19ae1f9f5a351deff72 (patch) | |
tree | 7a57b0ec1734cd997d21bd0ef6e9120986b0d22a /src | |
parent | f7e6723b638be83e33e9ecc6ea23ce43318b7b4c (diff) |
Added a workaround for GCC 4.2 bogus warning
git-svn-id: http://pugixml.googlecode.com/svn/trunk@778 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'src')
-rw-r--r-- | src/pugixml.cpp | 105 | ||||
-rw-r--r-- | src/pugixml.hpp | 6 |
2 files changed, 57 insertions, 54 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 837f5dc..833e43e 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -440,7 +440,10 @@ namespace pugi xml_attribute_struct* first_attribute; ///< First attribute }; +} +namespace +{ struct xml_document_struct: public xml_node_struct, public xml_allocator { xml_document_struct(xml_memory_page* page): xml_node_struct(page, node_document), xml_allocator(page), buffer(0) @@ -8899,6 +8902,49 @@ namespace #endif } }; + + struct xpath_query_impl + { + static xpath_query_impl* create() + { + void* memory = global_allocate(sizeof(xpath_query_impl)); + + return new (memory) xpath_query_impl(); + } + + static void destroy(void* ptr) + { + if (!ptr) return; + + // free all allocated pages + static_cast<xpath_query_impl*>(ptr)->alloc.release(); + + // free allocator memory (with the first page) + global_deallocate(ptr); + } + + xpath_query_impl(): root(0), alloc(&block) + { + block.next = 0; + } + + xpath_ast_node* root; + xpath_allocator alloc; + xpath_memory_block block; + }; + + xpath_string evaluate_string_impl(xpath_query_impl* impl, const xpath_node& n, xpath_stack_data& sd) + { + if (!impl) return xpath_string(); + + #ifdef PUGIXML_NO_EXCEPTIONS + if (setjmp(sd.error_handler)) return xpath_string(); + #endif + + xpath_context c(n, 1, 1); + + return impl->root->eval_string(c, sd.stack); + } } namespace pugi @@ -9294,36 +9340,6 @@ namespace pugi return find(name); } - struct xpath_query_impl - { - static xpath_query_impl* create() - { - void* memory = global_allocate(sizeof(xpath_query_impl)); - - return new (memory) xpath_query_impl(); - } - - static void destroy(void* ptr) - { - if (!ptr) return; - - // free all allocated pages - static_cast<xpath_query_impl*>(ptr)->alloc.release(); - - // free allocator memory (with the first page) - global_deallocate(ptr); - } - - xpath_query_impl(): root(0), alloc(&block) - { - block.next = 0; - } - - xpath_ast_node* root; - xpath_allocator alloc; - xpath_memory_block block; - }; - xpath_query::xpath_query(const char_t* query, xpath_variable_set* variables): _impl(0) { xpath_query_impl* impl = xpath_query_impl::create(); @@ -9359,7 +9375,7 @@ namespace pugi { if (!_impl) return xpath_type_none; - return _impl->root->rettype(); + return static_cast<xpath_query_impl*>(_impl)->root->rettype(); } bool xpath_query::evaluate_boolean(const xpath_node& n) const @@ -9373,7 +9389,7 @@ namespace pugi if (setjmp(sd.error_handler)) return false; #endif - return _impl->root->eval_boolean(c, sd.stack); + return static_cast<xpath_query_impl*>(_impl)->root->eval_boolean(c, sd.stack); } double xpath_query::evaluate_number(const xpath_node& n) const @@ -9387,28 +9403,15 @@ namespace pugi if (setjmp(sd.error_handler)) return gen_nan(); #endif - return _impl->root->eval_number(c, sd.stack); + return static_cast<xpath_query_impl*>(_impl)->root->eval_number(c, sd.stack); } - static xpath_string evaluate_string_impl(xpath_query_impl* impl, const xpath_node& n, xpath_stack_data& sd) - { - if (!impl) return xpath_string(); - - #ifdef PUGIXML_NO_EXCEPTIONS - if (setjmp(sd.error_handler)) return xpath_string(); - #endif - - xpath_context c(n, 1, 1); - - return impl->root->eval_string(c, sd.stack); - } - #ifndef PUGIXML_NO_STL string_t xpath_query::evaluate_string(const xpath_node& n) const { xpath_stack_data sd; - return evaluate_string_impl(_impl, n, sd).c_str(); + return evaluate_string_impl(static_cast<xpath_query_impl*>(_impl), n, sd).c_str(); } #endif @@ -9416,7 +9419,7 @@ namespace pugi { xpath_stack_data sd; - xpath_string r = evaluate_string_impl(_impl, n, sd); + xpath_string r = evaluate_string_impl(static_cast<xpath_query_impl*>(_impl), n, sd); size_t full_size = r.length() + 1; @@ -9436,7 +9439,9 @@ namespace pugi { if (!_impl) return xpath_node_set(); - if (_impl->root->rettype() != xpath_type_node_set) + xpath_ast_node* root = static_cast<xpath_query_impl*>(_impl)->root; + + if (root->rettype() != xpath_type_node_set) { #ifdef PUGIXML_NO_EXCEPTIONS return xpath_node_set(); @@ -9455,7 +9460,7 @@ namespace pugi if (setjmp(sd.error_handler)) return xpath_node_set(); #endif - xpath_node_set_raw r = _impl->root->eval_node_set(c, sd.stack); + xpath_node_set_raw r = root->eval_node_set(c, sd.stack); return xpath_node_set(r.begin(), r.end(), r.type()); } diff --git a/src/pugixml.hpp b/src/pugixml.hpp index bd6ad5f..63e0233 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -774,8 +774,6 @@ namespace pugi }; #ifndef PUGIXML_NO_XPATH - struct xpath_query_impl; - // XPath query return type enum xpath_value_type { @@ -875,10 +873,10 @@ namespace pugi class PUGIXML_CLASS xpath_query { private: - xpath_query_impl* _impl; + void* _impl; xpath_parse_result _result; - typedef xpath_query_impl* xpath_query::*unspecified_bool_type; + typedef void* xpath_query::*unspecified_bool_type; // Non-copyable semantics xpath_query(const xpath_query&); |