Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/api-var-annot into lp:zorba

2014-05-06 Thread Paul J. Lucas
> Why not allow introspection for non external variables? Does it make sense to
> restrict it?

I personally don't care, but the function getExternalVariables() in 
StaticContext was already there and there is *not* any getAllVariables() (or 
some such).  Since you can't introspect just the names of non-external 
variables, I didn't see any point in allowing you to get the annotations for 
them.
-- 
https://code.launchpad.net/~zorba-coders/zorba/api-var-annot/+merge/218485
Your team Zorba Coders is subscribed to branch lp:zorba.

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


Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/api-var-annot into lp:zorba

2014-05-06 Thread Matthias Brantner
Review: Needs Information

Why not allow introspection for non external variables? Does it make sense to 
restrict it?
-- 
https://code.launchpad.net/~zorba-coders/zorba/api-var-annot/+merge/218485
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/api-var-annot into lp:zorba

2014-05-06 Thread Paul J. Lucas
The proposal to merge lp:~zorba-coders/zorba/api-var-annot into lp:zorba has 
been updated.

Status: Needs review => Approved

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/api-var-annot/+merge/218485
-- 
https://code.launchpad.net/~zorba-coders/zorba/api-var-annot/+merge/218485
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/api-var-annot into lp:zorba

2014-05-06 Thread Paul J. Lucas
Paul J. Lucas has proposed merging lp:~zorba-coders/zorba/api-var-annot into 
lp:zorba.

Commit message:
Added public introspection API for external variable annotations.

Requested reviews:
  Matthias Brantner (matthias-brantner)
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/api-var-annot/+merge/218485

Added public introspection API for external variable annotations.
-- 
https://code.launchpad.net/~zorba-coders/zorba/api-var-annot/+merge/218485
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/annotation.h'
--- include/zorba/annotation.h	2013-06-12 04:55:14 +
+++ include/zorba/annotation.h	2014-05-06 18:07:18 +
@@ -55,6 +55,9 @@
*/
   virtual Item
   getLiteral(unsigned int i) const = 0;
+
+protected:
+  Annotation() { }
 };
 
 } /* namespace zorba */

=== modified file 'include/zorba/static_context.h'
--- include/zorba/static_context.h	2013-09-16 09:08:27 +
+++ include/zorba/static_context.h	2014-05-06 18:07:18 +
@@ -651,6 +651,18 @@
   virtual void
 	getExternalVariables(Iterator_t& aVarsIter) const = 0;
 
+  /** \brief Gets the Annotations (if any) for the given external variable.
+   *
+   * @param var_name The QName of the variable.
+   * @param result The vector into which to put all of the variable's
+   * annotations.
+   * @return Returns \c true only if the given external variable exists and has
+   * at least one annotation.
+   */
+  virtual bool
+  getExternalVariableAnnotations( Item const &var_name,
+  std::vector &result ) const = 0;
+
   /**
* @brief Set the URI lookup path (list of filesystem directories) for this
* static context.

=== modified file 'src/annotations/annotations.h'
--- src/annotations/annotations.h	2014-04-16 18:23:55 +
+++ src/annotations/annotations.h	2014-05-06 18:07:18 +
@@ -189,6 +189,10 @@
 
   size_type size() const { return theAnnotationList.size(); }
 
+  void swap( AnnotationList &a ) {
+theAnnotationList.swap( a.theAnnotationList );
+  }
+
   AnnotationInternal* get(size_type index) const;
 
   AnnotationInternal* get(AnnotationInternal::AnnotationId id) const;

=== modified file 'src/api/staticcontextimpl.cpp'
--- src/api/staticcontextimpl.cpp	2013-12-14 00:44:26 +
+++ src/api/staticcontextimpl.cpp	2014-05-06 18:07:18 +
@@ -1797,12 +1797,30 @@
 extVars.push_back((*ite)->getName());
   }
 
-  Iterator_t vIter = new VectorIterator(extVars, theDiagnosticHandler);
-  aVarsIter = vIter; 
+  aVarsIter = new VectorIterator(extVars, theDiagnosticHandler);
   ZORBA_CATCH
 }
 
 
+bool StaticContextImpl::
+getExternalVariableAnnotations( Item const &api_qname,
+std::vector &result ) const {
+  store::Item const *const qname = Unmarshaller::getInternalItem( api_qname );
+  VarInfo const *const var_info = theCtx->lookup_var( qname );
+  if ( var_info && var_info->isExternal() ) {
+if ( var_expr const *const var_expr = var_info->getVar() ) {
+  AnnotationList const &annotation_list = var_expr->get_annotations();
+  AnnotationList::size_type const n = annotation_list.size();
+  result.clear();
+  for ( AnnotationList::size_type i = 0; i < n; ++i )
+result.push_back( new AnnotationImpl( annotation_list.get( i ) ) );
+  return !!n;
+}
+  }
+  return false;
+}
+
+
 Item
 StaticContextImpl::fetch(const String& aURI) const
 {

=== modified file 'src/api/staticcontextimpl.h'
--- src/api/staticcontextimpl.h	2013-09-26 09:38:51 +
+++ src/api/staticcontextimpl.h	2014-05-06 18:07:18 +
@@ -307,6 +307,10 @@
   virtual void
   getExternalVariables(Iterator_t& aVarsIter) const;  
 
+  virtual bool
+  getExternalVariableAnnotations( Item const&,
+  std::vector& ) const;
+
   virtual void
   setURIPath(const std::vector& aURIPath);
 

=== modified file 'src/compiler/expression/var_expr.h'
--- src/compiler/expression/var_expr.h	2013-09-12 07:54:03 +
+++ src/compiler/expression/var_expr.h	2014-05-06 18:07:18 +
@@ -17,6 +17,7 @@
 #ifndef ZORBA_COMPILER_VAR_EXPR
 #define ZORBA_COMPILER_VAR_EXPR
 
+#include "annotations/annotations.h"
 #include "compiler/expression/expr_base.h"
 
 namespace zorba
@@ -178,6 +179,8 @@
 
   VarInfo * theVarInfo;
 
+  AnnotationListtheAnnotations;
+
   csize theNumRefs;
 
   bool  theIsExternal;
@@ -207,6 +210,14 @@
 public:
   void set_var_info(VarInfo* v);
 
+  AnnotationList const& get_annotations() const {
+return theAnnotations;
+  }
+
+  void swap_annotations( AnnotationList &a ) {
+theAnnotations.swap( a );
+  }
+
   VarInfo* get_var_info() const { return theVarInfo; }
 
   ulong get_unique_id() const { return theUniqueId; }

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2014-04-16 18:23:55 +
+++ src/compiler/translator/translator.cpp	2014-05-

Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/api-var-annot into lp:zorba

2014-05-06 Thread Paul J. Lucas
Review: Approve


-- 
https://code.launchpad.net/~zorba-coders/zorba/api-var-annot/+merge/218485
Your team Zorba Coders is subscribed to branch lp:zorba.

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