Rodolfo Ochoa has proposed merging lp:~zorba-coders/zorba/bug867112 into 
lp:zorba.

Requested reviews:
  Cezar Andrei (cezar-andrei)
  Matthias Brantner (matthias-brantner)
Related bugs:
  Bug #867112 in Zorba: "Diagnostic Handler not working in API Bindings"
  https://bugs.launchpad.net/zorba/+bug/867112

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug867112/+merge/102429

Diagnostic Handler is now working with other languages API, also the 
SWIG-Director functionality is active.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug867112/+merge/102429
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-04-17 16:21:12 +0000
+++ ChangeLog	2012-04-18 03:50:24 +0000
@@ -25,6 +25,7 @@
   * Fixed bug #921458 (file:read-text-lines() blocking)
   * Fixed bug #980526 (no-copy rule bug due to global var being set in "distant" udf)
   * Fixed bug #949910 (has-children may be invoked on all nodes). Internally, zorba::store::Item::getChildren() now returns NULL on node classes without offspring (instead of raising an error).
+  * Fixed bug #867112 (Diagnostic Handler was not working on API with other languages than C++
 
 
 version 2.2

=== modified file 'swig/DiagnosticHandler.i'
--- swig/DiagnosticHandler.i	2012-04-16 20:56:43 +0000
+++ swig/DiagnosticHandler.i	2012-04-18 03:50:24 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006-2008 The FLWOR Foundation.
+ * Copyright 2006-2012 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.
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+%feature("director") DiagnosticHandler;
 
 %{   // start Implementations
 
@@ -21,7 +22,7 @@
 {
  private:
   void error (const zorba::ZorbaException &ze) 
-  { 
+  {
     if ( zorba::XQueryException const *xe = dynamic_cast<zorba::XQueryException const*>( &ze ) ) {
       const XQueryException xe2(xe);
       error(xe2); 
@@ -38,7 +39,8 @@
 
  public:
   virtual ~DiagnosticHandler() {}
-  virtual void error(const ZorbaException &ze) {}
+  virtual void error(const ZorbaException &ze) {
+  }
   //virtual void warning(const XQueryWarning &xw) {}
  }; // class DiagnosticHandler
 

=== modified file 'swig/Exceptions.i'
--- swig/Exceptions.i	2012-04-16 20:56:43 +0000
+++ swig/Exceptions.i	2012-04-18 03:50:24 +0000
@@ -30,7 +30,7 @@
   ZorbaException(const zorba::ZorbaException *en)
   { theException = en; } 
 
-  //friend class DiagnosticHandler;
+  friend class DiagnosticHandler;
  public:
   virtual std::string getDescription() const 
   { return std::string(theException->what()); }
@@ -58,7 +58,7 @@
   XQueryException() {}
   XQueryException(const zorba::XQueryException *qe) : ZorbaException(qe) {}
 
-  //friend class DiagnosticHandler;
+  friend class DiagnosticHandler;
  private:
   const zorba::XQueryException* getQEx() const
   { return dynamic_cast<const zorba::XQueryException*>(theException); }
@@ -73,7 +73,7 @@
 
 class UserException : public XQueryException 
 {
-  //friend class DiagnosticHandler;
+  friend class DiagnosticHandler;
 
  protected:
   UserException (const zorba::UserException *se) : 

=== added file 'swig/Zorba.h'
--- swig/Zorba.h	1970-01-01 00:00:00 +0000
+++ swig/Zorba.h	2012-04-18 03:50:24 +0000
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006-2012 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.
+ */
+#ifndef API_ZORBA_H
+#define API_ZORBA_H
+
+class Zorba 
+{
+ private:
+  zorba::Zorba* theZorba;
+  Zorba(zorba::Zorba* aZorba) : theZorba(aZorba){};
+ public:
+  Zorba():theZorba(0){}
+  Zorba(const Zorba& aZorba) : theZorba(aZorba.theZorba) {};
+  
+  static Zorba getInstance(const Store&);
+  StaticContext createStaticContext();
+  XQuery createQuery();
+  XQuery compileQuery(const std::string& aStr);
+  XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext );
+  //XQuery compileQuery(const ZIStreamHelper& aZorbaStream);
+  //XQuery compileQuery(const ZIStreamHelper& aZorbaStream, StaticContext &aStaticContext );
+  ItemFactory getItemFactory();
+  XQuery compileQuery(const std::string& aStr, DiagnosticHandler* aDiagnosticHandler);
+  XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext, 
+                      DiagnosticHandler* aDiagnosticHandler);
+  XQuery compileQuery(const std::string& aStr, CompilerHints &aCompilerHints, 
+                      DiagnosticHandler* aDiagnosticHandler);
+  XmlDataManager getXmlDataManager();
+  void shutdown();
+  std::string getVersion();
+  int getMajorVersion();
+  int getMinorVersion();
+  int getPatchVersion();
+
+}; // class Zorba
+
+#endif

=== modified file 'swig/Zorba.i'
--- swig/Zorba.i	2012-04-16 20:56:43 +0000
+++ swig/Zorba.i	2012-04-18 03:50:24 +0000
@@ -1,41 +1,47 @@
+/*
+ * Copyright 2006-2012 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.
+ */
 
 %{  // start Implementation
 
-class Zorba 
-{
-private:
-  zorba::Zorba* theZorba;
-  Zorba(zorba::Zorba* aZorba) : theZorba(aZorba) {}
-
-public:
-  Zorba():theZorba(0){}
-  Zorba(const Zorba& aZorba) : theZorba(aZorba.theZorba) {}
-  
-  static Zorba getInstance(const Store& aStore)
+  Zorba Zorba::getInstance(const Store& aStore)
   {
     return Zorba(zorba::Zorba::getInstance(aStore.getStore()));
   }
-  ItemFactory getItemFactory()
+  
+  ItemFactory Zorba::getItemFactory()
   {
     return ItemFactory(theZorba->getItemFactory());
   }
   
-  StaticContext createStaticContext()
+  StaticContext Zorba::createStaticContext()
   {
     return StaticContext(theZorba->createStaticContext());
   }
   
-  XQuery createQuery() 
+  XQuery Zorba::createQuery() 
   {
     return XQuery(theZorba->createQuery());
   }
 
-  XQuery compileQuery(const std::string& aStr) 
+  XQuery Zorba::compileQuery(const std::string& aStr) 
   {
     return XQuery(theZorba->compileQuery(aStr));
   }
 
-  XQuery compileQuery(
+  XQuery Zorba::compileQuery(
     const std::string& aStr,
     StaticContext &aStaticContext )
   { 
@@ -47,7 +53,7 @@
     );
   }
 /*
-  XQuery compileQuery(const ZIStreamHelper& aZorbaStream)
+  XQuery Zorba::compileQuery(const ZIStreamHelper& aZorbaStream)
   {
     zorbabuffer *buffer = new zorbabuffer(&const_cast<ZIStreamHelper &> (aZorbaStream));
     std::istream stream = std::istream(buffer);
@@ -55,7 +61,7 @@
     return XQuery(theZorba->compileQuery(stream));
   }
 
-  XQuery compileQuery(const ZIStreamHelper& aZorbaStream, StaticContext &aStaticContext )
+  XQuery Zorba::compileQuery(const ZIStreamHelper& aZorbaStream, StaticContext &aStaticContext )
   { 
     zorbabuffer *buffer = new zorbabuffer(&const_cast<ZIStreamHelper &> (aZorbaStream));
     std::istream stream = std::istream(buffer);
@@ -63,16 +69,14 @@
   }
 */
 
-  /*
-  //--->> DiagnosticHandler implementations are postponed
-  XQuery compileQuery(
+  XQuery Zorba::compileQuery(
     const std::string& aStr,
     DiagnosticHandler* aDiagnosticHandler
   )
   {
     return XQuery(theZorba->compileQuery(aStr, aDiagnosticHandler));
   }
-  XQuery compileQuery(
+  XQuery Zorba::compileQuery(
     const std::string& aStr,
     StaticContext &aStaticContext, 
     DiagnosticHandler* aDiagnosticHandler)
@@ -86,7 +90,7 @@
     );
   }
 
-  XQuery compileQuery(
+  XQuery Zorba::compileQuery(
     const std::string& aStr,
     CompilerHints& aCompilerHints,
     DiagnosticHandler* aDiagnosticHandler)
@@ -99,60 +103,29 @@
       )
     );
   }
-*/
 
-  XmlDataManager getXmlDataManager()
+  XmlDataManager Zorba::getXmlDataManager()
   {
     return XmlDataManager(theZorba->getXmlDataManager());
   }
 
-  void shutdown() 
+  void Zorba::shutdown() 
   {
     theZorba->shutdown();
   }
-  std::string getVersion() {
+  std::string Zorba::getVersion() {
     return zorba::Zorba::version().getVersion();
   }
-  int getMajorVersion() {
+  int Zorba::getMajorVersion() {
     return zorba::Zorba::version().getMajorVersion();
   }
-  int getMinorVersion() {
+  int Zorba::getMinorVersion() {
     return zorba::Zorba::version().getMinorVersion();
   }
-  int getPatchVersion() {
+  int Zorba::getPatchVersion() {
     return zorba::Zorba::version().getPatchVersion();
   }
 
-}; // class Zorba
-
-
 %}  // end Implementation
 
-// Interface
-
-class Zorba 
-{
- public:
-  static Zorba getInstance(const Store&);
-  StaticContext createStaticContext();
-  XQuery createQuery();
-  XQuery compileQuery(const std::string& aStr);
-  XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext );
-  //XQuery compileQuery(const ZIStreamHelper& aZorbaStream);
-  //XQuery compileQuery(const ZIStreamHelper& aZorbaStream, StaticContext &aStaticContext );
-  ItemFactory getItemFactory();
-  /*
-  XQuery compileQuery(const std::string& aStr, DiagnosticHandler* aDiagnosticHandler);
-  XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext, 
-                      DiagnosticHandler* aDiagnosticHandler);
-  XQuery compileQuery(const std::string& aStr, CompilerHints &aCompilerHints, 
-                      DiagnosticHandler* aDiagnosticHandler);
-  */
-  XmlDataManager getXmlDataManager();
-  void shutdown();
-  std::string getVersion();
-  int getMajorVersion();
-  int getMinorVersion();
-  int getPatchVersion();
-
-}; // class Zorba
+%include "Zorba.h"

=== modified file 'swig/java/CMakeLists.txt'
--- swig/java/CMakeLists.txt	2012-04-16 20:56:43 +0000
+++ swig/java/CMakeLists.txt	2012-04-18 03:50:24 +0000
@@ -73,6 +73,7 @@
   CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY)
   CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY)
   CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY)
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Zorba.h" "${CMAKE_CURRENT_BINARY_DIR}/Zorba.h" COPYONLY)
 #  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZInputStream.java"   "${CMAKE_CURRENT_BINARY_DIR}/ZInputStream.java" COPYONLY)
 #  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/zistream.java"       "${CMAKE_CURRENT_BINARY_DIR}/zistream.java" COPYONLY)
 

=== modified file 'swig/php/CMakeLists.txt'
--- swig/php/CMakeLists.txt	2012-04-16 20:56:43 +0000
+++ swig/php/CMakeLists.txt	2012-04-18 03:50:24 +0000
@@ -60,6 +60,7 @@
   CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY)
   CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY)
   CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY)
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Zorba.h" "${CMAKE_CURRENT_BINARY_DIR}/Zorba.h" COPYONLY)
 
   # The following fix was added because of the changes in CMake 2.8, which have the
   # result of naming the java binding library "liblibzorba_api.so" instead of "libzorba_api.so"

=== modified file 'swig/php/zorba_api.i'
--- swig/php/zorba_api.i	2012-04-16 20:56:43 +0000
+++ swig/php/zorba_api.i	2012-04-18 03:50:24 +0000
@@ -17,11 +17,18 @@
 #include <iostream>
 
 #if defined(_MSC_VER)
+
 #define PHP_COMPILER_ID "VC9"
 #define strtoll _strtoi64
 #define strtoull _strtoui64
+
+#ifdef ZTS
+#include "zend.h"
+TSRMLS_FETCH();
 #endif
 
+#endif  //_MSC_VER
+
 %}
 
 

=== modified file 'swig/python/CMakeLists.txt'
--- swig/python/CMakeLists.txt	2012-04-16 20:56:43 +0000
+++ swig/python/CMakeLists.txt	2012-04-18 03:50:24 +0000
@@ -47,6 +47,7 @@
   CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY)
   CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY)
   CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY)
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Zorba.h" "${CMAKE_CURRENT_BINARY_DIR}/Zorba.h" COPYONLY)
 
   MESSAGE (STATUS "SWIG Python: Python module install path: " ${PYTHON_INSTALL_PATH})
 

=== modified file 'swig/python/tests/CMakeLists.txt'
--- swig/python/tests/CMakeLists.txt	2012-04-16 20:56:43 +0000
+++ swig/python/tests/CMakeLists.txt	2012-04-18 03:50:24 +0000
@@ -26,9 +26,9 @@
 ADD_TEST("python_test02" ${PYTHON_EXECUTABLE} test02.py)
 SET_TESTS_PROPERTIES("python_test02" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
 
-#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test03.py.in ${CMAKE_CURRENT_BINARY_DIR}/test03.py)
-#ADD_TEST("python_test03" ${PYTHON_EXECUTABLE} test03.py)
-#SET_TESTS_PROPERTIES("python_test03" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test03.py.in ${CMAKE_CURRENT_BINARY_DIR}/test03.py)
+ADD_TEST("python_test03" ${PYTHON_EXECUTABLE} test03.py)
+SET_TESTS_PROPERTIES("python_test03" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
 
 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test04.py.in ${CMAKE_CURRENT_BINARY_DIR}/test04.py)
 ADD_TEST("python_test04" ${PYTHON_EXECUTABLE} test04.py)

=== modified file 'swig/python/tests/test03.py.in'
--- swig/python/tests/test03.py.in	2012-04-16 20:56:43 +0000
+++ swig/python/tests/test03.py.in	2012-04-18 03:50:24 +0000
@@ -23,6 +23,7 @@
 def test(zorba):
   diagnosticHandler = MyDiagnosticHandler()
   try:
+    print "Compiling 1 div 0"
     xquery = zorba.compileQuery("1 div 0", diagnosticHandler)
     print xquery.execute()
   except Exception, e:

=== modified file 'swig/ruby/CMakeLists.txt'
--- swig/ruby/CMakeLists.txt	2012-04-16 20:56:43 +0000
+++ swig/ruby/CMakeLists.txt	2012-04-18 03:50:24 +0000
@@ -64,6 +64,7 @@
   CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY)
   CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY)
   CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY)
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Zorba.h" "${CMAKE_CURRENT_BINARY_DIR}/Zorba.h" COPYONLY)
 
   SET (RUBY_SITEARCH_DIR "${CMAKE_INSTALL_PREFIX}/share/ruby")
   

=== modified file 'swig/zorba_api.i'
--- swig/zorba_api.i	2012-04-16 20:56:43 +0000
+++ swig/zorba_api.i	2012-04-18 03:50:24 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006-2008 The FLWOR Foundation.
+ * Copyright 2006-2012 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.
@@ -15,6 +15,11 @@
  */
 
 %module zorba_api
+%module(directors="1") zorba_api
+
+
+TSRMLS_FETCH(); 
+
 %include "std_string.i"
 %include "std_pair.i"
 %include "exception.i"
@@ -61,7 +66,7 @@
 #include <zorba/serializer.h>
 
   class CompilerHints;
-  //class DiagnosticHandler;
+  class DiagnosticHandler;
   class Store;
   class Zorba;
   class Iterator;
@@ -75,6 +80,7 @@
   class TypeException;
   class UserException;
   class ZorbaException;
+  class XmlDataManager;
 
   #include "SerializationOptions.h"
   #include "TypeIdentifier.h"
@@ -83,6 +89,7 @@
   #include "DynamicContext.h"
   #include "StaticContext.h"
   #include "XQuery.h"
+  #include "Zorba.h"
   #include "ItemFactory.h"
   #include "ItemSequence.h"
   #include "Collection.h"
@@ -108,7 +115,7 @@
 %include "XQuery.i"
 %include "Store.i"
 %include "Exceptions.i"
-//%include "DiagnosticHandler.i"
+%include "DiagnosticHandler.i"
 %include "Zorba.i"
 %include "ItemFactory.i"
 %include "ItemSequence.i"
@@ -116,4 +123,3 @@
 %include "CollectionManager.i"
 %include "DocumentManager.i"
 %include "XmlDataManager.i"
-

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to