Browse Source

HPCC-13134 Further update based on review

Signed-off-by: Anthony Fishbeck <anthony.fishbeck@lexisnexis.com>
Anthony Fishbeck 10 years ago
parent
commit
16b5df3702
3 changed files with 10 additions and 5 deletions
  1. 7 2
      ecl/hqlcpp/hqlhtcpp.cpp
  2. 1 1
      rtl/eclrtl/rtlfield.cpp
  3. 2 2
      rtl/include/eclhelper.hpp

+ 7 - 2
ecl/hqlcpp/hqlhtcpp.cpp

@@ -3487,6 +3487,11 @@ IHqlExpression * HqlCppTranslator::getRtlFieldKey(IHqlExpression * expr, IHqlExp
     return LINK(expr);
 }
 
+bool checkXpathIsNonScalar(const char *xpath)
+{
+    return (strpbrk(xpath, "/?*[]<>")!=NULL); //anything other than a single tag/attr name cannot name a scalar field
+}
+
 unsigned HqlCppTranslator::buildRtlField(StringBuffer * instanceName, IHqlExpression * fieldKey)
 {
     BuildCtx declarectx(*code, declareAtom);
@@ -3550,8 +3555,8 @@ unsigned HqlCppTranslator::buildRtlField(StringBuffer * instanceName, IHqlExpres
         {
             if (xpathName.charAt(0) == '@')
                 typeFlags |= RFTMhasxmlattr;
-            if (!strpbrk(xpathName, "/?*[]<>"))
-                typeFlags |= RFTMxpathscalar;
+            if (checkXpathIsNonScalar(xpathName))
+                typeFlags |= RFTMhasnonscalarxpath;
         }
 
         StringBuffer typeName;

+ 1 - 1
rtl/eclrtl/rtlfield.cpp

@@ -41,7 +41,7 @@ static const char * queryXPath(const RtlFieldInfo * field)
 
 static const char * queryScalarXPath(const RtlFieldInfo * field)
 {
-    if (field->type && !field->type->xpathIsScalar())
+    if (field->type->isValueNonScalarXpath())
         return field->name->str();
     return queryXPath(field);
 }

+ 2 - 2
rtl/include/eclhelper.hpp

@@ -326,7 +326,7 @@ enum RtlFieldTypeMask
 
     RFTMalien               = 0x00000800,                   // this is the physical format of a user defined type, if unknown size we can't calculate it
     RFTMcontainsifblock     = 0x00000800,                   // contains an if block - if set on a record then it contains ifblocks, so can't work out field offsets.
-    RFTMxpathscalar         = 0x00001000,                   // field xpath contains only one node, and is therefore usable for naming scalar fields
+    RFTMhasnonscalarxpath   = 0x00001000,                   // field xpath contains only one node, and is therefore usable for naming scalar fields
 
     RFTMcontainsunknown     = 0x10000000,                   // contains a field of unknown type that we can't process properly
     RFTMinvalidxml          = 0x20000000,                   // cannot be called to generate xml
@@ -364,7 +364,7 @@ struct RtlTypeInfo : public RtlITypeInfo
     inline bool isFixedSize() const { return (fieldType & RFTMunknownsize) == 0; }
     inline bool isLinkCounted() const { return (fieldType & RFTMlinkcounted) != 0; }
     inline bool isUnsigned() const { return (fieldType & RFTMunsigned) != 0; }
-    inline bool xpathIsScalar() const { return (fieldType & RFTMxpathscalar) != 0; }
+    inline bool isValueNonScalarXpath() const { return (fieldType & RFTMhasnonscalarxpath) != 0; }
     inline unsigned getDecimalDigits() const { return (length & 0xffff); }
     inline unsigned getDecimalPrecision() const { return (length >> 16); }
     inline unsigned getBitfieldIntSize() const { return (length & 0xff); }