Procházet zdrojové kódy

HPCC-2819 Would be nice to be able to add inline qualifier to embedc++

Signed-off-by: Shamser Ahmed <shamser.ahmed@lexisnexis.co.uk>
Shamser Ahmed před 9 roky
rodič
revize
58bf1ff9ed

+ 2 - 4
ecl/hql/hqlexpr.cpp

@@ -12181,10 +12181,8 @@ IHqlExpression * createExternalFuncdefFromInternal(IHqlExpression * funcdef)
 
     IHqlExpression *child = body->queryChild(0);
     if (child && child->getOperator()==no_embedbody)
-    {
-        if (child->hasAttribute(inlineAtom))
-            attrs.append(*createAttribute(inlineAtom));
-    }
+        unwindAttribute(attrs, child, inlineAtom);
+
     ITypeInfo * returnType = funcdef->queryType()->queryChildType();
     OwnedHqlExpr externalExpr = createExternalReference(funcdef->queryId(), LINK(returnType), attrs);
     return replaceChild(funcdef, 0, externalExpr);

+ 1 - 1
ecl/hqlcpp/hqlcpp.cpp

@@ -11947,7 +11947,7 @@ void HqlCppTranslator::buildFunctionDefinition(IHqlExpression * funcdef)
         else
         {
             bool isInline = bodyCode->hasAttribute(inlineAtom);
-            if (isInline)
+            if (isInline && options.spanMultipleCpp)
             {
                 BuildCtx funcctx2(*code, parentHelpersAtom);
                 buildCppFunctionDefinition(funcctx2, bodyCode, proto);

+ 4 - 1
testing/regress/ecl/embedcppinline.ecl

@@ -28,4 +28,7 @@ BOOLEAN isUpper(const string mystring) := EMBED(C++ : inline)
   return true;
 ENDEMBED;
 
-IsUpper('TOM');
+OUTPUT(IsUpper('TOM'));
+
+ds := dataset(4, transform({string1 id}, SELF.id := 'aBcD'[COUNTER]));
+output(TABLE(ds, { isUpper(id) }));

+ 6 - 0
testing/regress/ecl/key/embedcppinline.xml

@@ -1,3 +1,9 @@
 <Dataset name='Result 1'>
  <Row><Result_1>true</Result_1></Row>
 </Dataset>
+<Dataset name='Result 2'>
+ <Row><isupper>false</isupper></Row>
+ <Row><isupper>true</isupper></Row>
+ <Row><isupper>false</isupper></Row>
+ <Row><isupper>true</isupper></Row>
+</Dataset>