How to create a PropertyMacro via Open API?

Hi all,

I am trying to create a PropertyMacro via Open API in a TF, but it doesn't seem to work though....

placeholder.png


⋮
// xml tag stuff
⋮
// dummy string for the internal content of the macro
node<StringLiteral> dummyString = new node<StringLiteral>(); 
dummyString.value.set("234"); 
 
// actual expression 
node<ExpressionStatement> exprState = new node<ExpressionStatement>(); 
// exprState.expression.set(stcMCall); 
exprState.expression.set(dummyString); 
 
// statement list 
node<StatementList> stateList = new node<StatementList>(); 
stateList.statement.add(exprState); 

// property gpv macro 
node<PropertyMacro_GetPropertyValue> macroGPV = new node<PropertyMacro_GetPropertyValue>(); 
macroGPV.body.set(stateList); 

// actual property macro 
node<PropertyMacro> realPropertyMacro = new node<PropertyMacro>(); 
realPropertyMacro.propertyValueFunction.set(macroGPV);

// add to xml attr text value
typeAttrValue.smodelAttribute.add(realPropertyMacro);
prettyPrint();

Actually this should like the following images:
shouldlooklike.png

shouldlooklike2.png


But in reality it gives me this:
fault1.png

fault2.png



Any thoughts on how to fix this?


Cheers,
Dennis
3 comments
It is not clear at the first glance. I expect "typeAttrValue" is of concept XmlTextValue, isn't it?
0
Try using different instruction for adding property macro:
typeAttrValue.@propertyMacro<text>.set(realPropertyMacro);
prettyPrint();
0
Thx Alex, it works like a charm now!
0

Please sign in to leave a comment.