Matthias Brantner has proposed merging lp:~matthias-brantner/zorba/bug-fixing 
into lp:zorba.

Requested reviews:
  Matthias Brantner (matthias-brantner)
  Markos Zaharioudakis (markos-za)
Related bugs:
  Bug #867133 in Zorba: "SWIG PHP build failure on Mac OSX"
  https://bugs.launchpad.net/zorba/+bug/867133

For more details, see:
https://code.launchpad.net/~matthias-brantner/zorba/bug-fixing/+merge/82561

- fixed DynamicLoader memory leak
- StaticContext::getAuditEvent const
- added iterator.h include to zorba.h
- fn:trace should not be constant folded and propagate the return type of its 
first argument
-- 
https://code.launchpad.net/~matthias-brantner/zorba/bug-fixing/+merge/82561
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2011-11-16 04:00:29 +0000
+++ ChangeLog	2011-11-17 16:49:37 +0000
@@ -29,6 +29,7 @@
     corruption will occur)
   * Fixed bug # (Should not destroy the parent of a node that is being detached
     before the detach is done).
+  * Added const qualifier to StaticContext::getAuditEvent() 
   * Fixed bug #3408181 (available-collection() returns undeclared collections)
   * Fixed bug #859465 (Fatal error if a PUL contains two deactivate IC primitives)
   * Fixed bug #859467 (Fatal error if a PUL contains two activate Foreign Key primitives)

=== modified file 'include/zorba/static_context.h'
--- include/zorba/static_context.h	2011-11-15 08:23:20 +0000
+++ include/zorba/static_context.h	2011-11-17 16:49:37 +0000
@@ -586,7 +586,7 @@
    * @return the audit event
    */
   virtual audit::Event*
-  getAuditEvent() = 0;
+  getAuditEvent() const = 0;
 
 
   /** \brief Returns the QName of all external variables within the

=== modified file 'include/zorba/zorba.h'
--- include/zorba/zorba.h	2011-06-17 03:47:29 +0000
+++ include/zorba/zorba.h	2011-11-17 16:49:37 +0000
@@ -33,6 +33,7 @@
 #include <zorba/collection_manager.h>
 #include <zorba/xquery.h>
 #include <zorba/zorba_string.h>
+#include <zorba/iterator.h>
 
 namespace zorba {
 

=== modified file 'src/api/staticcontextimpl.cpp'
--- src/api/staticcontextimpl.cpp	2011-11-15 08:23:20 +0000
+++ src/api/staticcontextimpl.cpp	2011-11-17 16:49:37 +0000
@@ -1424,7 +1424,7 @@
 
 
 audit::Event*
-StaticContextImpl::getAuditEvent()
+StaticContextImpl::getAuditEvent() const
 {
   return theCtx->get_audit_event();
 }

=== modified file 'src/api/staticcontextimpl.h'
--- src/api/staticcontextimpl.h	2011-11-15 08:23:20 +0000
+++ src/api/staticcontextimpl.h	2011-11-17 16:49:37 +0000
@@ -246,7 +246,7 @@
   setAuditEvent(audit::Event* anEvent);
   
   virtual audit::Event*
-  getAuditEvent();
+  getAuditEvent() const;
 
   virtual void
   getExternalVariables(Iterator_t& aVarsIter) const;  

=== modified file 'src/context/dynamic_loader.cpp'
--- src/context/dynamic_loader.cpp	2011-10-19 16:19:45 +0000
+++ src/context/dynamic_loader.cpp	2011-11-17 16:49:37 +0000
@@ -191,14 +191,6 @@
 }
 
 
-DynamicLoader&
-DynamicLoader::getInstance()
-{
-  static DynamicLoader singleton;
-  return singleton;
-}
-
-
 DynamicLoader::~DynamicLoader()
 {
   for (LibrarySet_t::const_iterator lIter = theLibraries.begin();
@@ -265,7 +257,7 @@
 
       if (modfile->good())
       {
-        ExternalModule* lModule = getInstance().loadModule(potentialModuleFile);
+        ExternalModule* lModule = loadModule(potentialModuleFile);
         if (lModule)
         {
           if (lModule->getURI().c_str() != aNsURI)

=== modified file 'src/context/dynamic_loader.h'
--- src/context/dynamic_loader.h	2011-08-08 13:51:27 +0000
+++ src/context/dynamic_loader.h	2011-11-17 16:49:37 +0000
@@ -29,18 +29,17 @@
 class DynamicLoader
 {
 public:
-  static ExternalModule* getExternalModule(
+  ExternalModule* getExternalModule(
       zstring const& aNsURI,
       static_context& aSctx);
 
 private:
 
+  friend class GlobalEnvironment;
   DynamicLoader();
 
   ~DynamicLoader();
 
-  static DynamicLoader& getInstance();
-
   ExternalModule* loadModule(const zstring& aFile) const;
 
 #ifdef WIN32

=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp	2011-11-15 08:23:20 +0000
+++ src/context/static_context.cpp	2011-11-17 16:49:37 +0000
@@ -207,7 +207,7 @@
     if (dyn_loaded_module)
     {
       ZORBA_ASSERT(sctx);
-      module = DynamicLoader::getExternalModule(lURI, *sctx);
+      module = GENV_DYNAMIC_LOADER->getExternalModule(lURI, *sctx);
 
       // no way to get the module
       if (!module)
@@ -2634,7 +2634,7 @@
   // dynamic loader
   if (!found)
   {
-    lModule = DynamicLoader::getExternalModule(aURI, *this);
+    lModule = GENV_DYNAMIC_LOADER->getExternalModule(aURI, *this);
 
     // no way to get the module
     if (!lModule)
@@ -3400,7 +3400,7 @@
 /***************************************************************************//**
 
 ********************************************************************************/
-audit::Event* static_context::get_audit_event()
+audit::Event* static_context::get_audit_event() const
 {
   const static_context* sctx = this;
   audit::Event* res = sctx->theAuditEvent;

=== modified file 'src/context/static_context.h'
--- src/context/static_context.h	2011-11-15 08:23:20 +0000
+++ src/context/static_context.h	2011-11-17 16:49:37 +0000
@@ -917,7 +917,7 @@
   //
   void set_audit_event(audit::Event* ae);
 
-  audit::Event* get_audit_event();
+  audit::Event* get_audit_event() const;
 
 
   //

=== modified file 'src/functions/func_errors_and_diagnostics_impl.cpp'
--- src/functions/func_errors_and_diagnostics_impl.cpp	2011-07-12 23:32:16 +0000
+++ src/functions/func_errors_and_diagnostics_impl.cpp	2011-11-17 16:49:37 +0000
@@ -65,5 +65,15 @@
   }
 }
 
+/*******************************************************************************
+
+********************************************************************************/
+xqtref_t fn_trace::getReturnType(
+    const TypeManager* tm,
+    const std::vector<xqtref_t>& argTypes) const
+{
+  return argTypes[0];
+}
+
 } // namespace zorba
 /* vim:set et sw=2 ts=2: */

=== modified file 'src/functions/pregenerated/func_errors_and_diagnostics.h'
--- src/functions/pregenerated/func_errors_and_diagnostics.h	2011-11-09 05:42:08 +0000
+++ src/functions/pregenerated/func_errors_and_diagnostics.h	2011-11-17 16:49:37 +0000
@@ -72,6 +72,12 @@
 
   BoolAnnotationValue ignoresDuplicateNodes(expr* fo, ulong producer) const;
 
+  bool accessesDynCtx() const { return true; }
+
+  xqtref_t getReturnType(
+        const TypeManager* tm,
+        const std::vector<xqtref_t>& arg_types) const;
+
   CODEGEN_DECL();
 };
 

=== modified file 'src/runtime/spec/errors_and_diagnostics/errors_and_diagnostics.xml'
--- src/runtime/spec/errors_and_diagnostics/errors_and_diagnostics.xml	2011-04-13 19:33:42 +0000
+++ src/runtime/spec/errors_and_diagnostics/errors_and_diagnostics.xml	2011-11-17 16:49:37 +0000
@@ -77,6 +77,8 @@
         <zorba:propagatesSortedNodes producer="0"/>
         <zorba:ignoresSortedNodes/>
         <zorba:ignoresDuplicateNodes/>
+        <zorba:accessesDynCtx returnValue="true"/>
+        <zorba:getReturnType/>
       </zorba:methods>
 
     </zorba:function>

=== modified file 'src/system/globalenv.cpp'
--- src/system/globalenv.cpp	2011-11-02 06:14:25 +0000
+++ src/system/globalenv.cpp	2011-11-17 16:49:37 +0000
@@ -34,6 +34,7 @@
 #include "types/schema/schema.h"
 #include "context/root_static_context.h"
 #include "context/default_url_resolvers.h"
+#include "context/dynamic_loader.h"
 #include "functions/library.h"
 #include "annotations/annotations.h"
 #include "compiler/api/compiler_api.h"
@@ -98,6 +99,8 @@
   m_globalEnv->m_compilerSubSys = lSubSystem.release();
 
   m_globalEnv->m_http_resolver = new internal::HTTPURLResolver();
+
+  m_globalEnv->m_dynamic_loader = 0;
 }
 
 
@@ -105,6 +108,8 @@
 // note: destruction must be done in reverse initialization order
 void GlobalEnvironment::destroy()
 {
+  delete m_globalEnv->m_dynamic_loader;
+
   delete m_globalEnv->m_http_resolver;
 
   serialization::ClassSerializer::getInstance()->destroyArchiverForHardcodedObjects();
@@ -273,6 +278,15 @@
   return *m_compilerSubSys;
 }
 
+DynamicLoader* GlobalEnvironment::getDynamicLoader() const
+{
+  if (!m_dynamic_loader)
+  {
+    m_dynamic_loader = new DynamicLoader();
+  }
+  return m_dynamic_loader;
+}
+
 #ifdef ZORBA_XQUERYX
 XQueryXConvertor    *GlobalEnvironment::getXQueryXConvertor()
 {

=== modified file 'src/system/globalenv.h'
--- src/system/globalenv.h	2011-10-21 03:05:49 +0000
+++ src/system/globalenv.h	2011-11-17 16:49:37 +0000
@@ -27,6 +27,7 @@
 class RootTypeManager;
 class root_static_context;
 class XQueryXConvertor;
+class DynamicLoader;
 
 namespace internal {
 class HTTPURLResolver;
@@ -67,6 +68,8 @@
   internal::ThesaurusURLResolver  * m_thesaurus_resolver;
 #endif /* ZORBA_NO_FULL_TEXT */
 
+  mutable DynamicLoader  * m_dynamic_loader;
+
 public:
 
   static void init(store::Store* store);
@@ -108,6 +111,8 @@
   internal::ThesaurusURLResolver* getThesaurusURLResolver() const { return m_thesaurus_resolver; }
 #endif /* ZORBA_NO_FULL_TEXT */
 
+  DynamicLoader* getDynamicLoader() const;
+
 #ifdef ZORBA_XQUERYX
   XQueryXConvertor* getXQueryXConvertor();
 #endif
@@ -135,6 +140,8 @@
 
 #define GENV_ROOT_STATIC_CONTEXT GlobalEnvironment::getInstance().getRootStaticContext()
 
+#define GENV_DYNAMIC_LOADER GlobalEnvironment::getInstance().getDynamicLoader()
+
 }
 
 #endif /* ZORBA_GLOBALENV_H */

=== added directory 'test/rbkt/ExpCompilerResults/IterPlan/zorba/error'
=== added file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/error/trace1.iter'
--- test/rbkt/ExpCompilerResults/IterPlan/zorba/error/trace1.iter	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpCompilerResults/IterPlan/zorba/error/trace1.iter	2011-11-17 16:49:37 +0000
@@ -0,0 +1,8 @@
+Iterator tree for main query:
+<FunctionTraceIterator>
+  <TraceIterator>
+    <SingletonIterator value="xs:integer(3)"/>
+    <SingletonIterator value="xs:string(foo)"/>
+  </TraceIterator>
+</FunctionTraceIterator>
+

=== added file 'test/rbkt/ExpQueryResults/zorba/error/trace1.xml.res'
--- test/rbkt/ExpQueryResults/zorba/error/trace1.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/error/trace1.xml.res	2011-11-17 16:49:37 +0000
@@ -0,0 +1,1 @@
+3

=== added file 'test/rbkt/Queries/zorba/error/trace1.xq'
--- test/rbkt/Queries/zorba/error/trace1.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/error/trace1.xq	2011-11-17 16:49:37 +0000
@@ -0,0 +1,6 @@
+declare function local:foo() as xs:anyAtomicType
+{
+  fn:trace(3, "foo")
+};
+
+local:foo()

-- 
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