Pārlūkot izejas kodu

HPCC-19662 PassParameterMeta does not work with C++ Embeds

- Modified ECLCC to check for PassParameterMeta on C++ Embeds

Signed-off-by: James McMullan <james.mcmullan@lexisnexis.com>
James McMullan 7 gadi atpakaļ
vecāks
revīzija
65b2ac98ee
5 mainītis faili ar 32 papildinājumiem un 5 dzēšanām
  1. 17 1
      ecl/hql/hqlexpr.cpp
  2. 2 0
      ecl/hql/hqlexpr.hpp
  3. 7 1
      ecl/hql/hqlutil.cpp
  4. 4 2
      ecl/hqlcpp/hqlcpp.cpp
  5. 2 1
      ecl/hqlcpp/hqlwcpp.cpp

+ 17 - 1
ecl/hql/hqlexpr.cpp

@@ -8437,6 +8437,18 @@ bool functionBodyUsesContext(IHqlExpression * body)
     }
 }
 
+IHqlExpression* getFunctionBodyAttribute(IHqlExpression* body, IAtom* atom) 
+{
+    switch (body->getOperator())
+    {
+    case no_outofline:
+    case no_funcdef:
+        return getFunctionBodyAttribute(body->queryChild(0),atom);
+    default:
+        return body->queryAttribute(atom);
+    }
+}
+
 bool functionBodyIsActivity(IHqlExpression * body)
 {
     switch (body->getOperator())
@@ -13046,6 +13058,10 @@ IHqlExpression * createExternalFuncdefFromInternal(IHqlExpression * funcdef)
         attrs.append(*LINK(cachedContextAttribute));
     if (functionBodyIsActivity(body))
         attrs.append(*createAttribute(activityAtom));
+    
+    IHqlExpression* passParamAttr = getFunctionBodyAttribute(body, passParameterMetaAtom);
+    if (passParamAttr != NULL && getBoolAttributeValue(passParamAttr))
+        attrs.append(*createAttribute(passParameterMetaAtom));
 
     IHqlExpression *child = body->queryChild(0);
     if (child && child->getOperator()==no_embedbody)
@@ -16717,7 +16733,7 @@ bool isKeyedCountAggregate(IHqlExpression * aggregate)
 }
 
 
-static bool getBoolAttributeValue(IHqlExpression * attr)
+bool getBoolAttributeValue(IHqlExpression * attr)
 {
     IHqlExpression * value = attr->queryChild(0);
     //No argument implies true

+ 2 - 0
ecl/hql/hqlexpr.hpp

@@ -1915,6 +1915,7 @@ inline int boolToInt(bool x)                    { return x ? 1 : 0; }
 extern HQL_API IHqlExpression * createFunctionDefinition(IIdAtom * name, IHqlExpression * value, IHqlExpression * parms, IHqlExpression * defaults, IHqlExpression * attrs);
 extern HQL_API IHqlExpression * createFunctionDefinition(IIdAtom * name, HqlExprArray & args);
 extern HQL_API IHqlExpression * queryNonDelayedBaseAttribute(IHqlExpression * expr);
+extern HQL_API IHqlExpression * getFunctionBodyAttribute(IHqlExpression* body, IAtom* atom);
 extern HQL_API bool functionBodyUsesContext(IHqlExpression * body);
 extern HQL_API bool functionBodyIsActivity(IHqlExpression * body);
 extern HQL_API bool functionCallIsActivity(IHqlExpression * call);
@@ -1967,6 +1968,7 @@ extern HQL_API void ensureSymbolsDefined(IHqlExpression * scope, HqlLookupContex
 extern HQL_API void ensureSymbolsDefined(IHqlScope * scope, HqlLookupContext & ctx);
 extern HQL_API IHqlExpression * queryBoolExpr(bool value);
 extern HQL_API IHqlExpression * queryBoolAttribute(IHqlExpression * expr, IAtom * name);    // true expr, false expr or NULL
+extern HQL_API bool getBoolAttributeValue(IHqlExpression * attr);
 extern HQL_API bool getBoolAttribute(IHqlExpression * expr, IAtom * name, bool dft=false);
 extern HQL_API bool getBoolAttributeInList(IHqlExpression * expr, IAtom * name, bool dft);
 

+ 7 - 1
ecl/hql/hqlutil.cpp

@@ -7911,7 +7911,13 @@ public:
 
         if (formals->numChildren())
         {
-            bool hasMeta = getBoolAttribute(body, passParameterMetaAtom, false);
+            bool hasMeta = false;
+            IHqlExpression* passParamAttr = getFunctionBodyAttribute(body, passParameterMetaAtom);
+            if (passParamAttr != NULL)
+            {
+                hasMeta = getBoolAttributeValue(passParamAttr);
+            }
+
             ForEachChild(i, formals)
             {
                 IHqlExpression * param = formals->queryChild(i);

+ 4 - 2
ecl/hqlcpp/hqlcpp.cpp

@@ -6163,7 +6163,8 @@ void HqlCppTranslator::doBuildCall(BuildCtx & ctx, const CHqlBoundTarget * tgt,
         case type_table:
         case type_groupedtable:
             {
-                if (getBoolAttribute(external, passParameterMetaAtom, false))
+                IHqlExpression* passParamAttr = getFunctionBodyAttribute(external, passParameterMetaAtom);
+                if (passParamAttr != NULL && getBoolAttributeValue(passParamAttr))
                     args.append(*buildMetaParameter(curParam));
                 ExpressionFormat format = queryNaturalFormat(argType);
                 buildDataset(ctx, castParam, bound, format);
@@ -6171,7 +6172,8 @@ void HqlCppTranslator::doBuildCall(BuildCtx & ctx, const CHqlBoundTarget * tgt,
             }
         case type_row:
             {
-                if (getBoolAttribute(external, passParameterMetaAtom, false))
+                IHqlExpression* passParamAttr = getFunctionBodyAttribute(external, passParameterMetaAtom);
+                if (passParamAttr != NULL && getBoolAttributeValue(passParamAttr))
                     args.append(*buildMetaParameter(curParam));
                 Owned<IReferenceSelector> selector = buildNewRow(ctx, castParam);
 

+ 2 - 1
ecl/hqlcpp/hqlwcpp.cpp

@@ -850,7 +850,8 @@ void HqlCppWriter::generateParamCpp(IHqlExpression * param, IHqlExpression * att
     case type_table:
     case type_groupedtable:
     case type_row:
-        if (getBoolAttribute(attrs, passParameterMetaAtom, false))
+        IHqlExpression* passParamAttr = getFunctionBodyAttribute(attrs, passParameterMetaAtom);
+        if (passParamAttr != NULL && getBoolAttributeValue(passParamAttr))
         {
             out.append("IOutputMetaData & ");
             if (paramName)