zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #25668
[Merge] lp:~zorba-coders/zorba/diagnostic-namespaces into lp:zorba
Paul J. Lucas has proposed merging lp:~zorba-coders/zorba/diagnostic-namespaces into lp:zorba.
Commit message:
You can now add more namespaces/prefixes to diagnostics_*.xml files. The upshot is that core modules can have errors in their own namespaces.
Requested reviews:
Paul J. Lucas (paul-lucas)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/diagnostic-namespaces/+merge/185610
You can now add more namespaces/prefixes to diagnostics_*.xml files. The upshot is that core modules can have errors in their own namespaces.
--
https://code.launchpad.net/~zorba-coders/zorba/diagnostic-namespaces/+merge/185610
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/CMakeLists.txt'
--- include/CMakeLists.txt 2013-02-07 17:24:36 +0000
+++ include/CMakeLists.txt 2013-09-14 00:51:56 +0000
@@ -27,3 +27,9 @@
${CMAKE_CURRENT_BINARY_DIR}/zorba/config.h
${CMAKE_CURRENT_BINARY_DIR}/zorba/diagnostic_list.h
DESTINATION include/zorba)
+
+INSTALL(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/zorba/qnames.h
+ DESTINATION include/zorba/internal)
+
+# vim:set et sw=2 ts=2:
=== modified file 'include/zorba/diagnostic.h'
--- include/zorba/diagnostic.h 2013-06-04 00:34:52 +0000
+++ include/zorba/diagnostic.h 2013-09-14 00:51:56 +0000
@@ -270,8 +270,6 @@
} // namespace diagnostic
} // namespace zorba
-#include <zorba/internal/qname.h>
-
namespace zorba {
///////////////////////////////////////////////////////////////////////////////
@@ -344,7 +342,8 @@
} // namespace zorba
-#include <zorba/internal/diagnostic.h>
+#include <zorba/internal/system_diagnostic.h>
+#include <zorba/internal/qname.h>
#endif /* ZORBA_DIAGNOSTIC_API_H */
/*
=== modified file 'include/zorba/error.h'
--- include/zorba/error.h 2013-06-15 02:57:08 +0000
+++ include/zorba/error.h 2013-09-14 00:51:56 +0000
@@ -17,12 +17,11 @@
#ifndef ZORBA_ERROR_API_H
#define ZORBA_ERROR_API_H
-#include <zorba/internal/system_diagnostic.h>
+#include <zorba/internal/diagnostic.h>
#include <zorba/internal/qname.h>
namespace zorba {
-class Diagnostic;
namespace serialization {
class Archiver;
void operator&( serialization::Archiver&, const Diagnostic*& );
@@ -33,23 +32,6 @@
typedef Diagnostic Error;
/**
- * An %XQueryErrorCode is a diagnostic for all XQuery-specific errors.
- */
-typedef internal::SystemDiagnostic<internal::XQueryErrQName> XQueryErrorCode;
-
-/**
- * A %ZorbaErrorCode is a diagnostic for all Zorba-specific errors.
- */
-typedef internal::SystemDiagnostic<internal::ZorbaErrQName> ZorbaErrorCode;
-
-/**
- * An %JSONiqErrorCode is a diagnostic for all JSONiq-specific errors.
- */
-typedef internal::SystemDiagnostic<internal::JSONiqErrQName> JSONiqErrorCode;
-
-///////////////////////////////////////////////////////////////////////////////
-
-/**
* A %UserError is-a Diagnostic for user-defined errors via \c fn:error().
*/
class ZORBA_DLL_PUBLIC UserError : public Diagnostic {
=== modified file 'include/zorba/internal/diagnostic.h'
--- include/zorba/internal/diagnostic.h 2013-07-13 00:40:09 +0000
+++ include/zorba/internal/diagnostic.h 2013-09-14 00:51:56 +0000
@@ -239,7 +239,6 @@
column_type column_end_;
friend bool operator==( location const&, location const& );
- friend bool operator!=( location const&, location const& );
// for plan serialization
friend void serialization::operator&( serialization::Archiver&, location& );
@@ -263,7 +262,9 @@
* @param j The second location.
* @return Returns \c true only if the two locations are not equal.
*/
-bool operator!=( location const &i, location const &j );
+inline bool operator!=( location const &i, location const &j ) {
+ return !(i == j);
+}
///////////////////////////////////////////////////////////////////////////////
=== added directory 'include/zorba/internal/pregenerated'
=== added file 'include/zorba/internal/pregenerated/qnames.h'
--- include/zorba/internal/pregenerated/qnames.h 1970-01-01 00:00:00 +0000
+++ include/zorba/internal/pregenerated/qnames.h 2013-09-14 00:51:56 +0000
@@ -0,0 +1,86 @@
+/**
+ * Copyright 2006-2013 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ /*
+ * THIS FILE IS GENERATED.
+ * PLEASE DO NOT EDIT.
+ */
+
+
+#ifndef ZORBA_INTERNAL_QNAMES_H
+#define ZORBA_INTERNAL_QNAMES_H
+
+namespace zorba {
+namespace internal {
+
+class ZORBA_DLL_PUBLIC XQueryErrorQName :
+ public FixedQName<XQueryErrorQName,char const*>
+{
+ typedef FixedQName<XQueryErrorQName,char const*> base_type;
+public:
+ static char const NAMESPACE[];
+ static char const PREFIX[];
+ XQueryErrorQName( char const *localname ) : base_type( localname ) { }
+ zorba::diagnostic::kind kind() const;
+};
+
+class ZORBA_DLL_PUBLIC JSONiqErrorQName :
+ public FixedQName<JSONiqErrorQName,char const*>
+{
+ typedef FixedQName<JSONiqErrorQName,char const*> base_type;
+public:
+ static char const NAMESPACE[];
+ static char const PREFIX[];
+ JSONiqErrorQName( char const *localname ) : base_type( localname ) { }
+ zorba::diagnostic::kind kind() const;
+};
+
+class ZORBA_DLL_PUBLIC ZorbaErrorQName :
+ public FixedQName<ZorbaErrorQName,char const*>
+{
+ typedef FixedQName<ZorbaErrorQName,char const*> base_type;
+public:
+ static char const NAMESPACE[];
+ static char const PREFIX[];
+ ZorbaErrorQName( char const *localname ) : base_type( localname ) { }
+ zorba::diagnostic::kind kind() const;
+};
+
+class ZORBA_DLL_PUBLIC ZorbaWarningQName :
+ public FixedQName<ZorbaWarningQName,char const*>
+{
+ typedef FixedQName<ZorbaWarningQName,char const*> base_type;
+public:
+ static char const NAMESPACE[];
+ static char const PREFIX[];
+ ZorbaWarningQName( char const *localname ) : base_type( localname ) { }
+ zorba::diagnostic::kind kind() const;
+};
+
+} // namespace internal
+
+typedef internal::SystemDiagnostic<internal::XQueryErrorQName> XQueryErrorCode;
+typedef internal::SystemDiagnostic<internal::JSONiqErrorQName> JSONiqErrorCode;
+typedef internal::SystemDiagnostic<internal::ZorbaErrorQName> ZorbaErrorCode;
+typedef internal::SystemDiagnostic<internal::ZorbaWarningQName> ZorbaWarningCode;
+
+} // namespace zorba
+#endif /* ZORBA_INTERNAL_QNAMES_H */
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
=== modified file 'include/zorba/internal/qname.h'
--- include/zorba/internal/qname.h 2013-06-15 02:57:08 +0000
+++ include/zorba/internal/qname.h 2013-09-14 00:51:56 +0000
@@ -112,119 +112,10 @@
///////////////////////////////////////////////////////////////////////////////
-/**
- * A %ZorbaErrQName is-a FixedQName for Zorba errors.
- */
-class ZORBA_DLL_PUBLIC ZorbaErrQName :
- public FixedQName<ZorbaErrQName,char const*>
-{
- typedef FixedQName<ZorbaErrQName,char const*> base_type;
-public:
- static char const NAMESPACE[];
- static char const PREFIX[];
-
- /**
- * Constructs a %ZorbaErrQName.
- *
- * @param localname The local-name of the error.
- */
- ZorbaErrQName( char const *localname ) : base_type( localname ) { }
-
- /**
- * Gets the kind of error this QName represents.
- *
- * @return Returns said kind.
- */
- zorba::diagnostic::kind kind() const;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-/**
- * An %XQueryErrQName is-a FixedQName for standard XQuery errors.
- */
-class ZORBA_DLL_PUBLIC XQueryErrQName :
- public FixedQName<XQueryErrQName,char const*>
-{
- typedef FixedQName<XQueryErrQName,char const*> base_type;
-public:
- static char const NAMESPACE[];
- static char const PREFIX[];
-
- /**
- * Constructs an %XQueryErrQName.
- *
- * @param localname The local-name of the error.
- */
- XQueryErrQName( char const *localname ) : base_type( localname ) { }
-
- /**
- * Gets the kind of error this QName represents.
- *
- * @return Returns said kind.
- */
- zorba::diagnostic::kind kind() const;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-/**
- * An %JSONiqErrQName is-a FixedQName for standard JSONiq errors.
- */
-class ZORBA_DLL_PUBLIC JSONiqErrQName :
- public FixedQName<JSONiqErrQName,char const*>
-{
- typedef FixedQName<JSONiqErrQName,char const*> base_type;
-public:
- static char const NAMESPACE[];
- static char const PREFIX[];
-
- /**
- * Constructs an %JSONiqErrQName.
- *
- * @param localname The local-name of the error.
- */
- JSONiqErrQName( char const *localname ) : base_type( localname ) { }
-
- /**
- * Gets the kind of error this QName represents.
- *
- * @return Returns said kind.
- */
- zorba::diagnostic::kind kind() const;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-/**
- * An %ZorbaWarningQName is-a FixedQName for Zorba warnings.
- */
-class ZORBA_DLL_PUBLIC ZorbaWarningQName :
- public FixedQName<ZorbaWarningQName,char const*>
-{
- typedef FixedQName<ZorbaWarningQName,char const*> base_type;
-public:
- static char const NAMESPACE[];
- static char const PREFIX[];
-
- /**
- * Constructs a %ZorbaWarningQName.
- *
- * @param localname The local-name of the warning.
- */
- ZorbaWarningQName( char const *localname ) : base_type( localname ) { }
-
- /**
- * Gets the kind of warning this QName represents.
- *
- * @return Returns said kind.
- */
- zorba::diagnostic::kind kind() const;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
} // namespace internal
} // namespace zorba
+
+#include <zorba/internal/qnames.h>
+
#endif /* ZORBA_INTERNAL_QNAME_H */
/* vim:set et sw=2 ts=2: */
=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
--- include/zorba/pregenerated/diagnostic_list.h 2013-09-02 20:58:31 +0000
+++ include/zorba/pregenerated/diagnostic_list.h 2013-09-14 00:51:56 +0000
@@ -23,8 +23,7 @@
#define ZORBA_DIAGNOSTIC_LIST_API_H
#include <zorba/config.h>
-#include <zorba/error.h>
-#include <zorba/xquery_warning.h>
+#include <zorba/internal/qname.h>
namespace zorba {
=== modified file 'include/zorba/xquery_warning.h'
--- include/zorba/xquery_warning.h 2013-02-07 17:24:36 +0000
+++ include/zorba/xquery_warning.h 2013-09-14 00:51:56 +0000
@@ -17,8 +17,7 @@
#ifndef ZORBA_XQUERY_WARNING_API_H
#define ZORBA_XQUERY_WARNING_API_H
-#include <zorba/internal/qname.h>
-#include <zorba/internal/system_diagnostic.h>
+#include <zorba/diagnostic.h>
#include <zorba/xquery_exception.h>
namespace zorba {
@@ -28,12 +27,6 @@
typedef Diagnostic Warning;
/**
- * A %ZorbaWarningCode is a diagnostic for all Zorba-specific warnings.
- */
-typedef internal::SystemDiagnostic<internal::ZorbaWarningQName>
- ZorbaWarningCode;
-
-/**
* Re-use an XQueryException as an %XQueryWarning to:
* - leverage all the localization and printing code
* - allow warnings to be treated as exceptions and thrown
=== modified file 'src/compiler/parsetree/parsenode_base.h'
--- src/compiler/parsetree/parsenode_base.h 2013-02-07 17:24:36 +0000
+++ src/compiler/parsetree/parsenode_base.h 2013-09-14 00:51:56 +0000
@@ -19,6 +19,7 @@
#include <zorba/config.h>
#include <zorba/diagnostic_list.h>
+#include <zorba/error.h>
#include "compiler/parser/parse_constants.h"
#include "compiler/parser/query_loc.h"
=== modified file 'src/diagnostics/CMakeLists.txt'
--- src/diagnostics/CMakeLists.txt 2013-06-24 23:16:24 +0000
+++ src/diagnostics/CMakeLists.txt 2013-09-14 00:51:56 +0000
@@ -17,6 +17,8 @@
dict_en.cpp
diagnostic.cpp
qname.cpp
+ qname_util.cpp
+ qnames.cpp
diagnostic_list.cpp
assert.cpp
zorba_exception.cpp
@@ -28,17 +30,39 @@
dict_zed_keys.h
)
+IF (WIN32)
+ SET( DIAGNOSTICS_SRCS ${DIAGNOSTICS_SRCS} StackWalker.cpp )
+ENDIF (WIN32)
+
+###############################################################################
+
+ZORBA_DIAGNOSTIC_GENERATOR(
+ "${CMAKE_SOURCE_DIR}/src/diagnostics/qnames_h.xq"
+ "input=${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_namespaces.xml"
+ "diagnostic_namespaces.xml"
+ ""
+ "${CMAKE_BINARY_DIR}/include/zorba/internal/qnames.h"
+)
+
+ZORBA_DIAGNOSTIC_GENERATOR(
+ "${CMAKE_SOURCE_DIR}/src/diagnostics/qnames_cpp.xq"
+ "input=${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_namespaces.xml"
+ "diagnostic_namespaces.xml"
+ ""
+ "${CMAKE_BINARY_DIR}/src/diagnostics/qnames.cpp"
+)
+
ZORBA_DIAGNOSTIC_GENERATOR(
"${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_list_h.xq"
- "input=${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_en.xml"
+ "diagnostics-input=${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_en.xml;namespaces-input=${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_namespaces.xml"
"diagnostic_en.xml"
- ""
+ "${CMAKE_BINARY_DIR}/include/zorba/internal/qnames.h"
"${CMAKE_BINARY_DIR}/include/zorba/diagnostic_list.h"
)
ZORBA_DIAGNOSTIC_GENERATOR(
"${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_list_cpp.xq"
- "input=${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_en.xml"
+ "diagnostics-input=${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_en.xml;namespaces-input=${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_namespaces.xml"
"diagnostic_en.xml"
"${CMAKE_BINARY_DIR}/include/zorba/diagnostic_list.h"
"${CMAKE_BINARY_DIR}/src/diagnostics/diagnostic_list.cpp"
@@ -53,6 +77,16 @@
)
ZORBA_DIAGNOSTIC_GENERATOR(
+ "${CMAKE_SOURCE_DIR}/src/diagnostics/dict_zed_keys_h.xq"
+ "input=${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_en.xml"
+ "diagnostic_en.xml"
+ ""
+ "${CMAKE_BINARY_DIR}/src/diagnostics/dict_zed_keys.h"
+)
+
+###############################################################################
+
+ZORBA_DIAGNOSTIC_GENERATOR(
"${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_list_xq.xq"
"input=${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_en.xml;ns:=err"
"diagnostic_en.xml"
@@ -61,14 +95,6 @@
)
ZORBA_DIAGNOSTIC_GENERATOR(
- "${CMAKE_SOURCE_DIR}/src/diagnostics/dict_zed_keys_h.xq"
- "input=${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_en.xml"
- "diagnostic_en.xml"
- ""
- "${CMAKE_BINARY_DIR}/src/diagnostics/dict_zed_keys.h"
-)
-
-ZORBA_DIAGNOSTIC_GENERATOR(
"${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_list_xq.xq"
"input=${CMAKE_SOURCE_DIR}/src/diagnostics/diagnostic_en.xml;ns:=jerr"
"diagnostic_en.xml"
@@ -92,6 +118,8 @@
"${CMAKE_BINARY_DIR}/modules/zorba-warnings.xq"
)
+###############################################################################
+
SET( DIAG_MODULES
${CMAKE_BINARY_DIR}/modules/zorba-errors.xq
${CMAKE_BINARY_DIR}/modules/zorba-warnings.xq
@@ -100,11 +128,6 @@
)
ADD_CUSTOM_TARGET( gen_diag_modules DEPENDS ${DIAG_MODULES} )
-
SET_TARGET_PROPERTIES( gen_diag_modules PROPERTIES FOLDER "Modules" )
-IF (WIN32)
- SET( DIAGNOSTICS_SRCS ${DIAGNOSTICS_SRCS} StackWalker.cpp )
-ENDIF (WIN32)
-
# vim:set et sw=2 ts=2:
=== modified file 'src/diagnostics/diagnostic.cpp'
--- src/diagnostics/diagnostic.cpp 2013-06-04 00:34:52 +0000
+++ src/diagnostics/diagnostic.cpp 2013-09-14 00:51:56 +0000
@@ -140,10 +140,6 @@
location const location::empty;
-bool operator!=( location const &i, location const &j ) {
- return !(i == j);
-}
-
bool operator==( location const &i, location const &j ) {
return i.file_ == j.file_
&& i.line_ == j.line_
=== modified file 'src/diagnostics/diagnostic_list_cpp.xq'
--- src/diagnostics/diagnostic_list_cpp.xq 2013-06-25 00:41:44 +0000
+++ src/diagnostics/diagnostic_list_cpp.xq 2013-09-14 00:51:56 +0000
@@ -17,16 +17,17 @@
import module namespace util = "http://zorba.io/diagnostic/util"
at "diagnostic_util.xq";
+declare variable $diagnostics-input external;
+declare variable $namespaces-input external;
+
declare function local:declare-diagnostics( $doc ) as xs:string*
{
for $namespace in $doc/diagnostic-list/namespace
+ let $class-prefix := data( $namespaces-input//namespace[ @prefix = $namespace/@prefix ]/@class-prefix )
let $class :=
- switch ( data( $namespace/@prefix ) )
- case "err" return "XQueryErrorCode"
- case "jerr" return "JSONiqErrorCode"
- case "zerr" return "ZorbaErrorCode"
- case "zwarn" return "ZorbaWarningCode"
- default return error()
+ if ( empty( $class-prefix ) )
+ then error()
+ else concat( $class-prefix, "Code" )
return
string-join(
(
@@ -49,9 +50,6 @@
)
};
-
-declare variable $input external;
-
string-join(
( util:copyright(),
'',
@@ -60,7 +58,7 @@
'',
'namespace zorba {',
'',
- local:declare-diagnostics( $input ),
+ local:declare-diagnostics( $diagnostics-input ),
'',
'} // namespace zorba',
'/*',
=== modified file 'src/diagnostics/diagnostic_list_h.xq'
--- src/diagnostics/diagnostic_list_h.xq 2013-06-25 00:41:44 +0000
+++ src/diagnostics/diagnostic_list_h.xq 2013-09-14 00:51:56 +0000
@@ -17,6 +17,9 @@
import module namespace util = "http://zorba.io/diagnostic/util"
at "diagnostic_util.xq";
+declare variable $diagnostics-input external;
+declare variable $namespaces-input external;
+
declare function local:strip-ws( $comment ) as element(comment)
{
copy $copy := $comment
@@ -26,12 +29,11 @@
return $copy
};
-declare function local:reformat-line($line as xs:string) as xs:string
+declare function local:reformat-line( $line as xs:string ) as xs:string
{
concat( $util:newline, ' * ', substring($line, 7) )
};
-
declare function local:add-stars( $comment )
{
copy $copy := $comment
@@ -74,13 +76,11 @@
declare function local:declare-diagnostics( $doc ) as xs:string*
{
for $namespace in $doc/diagnostic-list/namespace
+ let $class-prefix := data( $namespaces-input//namespace[ @prefix = $namespace/@prefix ]/@class-prefix )
let $class :=
- switch ( data( $namespace/@prefix ) )
- case "err" return "XQueryErrorCode"
- case "jerr" return "JSONiqErrorCode"
- case "zerr" return "ZorbaErrorCode"
- case "zwarn" return "ZorbaWarningCode"
- default return error()
+ if ( empty( $class-prefix ) )
+ then error()
+ else concat( $class-prefix, "Code" )
return
string-join(
(
@@ -106,20 +106,16 @@
)
};
-
-declare variable $input external;
-
string-join(
( util:copyright(),
'#ifndef ZORBA_DIAGNOSTIC_LIST_API_H',
'#define ZORBA_DIAGNOSTIC_LIST_API_H',
'',
- '#include <zorba/config.h>',
- '#include <zorba/error.h>',
- '#include <zorba/xquery_warning.h>',
+ '#include <zorba/config.h>',
+ '#include <zorba/internal/qname.h>',
'',
'namespace zorba {',
- local:declare-diagnostics( $input ),
+ local:declare-diagnostics( $diagnostics-input ),
'} // namespace zorba',
'#endif /* ZORBA_DIAGNOSTIC_LIST_API_H */',
'/*',
=== added file 'src/diagnostics/diagnostic_namespaces.xml'
--- src/diagnostics/diagnostic_namespaces.xml 1970-01-01 00:00:00 +0000
+++ src/diagnostics/diagnostic_namespaces.xml 2013-09-14 00:51:56 +0000
@@ -0,0 +1,65 @@
+<!--
+ ! Copyright 2006-2013 The FLWOR Foundation.
+ !
+ ! Licensed under the Apache License, Version 2.0 (the "License");
+ ! you may not use this file except in compliance with the License.
+ ! You may obtain a copy of the License at
+ !
+ ! http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing, software
+ ! distributed under the License is distributed on an "AS IS" BASIS,
+ ! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ! See the License for the specific language governing permissions and
+ ! limitations under the License.
+ -->
+
+<!--
+ ! This file lists all the namespace URIs and prefixes used for errors and
+ ! warnings. The attributes are:
+ !
+ ! prefix:
+ ! The error namespace prefix, e.g., "err" (for standard XQuery errors).
+ !
+ ! uri:
+ ! The error namespace URI. It can be either a C++ identifier that refers
+ ! to constant or macro defined elsewhere, e.g., "XQUERY_ERR_NS" defined in
+ ! ns_consts.h or a string literal starting with "http:".
+ !
+ ! class-prefix:
+ ! The prefix for C++ class/type names used in code, e.g., "XQueryError" is
+ ! used to form the class names "XQueryErrorCode" and "XQueryErrorQName".
+ !
+ ! kind-function:
+ ! How the {class-prefix}QName::kind() member function is to be implemented;
+ ! one of: "override", "standard", or "unknown".
+ !
+ ! override:
+ ! You must supply the entire function definition in qname.cpp.
+ !
+ ! standard:
+ ! The function definition is generated automatically such that it returns
+ ! dynamic, static, and type error kinds based on the local name of the
+ ! error's QName.
+ !
+ ! unknown:
+ ! The function definition is generated automatically such that it returns
+ ! UNKNOWN_KIND.
+ !-->
+
+<diagnostic-namespaces>
+
+ <namespace prefix="err" uri="XQUERY_ERR_NS"
+ class-prefix="XQueryError" kind-function="override"/>
+
+ <namespace prefix="jerr" uri="JSONIQ_ERR_NS"
+ class-prefix="JSONiqError" kind-function="standard"/>
+
+ <namespace prefix="zerr" uri="ZORBA_ERR_NS"
+ class-prefix="ZorbaError" kind-function="unknown"/>
+
+ <namespace prefix="zwarn" uri="ZORBA_WARN_NS"
+ class-prefix="ZorbaWarning" kind-function="standard"/>
+
+</diagnostic-namespaces>
+<!-- vim:set et sw=2 ts=2: -->
=== added file 'src/diagnostics/pregenerated/qnames.cpp'
--- src/diagnostics/pregenerated/qnames.cpp 1970-01-01 00:00:00 +0000
+++ src/diagnostics/pregenerated/qnames.cpp 2013-09-14 00:51:56 +0000
@@ -0,0 +1,63 @@
+/**
+ * Copyright 2006-2013 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ /*
+ * THIS FILE IS GENERATED.
+ * PLEASE DO NOT EDIT.
+ */
+
+
+#include <zorba/diagnostic.h>
+#include "zorbamisc/ns_consts.h"
+
+namespace zorba {
+
+extern diagnostic::kind get_standard_error_kind( char const* );
+
+namespace internal {
+
+char const XQueryErrorQName::NAMESPACE[] = XQUERY_ERR_NS;
+char const XQueryErrorQName::PREFIX[] = "err";
+
+
+char const JSONiqErrorQName::NAMESPACE[] = JSONIQ_ERR_NS;
+char const JSONiqErrorQName::PREFIX[] = "jerr";
+
+zorba::diagnostic::kind JSONiqErrorQName::kind() const {
+ return get_standard_error_kind( localname() );
+}
+
+char const ZorbaErrorQName::NAMESPACE[] = ZORBA_ERR_NS;
+char const ZorbaErrorQName::PREFIX[] = "zerr";
+
+zorba::diagnostic::kind ZorbaErrorQName::kind() const {
+ return zorba::diagnostic::UNKNOWN_KIND;
+}
+
+char const ZorbaWarningQName::NAMESPACE[] = ZORBA_WARN_NS;
+char const ZorbaWarningQName::PREFIX[] = "zwarn";
+
+zorba::diagnostic::kind ZorbaWarningQName::kind() const {
+ return get_standard_error_kind( localname() );
+}
+
+} // namespace internal
+} // namespace zorba
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
=== modified file 'src/diagnostics/qname.cpp'
--- src/diagnostics/qname.cpp 2013-06-15 02:57:08 +0000
+++ src/diagnostics/qname.cpp 2013-09-14 00:51:56 +0000
@@ -15,84 +15,28 @@
*/
#include "stdafx.h"
+#include <cstring>
+
#include <zorba/internal/qname.h>
-#include "assert.h"
-#include "util/ascii_util.h"
-#include "zorbamisc/ns_consts.h"
+using namespace std;
namespace zorba {
+
+extern diagnostic::kind get_standard_error_kind( char const* );
+
namespace internal {
///////////////////////////////////////////////////////////////////////////////
-char const XQueryErrQName::NAMESPACE[] = XQUERY_ERR_NS;
-char const XQueryErrQName::PREFIX[] = "err";
-
-zorba::diagnostic::kind XQueryErrQName::kind() const {
+zorba::diagnostic::kind XQueryErrorQName::kind() const {
using namespace zorba::diagnostic;
char const *const name = localname();
- if ( ::strncmp( name + 2, "DY", 2 ) == 0 )
- return XQUERY_DYNAMIC;
- if ( ::strncmp( name + 2, "ST", 2 ) == 0 )
- return XQUERY_STATIC;
- if ( ::strncmp( name + 2, "TY", 2 ) == 0 )
- return XQUERY_TYPE;
if ( ::strncmp( name, "FO", 2 ) == 0 )
return XQUERY_DYNAMIC; // all F&O errors are dynamic
-
- return UNKNOWN_KIND;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-char const JSONiqErrQName::NAMESPACE[] = JSONIQ_ERR_NS;
-char const JSONiqErrQName::PREFIX[] = "jerr";
-
-zorba::diagnostic::kind JSONiqErrQName::kind() const {
- using namespace zorba::diagnostic;
-
- char const *const name = localname();
-
- if ( ::strncmp( name + 2, "DY", 2 ) == 0 )
- return XQUERY_DYNAMIC;
- if ( ::strncmp( name + 2, "ST", 2 ) == 0 )
- return XQUERY_STATIC;
- if ( ::strncmp( name + 2, "TY", 2 ) == 0 )
- return XQUERY_TYPE;
-
- return UNKNOWN_KIND;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-char const ZorbaErrQName::NAMESPACE[] = ZORBA_ERR_NS;
-char const ZorbaErrQName::PREFIX[] = "zerr";
-
-zorba::diagnostic::kind ZorbaErrQName::kind() const {
- return zorba::diagnostic::UNKNOWN_KIND;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-char const ZorbaWarningQName::NAMESPACE[] = ZORBA_WARN_NS;
-char const ZorbaWarningQName::PREFIX[] = "zwarn";
-
-zorba::diagnostic::kind ZorbaWarningQName::kind() const {
- using namespace zorba::diagnostic;
-
- char const *const name = localname();
-
- if ( ::strncmp( name + 2, "DY", 2 ) == 0 )
- return XQUERY_DYNAMIC;
- if ( ::strncmp( name + 2, "ST", 2 ) == 0 )
- return XQUERY_STATIC;
- if ( ::strncmp( name + 2, "TY", 2 ) == 0 )
- return XQUERY_TYPE;
-
- return UNKNOWN_KIND;
+ return get_standard_error_kind( name );
}
///////////////////////////////////////////////////////////////////////////////
=== modified file 'src/diagnostics/qname.h'
--- src/diagnostics/qname.h 2013-04-08 00:12:00 +0000
+++ src/diagnostics/qname.h 2013-09-14 00:51:56 +0000
@@ -24,6 +24,7 @@
namespace zorba {
namespace diagnostic {
+///////////////////////////////////////////////////////////////////////////////
template<class QNameType>
QNameType to_QName( store::Item_t const &qname ) {
@@ -34,6 +35,7 @@
);
}
+///////////////////////////////////////////////////////////////////////////////
} // namespace diagnostic
} // namespace zorba
=== added file 'src/diagnostics/qname_util.cpp'
--- src/diagnostics/qname_util.cpp 1970-01-01 00:00:00 +0000
+++ src/diagnostics/qname_util.cpp 2013-09-14 00:51:56 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "stdafx.h"
+
+#include <cstring>
+
+#include <zorba/diagnostic.h>
+
+using namespace std;
+
+namespace zorba {
+
+///////////////////////////////////////////////////////////////////////////////
+
+diagnostic::kind get_standard_error_kind( char const *localname ) {
+ using namespace zorba::diagnostic;
+
+ if ( ::strncmp( localname + 2, "DY", 2 ) == 0 )
+ return XQUERY_DYNAMIC;
+ if ( ::strncmp( localname + 2, "ST", 2 ) == 0 )
+ return XQUERY_STATIC;
+ if ( ::strncmp( localname + 2, "TY", 2 ) == 0 )
+ return XQUERY_TYPE;
+ return UNKNOWN_KIND;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+} // namespace zorba
+/* vim:set et sw=2 ts=2: */
=== added file 'src/diagnostics/qnames_cpp.xq'
--- src/diagnostics/qnames_cpp.xq 1970-01-01 00:00:00 +0000
+++ src/diagnostics/qnames_cpp.xq 2013-09-14 00:51:56 +0000
@@ -0,0 +1,84 @@
+(:
+ : Copyright 2006-2009 The FLWOR Foundation.
+ :
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+:)
+
+import module namespace util = "http://zorba.io/diagnostic/util"
+ at "diagnostic_util.xq";
+
+declare function local:declare-qname-classes( $doc ) as xs:string*
+{
+ for $namespace in $doc//namespace
+ let $class := concat( $namespace/@class-prefix, "QName" )
+ let $uri :=
+ if ( starts-with( $namespace/@uri, "http:" ) )
+ then concat( '"', $namespace/@uri, '"' )
+ else $namespace/@uri
+ let $kind-function :=
+ switch ( $namespace/@kind-function )
+ case "override" return ()
+ case "standard" return
+ (
+ concat( 'zorba::diagnostic::kind ', $class, '::kind() const {' ),
+ ' return get_standard_error_kind( localname() );',
+ '}'
+ )
+ case "unknown" return
+ (
+ concat( 'zorba::diagnostic::kind ', $class, '::kind() const {' ),
+ ' return zorba::diagnostic::UNKNOWN_KIND;',
+ '}'
+ )
+ default return error()
+ return
+ string-join(
+ (
+ concat( 'char const ', $class, '::NAMESPACE[] = ', $uri, ';' ),
+ concat( 'char const ', $class, '::PREFIX[] = "', $namespace/@prefix, '";' ),
+ '',
+ $kind-function,
+ ''
+ ),
+ $util:newline
+ )
+};
+
+declare variable $input external;
+
+string-join(
+ ( util:copyright(),
+ '',
+ '#include <zorba/diagnostic.h>',
+ '#include "zorbamisc/ns_consts.h"',
+ '',
+ 'namespace zorba {',
+ '',
+ 'extern diagnostic::kind get_standard_error_kind( char const* );',
+ '',
+ 'namespace internal {',
+ '',
+ local:declare-qname-classes( $input ),
+ '} // namespace internal',
+ '} // namespace zorba',
+ '/*',
+ ' * Local variables:',
+ ' * mode: c++',
+ ' * End:',
+ ' */'
+ ),
+ $util:newline
+),
+$util:newline
+
+(: vim:set syntax=xquery et sw=2 ts=2: :)
=== added file 'src/diagnostics/qnames_h.xq'
--- src/diagnostics/qnames_h.xq 1970-01-01 00:00:00 +0000
+++ src/diagnostics/qnames_h.xq 2013-09-14 00:51:56 +0000
@@ -0,0 +1,86 @@
+(:
+ : Copyright 2006-2009 The FLWOR Foundation.
+ :
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+:)
+
+import module namespace util = "http://zorba.io/diagnostic/util"
+ at "diagnostic_util.xq";
+
+declare function local:declare-qname-classes( $doc ) as xs:string*
+{
+ for $namespace in $doc//namespace
+ let $class := concat( $namespace/@class-prefix, "QName" )
+ return
+ string-join(
+ (
+ concat( 'class ZORBA_DLL_PUBLIC ', $class, ' :' ),
+ concat( ' public FixedQName<', $class, ',char const*>' ),
+ '{',
+ concat( ' typedef FixedQName<', $class, ',char const*> base_type;' ),
+ 'public:',
+ ' static char const NAMESPACE[];',
+ ' static char const PREFIX[];',
+ concat( ' ', $class, '( char const *localname ) : base_type( localname ) { }' ),
+ ' zorba::diagnostic::kind kind() const;',
+ '};',
+ ''
+ ),
+ $util:newline
+ )
+};
+
+declare function local:declare-error-code-types( $doc ) as xs:string*
+{
+ for $namespace in $doc//namespace
+ let $qname-class := concat( $namespace/@class-prefix, "QName" )
+ let $code-typedef := concat( $namespace/@class-prefix, "Code" )
+ return
+ string-join(
+ (
+ concat( 'typedef internal::SystemDiagnostic<internal::', $qname-class,
+ '> ', $code-typedef, ';' )
+ ),
+ $util:newline
+ )
+};
+
+declare variable $input external;
+
+string-join(
+ ( util:copyright(),
+ '',
+ '#ifndef ZORBA_INTERNAL_QNAMES_H',
+ '#define ZORBA_INTERNAL_QNAMES_H',
+ '',
+ 'namespace zorba {',
+ 'namespace internal {',
+ '',
+ local:declare-qname-classes( $input ),
+ '} // namespace internal',
+ '',
+ local:declare-error-code-types( $input ),
+ '',
+ '} // namespace zorba',
+ '#endif /* ZORBA_INTERNAL_QNAMES_H */',
+ '/*',
+ ' * Local variables:',
+ ' * mode: c++',
+ ' * End:',
+ ' */'
+ ),
+ $util:newline
+),
+$util:newline
+
+(: vim:set syntax=xquery et sw=2 ts=2: :)
Follow ups