Commit d3f79bff authored by Johannes Eder's avatar Johannes Eder
Browse files

Merge branch '4051' into 'master'

4051

See merge request af3/af3!361
parents 5f678e7a 0609e3be
......@@ -18,6 +18,12 @@
modelElementClass="org.fortiss.af3.expression.model.DataDictionary">
</modelElementClass>
</modelElementHandler>
<modelElementHandler
handler="org.fortiss.af3.expression.ui.handler.FunctionDeployedParameterHandler">
<modelElementClass
modelElementClass="org.fortiss.af3.expression.model.definitions.FunctionDeployedParameter">
</modelElementClass>
</modelElementHandler>
<modelElementHandler
handler="org.fortiss.af3.expression.ui.handler.FunctionDefinitionHandler">
<modelElementClass
......@@ -101,7 +107,7 @@
<extension
point="org.eclipse.ui.views.properties.tabbed.propertySections">
<propertySections
contributorId="org.fortiss.tooling.kernel.ui.properties.Contributor">
contributorId="org.fortiss.tooling.kernel.ui.properties.Contributor">
<propertySection
afterSection="org.fortiss.tooling.kernel.ui.internal.properties.NamedCommentedPropertySection"
class="org.fortiss.af3.expression.ui.properties.FunctionDefinitionPropertySection"
......
......@@ -2,6 +2,7 @@ ArrayHandler.java 1d17548dffca9839e552a283c0d7b1ec0d4aa741 GREEN
DataDictionaryHandler.java f421407a82eba44a53558314ac3028a9271e89d3 GREEN
EnumerationHandler.java ce7548f6665d24cbfe2b826b8aaa187a2dc4fc02 GREEN
FunctionDefinitionHandler.java 9e0ea3284373c3fce7d9816337caa49d385bf6cd GREEN
FunctionDeployedParameterHandler.java 778422d367fd80e58821e7ddc6990430040db6a2 GREEN
LibraryFunctionDefinitionHandler.java 6f216d33f71fd3bb5b9e229b2f7e3d29a38b6c8c GREEN
LibraryTypeDefinitionHandler.java a78a38fc457296502fa947ff804adfafc65542c6 GREEN
MemberHandler.java fc612dc4983bd1e34477a530392be5e996586c68 GREEN
......
/*-------------------------------------------------------------------------+
| Copyright 2011 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.expression.ui.handler;
import static org.fortiss.af3.expression.ui.AF3ExpressionUIActivator.PLUGIN_ID;
import org.fortiss.af3.expression.model.definitions.FunctionDeployedParameter;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.extension.base.ModelElementHandlerBase;
/**
* {@link IModelElementHandler} for {@link FunctionDeployedParameter}s.
*
*/
public final class FunctionDeployedParameterHandler
extends ModelElementHandlerBase<FunctionDeployedParameter> {
/** {@inheritDoc} */
@Override
public String getName(FunctionDeployedParameter element) {
return element.getFunction().getName();
}
/** {@inheritDoc} */
@Override
protected String getPluginId() {
return PLUGIN_ID;
}
/** {@inheritDoc} */
@Override
protected String getIconPath(FunctionDeployedParameter element) {
return "icons/functiondeployedparameter.png";
}
}
ArrayPropertySection.java 49c7ab946be39d9ba680fc15f45a7ee635923f98 GREEN
EnumPropertySection.java f6c6028c3e082314d5c3ef7c6a07de9f2f21a65e GREEN
FunctionDefinitionPropertySection.java 6b132b194a8dc7e9cd5c3645bf644aa529a8ca67 GREEN
FunctionDefinitionPropertySection.java 8aa27099254048a57bd21f4ca3f4126ba57ab00f GREEN
StructureMemberPropertySection.java 2afb1ca630444ca323f45f6b2114a95a37c73703 GREEN
StructurePropertySection.java 3d1fe66636166447bb404a18473f9eaa844363a0 GREEN
......@@ -44,6 +44,7 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.fortiss.af3.expression.model.DataDictionary;
import org.fortiss.af3.expression.model.definitions.DefinitionsPackage;
import org.fortiss.af3.expression.model.definitions.FunctionDefinition;
import org.fortiss.af3.expression.model.definitions.FunctionDeployedParameter;
import org.fortiss.af3.expression.model.definitions.FunctionParameter;
import org.fortiss.af3.expression.model.definitions.library.FunctionDefinitionRef;
import org.fortiss.af3.expression.ui.databinding.convert.StatementSequenceToStringConverter;
......@@ -86,6 +87,9 @@ public final class FunctionDefinitionPropertySection extends PropertySectionBase
/** Parameter widget. */
private Text parametersText;
/** Parameter label. */
private Label parametersLabel;
/** Return type widget. */
private Text returnTypeText;
......@@ -103,6 +107,12 @@ public final class FunctionDefinitionPropertySection extends PropertySectionBase
/** Detach label. */
private Label detachLabel;
/** Label for the lookup url of {@link FunctionDeployedParameter}s */
private Label lookupUrlLabel;
/** Text for the lookup url of {@link FunctionDeployedParameter}s */
private Text lookupUrlText;
/** {@inheritDoc} */
@Override
public void createControls(Composite parent,
......@@ -117,7 +127,8 @@ public final class FunctionDefinitionPropertySection extends PropertySectionBase
uriLabel = createFormEntry(uriText, "URI");
uriLabel.setVisible(false);
uriText.setVisible(false); // only visible if its a reference element
parametersText = createDecoratedFormText("Parameter");
parametersText = getWidgetFactory().createText(composite, "");
parametersLabel = createFormEntry(parametersText, "Parameter");
returnTypeText = createDecoratedFormText("Return");
definitionText = getWidgetFactory().createText(composite, "", SWT.MULTI | SWT.V_SCROLL);
......@@ -127,6 +138,11 @@ public final class FunctionDefinitionPropertySection extends PropertySectionBase
gd.heightHint = 150;
definitionText.setLayoutData(gd);
lookupUrlText = getWidgetFactory().createText(composite, "");
lookupUrlLabel = createFormEntry(lookupUrlText, "Lookup Url");
lookupUrlLabel.setVisible(false);
lookupUrlText.setVisible(false);
detachLabel = getWidgetFactory().createLabel(composite, "Detach");
detachButton = getWidgetFactory().createButton(composite, "Detach from library", SWT.NONE);
detachLabel.setVisible(false);
......@@ -240,6 +256,17 @@ public final class FunctionDefinitionPropertySection extends PropertySectionBase
uriText.setText(((FunctionDefinitionRef)function).getURI());
uriLabel.setEnabled(true);
}
if(function instanceof FunctionDeployedParameter) {
lookupUrlLabel.setVisible(true);
lookupUrlText.setVisible(true);
parametersText.setVisible(false);
parametersLabel.setVisible(false);
} else {
lookupUrlLabel.setVisible(false);
lookupUrlText.setVisible(false);
parametersText.setVisible(true);
parametersLabel.setVisible(true);
}
EAttribute nameAttribute = FortissToolingKernelPackage.Literals.INAMED_ELEMENT__NAME;
IObservableValue<?> modelObservable = observeValue(function.getFunction(), nameAttribute);
......@@ -269,6 +296,12 @@ public final class FunctionDefinitionPropertySection extends PropertySectionBase
new StringToStatementSequenceConverter(function),
new StringToStatementSequenceValidator(function), null);
if(function instanceof FunctionDeployedParameter) {
modelObservable = observeValue(function,
DefinitionsPackage.Literals.FUNCTION_DEPLOYED_PARAMETER__LOOKUP_URL);
dbc.bindValue(observeText(lookupUrlText, SWT.Modify), modelObservable, null, null);
}
if(nameText.getText().equals("samplingTime")) {
String samplingComment =
"Sampling time represents the time corresponding to an AF3 tick, it is used for different AF3 features like FMU generation.";
......
PrototypeProvider.java 22180df12d9a7d4d381ec91ddbf5d1f37a825165 GREEN
PrototypeProvider.java 48a5ec2d19e7e7ed980906b231c28cce026ddfbd GREEN
......@@ -17,6 +17,7 @@ package org.fortiss.af3.expression.ui.prototypes;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.boolType;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.createDataDictionary;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.createDeployedParameter;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.createEnumeration;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.createEnumerationMember;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.createFunctionParameter;
......@@ -30,6 +31,7 @@ import org.fortiss.af3.expression.model.definitions.DefinitionsFactory;
import org.fortiss.af3.expression.model.definitions.Enumeration;
import org.fortiss.af3.expression.model.definitions.EnumerationMember;
import org.fortiss.af3.expression.model.definitions.FunctionDefinition;
import org.fortiss.af3.expression.model.definitions.FunctionDeployedParameter;
import org.fortiss.af3.expression.model.definitions.FunctionParameter;
import org.fortiss.af3.expression.model.definitions.Structure;
import org.fortiss.af3.expression.model.definitions.StructureMember;
......@@ -70,6 +72,8 @@ public final class PrototypeProvider extends PrototypeProviderBase {
setupUserDefinedFunctionPrototype();
setupDeployedParameterPrototype();
setupArrayPrototypes();
}
......@@ -92,6 +96,17 @@ public final class PrototypeProvider extends PrototypeProviderBase {
registerPrototype("Function", fun, CATEGORY_NAME);
}
/** Defines prototype for {@link FunctionDeployedParameter}. */
private void setupDeployedParameterPrototype() {
FunctionDeployedParameter dplPrm = createDeployedParameter("myParam", intType());
Return ret = ReturnStaticImpl.create(IntConstStaticImpl.create(0));
dplPrm.setDefinition(StatementSequenceStaticImpl.create(ret));
dplPrm.getFunction().setComment(
"Deployed parameters are used to return values read from a configuration file during runtime. The entered definition is only used for simulation.");
dplPrm.setLookupUrl("url/myParam");
registerPrototype("Deployed Parameter", dplPrm, CATEGORY_NAME);
}
/** Defines prototype for {@link StructureMember}. */
private void setupStructureMemberPrototype() {
registerPrototype("Structure Member", createStructureMember("member", intType()),
......
expression.ecore 3dfeaad4471672511739be4e9457c75430dab2ee RED
expression.ecore 773c97a58c29095f5bc012d7e9699d1e48044ef7 GREEN
......@@ -767,6 +767,12 @@
containment="true"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="length" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="FunctionDeployedParameter" eSuperTypes="#//definitions/FunctionDefinition">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="User-defined fixed-value parameter consisting of a name, a return type, a lookup url for the value during runtime and statement block as stand-in for simulation."/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="lookupUrl" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eSubpackages name="library" nsURI="http://www.fortiss.org/af3/expression/definitions/library"
nsPrefix="org-fortiss-af3-expression-definitions-library">
<eClassifiers xsi:type="ecore:EClass" name="LibraryTypeDefinition" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//base/LibraryElementBase">
......
......@@ -404,6 +404,9 @@
ecoreFeature="ecore:EReference expression.ecore#//definitions/Array/type"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute expression.ecore#//definitions/Array/length"/>
</genClasses>
<genClasses ecoreClass="expression.ecore#//definitions/FunctionDeployedParameter">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute expression.ecore#//definitions/FunctionDeployedParameter/lookupUrl"/>
</genClasses>
<nestedGenPackages prefix="Library" basePackage="org.fortiss.af3.expression.model.definitions"
disposableProviderFactory="true" ecorePackage="expression.ecore#//definitions/library">
<genClasses ecoreClass="expression.ecore#//definitions/library/LibraryTypeDefinition">
......
ArrayToCHeaderTransformation.java d656d0ff5ed03f108eb543d77789e7f0e4bbd21c GREEN
CReplacementVisitor.java 7cab595ef28be6a58914c45dfb69b7a48d89f164 GREEN
DataDictionaryToCSourcePackageTransformation.java 18ded8476d2c06ecf651468de17c01a989edc4fd GREEN
DataDictionaryToCSourcePackageTransformation.java 716e5d57936d515ab00fc3cca8186780a9a42dc4 GREEN
EnumerationToCHeaderTransformation.java 631c23594238b0f01f786da16e1ef57837052563 GREEN
FunctionDefinitionToCFunctionDeclarationTransformation.java dd10dbc822c4f910faee6cb956d15ca389a3ec46 GREEN
FunctionDefinitionToCFunctionDeclarationTransformation.java fc03d9f66fbf934c7fb2674642c60ead6fa57537 GREEN
StructureToCHeaderTransformation.java 416dd37ee55629b4eba8f047d5789befb9b27da4 GREEN
......@@ -41,6 +41,7 @@ import org.fortiss.af3.expression.model.DataDictionary;
import org.fortiss.af3.expression.model.definitions.Array;
import org.fortiss.af3.expression.model.definitions.Enumeration;
import org.fortiss.af3.expression.model.definitions.FunctionDefinition;
import org.fortiss.af3.expression.model.definitions.FunctionDeployedParameter;
import org.fortiss.af3.expression.model.definitions.Structure;
import org.fortiss.af3.expression.model.definitions.StructureMember;
import org.fortiss.af3.expression.model.definitions.TypeDefinition;
......@@ -52,6 +53,7 @@ import org.fortiss.af3.generator.common.model.c.CImplementationFile;
import org.fortiss.af3.generator.common.model.c.CSourcePackage;
import org.fortiss.af3.generator.common.model.c.CTypeDeclaration;
import org.fortiss.af3.generator.common.model.source.Declaration;
import org.fortiss.af3.generator.common.utils.CLanguageModelElementFacade;
import org.fortiss.tooling.kernel.extension.ITransformationProvider;
import org.fortiss.tooling.kernel.extension.base.TransformationProviderBase;
import org.fortiss.tooling.kernel.extension.data.ITransformationContext;
......@@ -115,11 +117,19 @@ public class DataDictionaryToCSourcePackageTransformation
}
// user-defined functions
boolean hasParameter = false;
for(FunctionDefinition fdef : dict.getFunctions()) {
CFunctionDeclaration fd =
createTransformedObjectFor(fdef, CFunctionDeclaration.class, context);
addDeclaration(header, fd);
addDefinition(impl, fd.getDefinition());
if(fdef instanceof FunctionDeployedParameter) {
hasParameter = true;
}
}
if(hasParameter) {
CLanguageModelElementFacade.addStandardHeaderInclude(impl, "conf");
}
// source package
......
......@@ -15,13 +15,16 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.expression.generator.c;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory2.createParameterLookup;
import static org.fortiss.af3.generator.common.model.c.CModifier.EXTERN;
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createCFunctionDeclaration;
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createCFunctionDefinition;
import static org.fortiss.af3.generator.common.utils.CLanguageModelElementFactory.createCVariable;
import org.fortiss.af3.expression.model.definitions.FunctionDefinition;
import org.fortiss.af3.expression.model.definitions.FunctionDeployedParameter;
import org.fortiss.af3.expression.model.definitions.FunctionParameter;
import org.fortiss.af3.expression.model.terms.imperative.StatementSequence;
import org.fortiss.af3.generator.common.model.c.CFunctionDeclaration;
import org.fortiss.af3.generator.common.model.c.CFunctionDefinition;
import org.fortiss.af3.generator.common.model.c.CVariable;
......@@ -66,6 +69,15 @@ public class FunctionDefinitionToCFunctionDeclarationTransformation
/** {@inheritDoc} */
@Override
public CFunctionDeclaration transform(Object source, ITransformationContext context) {
if(source instanceof FunctionDeployedParameter) {
FunctionDeployedParameter def = (FunctionDeployedParameter)source;
StatementSequence seq = createParameterLookup(def);
CFunctionDefinition cDef = createCFunctionDefinition(def.getFunction().getName(),
def.getReturnType(), seq);
return createCFunctionDeclaration(EXTERN, cDef);
}
FunctionDefinition def = (FunctionDefinition)source;
CFunctionDefinition cDef = createCFunctionDefinition(def.getFunction().getName(),
def.getReturnType(), new CReplacementVisitor(def.getDefinition()).apply());
......
ConstraintMessage.java faaa743651a3ddf98c660d47cc6c4720172b5331 GREEN
ConstraintMessage.java 587d507ab408ccf99c43a92d4cd54da98d305996 GREEN
DataDictionaryConstraintChecker.java bcbe46859c6bfff5ff6bf4a85ecbe0c1bdc51979 GREEN
EnumerationConstraintChecker.java f40d879d2f70aee226b6ca46b5765a9adf61f69c GREEN
FunctionDefinitionConstraintChecker.java 0e04ee397c45ef1eda462d6470c7199786c48b41 GREEN
FunctionDefinitionConstraintChecker.java c065f4b6b1e06b6168e60538280603bb3ac19b1d GREEN
StructureConstraintChecker.java c311702ad94abf206e62817a482e0e0da5ff3e51 GREEN
......@@ -91,6 +91,15 @@ final class ConstraintMessage {
def.getDataDictionary());
}
/** Creates violation for function body type checking. */
public static ConstraintViolationBase<FunctionDefinition>
createFunctionDefinitionisParameterCheckViolation(FunctionDefinition def,
String detailedMessage) {
return new ConstraintViolationBase<FunctionDefinition>(def, ERROR,
"Not a parameter " + def.getFunction().getName() + ": " + detailedMessage,
def.getDataDictionary());
}
/** Creates violation for using NoVal in function body. */
public static ConstraintViolationBase<FunctionDefinition>
createFunctionDefinitionNoValCheckViolation(FunctionDefinition def) {
......
......@@ -38,6 +38,7 @@ import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.expression.language.evaluation.NoVal;
import org.fortiss.af3.expression.model.DataDictionary;
import org.fortiss.af3.expression.model.definitions.FunctionDefinition;
import org.fortiss.af3.expression.model.definitions.FunctionDeployedParameter;
import org.fortiss.af3.expression.model.definitions.FunctionParameter;
import org.fortiss.af3.expression.model.terms.FunctionCall;
import org.fortiss.af3.expression.model.terms.Var;
......@@ -103,7 +104,27 @@ public class FunctionDefinitionConstraintChecker
if(alreadyViolated.get()) {
performAllPathsReturnValuecheck(def, results);
}
if(def instanceof FunctionDeployedParameter && alreadyViolated.get()) {
performIsParameterCheck(def, results);
}
}
}
/**
* Checks that the function definition only consists of a return statement (only applicable to
* the definitions of {@link FunctionDeployedParameter})
*/
private void performIsParameterCheck(FunctionDefinition def,
List<IConstraintViolation<FunctionDefinition>> results) {
StatementSequence term = def.getDefinition();
for(IStatementTerm stmt : term.getStatements()) {
if(stmt instanceof Return) {
return;
}
}
results.add(ConstraintMessage.createFunctionDefinitionisParameterCheckViolation(def,
"The definition is too complex for a parameter"));
}
/**
......
DataDictionaryUtils.java 67bd95a8f9eb89303b502f3831f228c85134f5bf GREEN
ExpressionModelElementFactory.java aa250d8cbc5a8a1f5112638abb7590892300f1a9 GREEN
ExpressionModelElementFactory.java 37250b8ade2709a030304dbcf3d083c99a9ec10d GREEN
ExpressionModelElementFactory2.java 1498426fb7735aa747f64c251f3d3e0f876bdaaf GREEN
ExpressionUtils.java 468ad163bb6ca438b8d461ec9961c2bfe11c1b27 GREEN
LibraryElementsFactory.java d0b803949097a7c840ced1d92c302ec4cef2054a GREEN
NoValSpecialTreatmentUtils.java 5d7736859de2bedc2ac5173e6090824f38acaf51 GREEN
......
......@@ -35,6 +35,7 @@ import org.fortiss.af3.expression.model.definitions.DoubleTypeDefinition;
import org.fortiss.af3.expression.model.definitions.Enumeration;
import org.fortiss.af3.expression.model.definitions.EnumerationMember;
import org.fortiss.af3.expression.model.definitions.FunctionDefinition;
import org.fortiss.af3.expression.model.definitions.FunctionDeployedParameter;
import org.fortiss.af3.expression.model.definitions.FunctionParameter;
import org.fortiss.af3.expression.model.definitions.IntTypeDefinition;
import org.fortiss.af3.expression.model.definitions.Structure;
......@@ -118,6 +119,17 @@ public class ExpressionModelElementFactory {
return fun;
}
/** Creates a {@link FunctionDeployedParameter} with the given name and return type. */
public static FunctionDeployedParameter createDeployedParameter(String name, IType returnType) {
FunctionDeployedParameter deplPrm =
DefinitionsFactory.eINSTANCE.createFunctionDeployedParameter();
UserdefinedFunction ufun = TermsFactory.eINSTANCE.createUserdefinedFunction();
ufun.setName(name);
deplPrm.setFunction(ufun);
deplPrm.setReturnType(returnType);
return deplPrm;
}
/** Creates a {@link FunctionParameter} with the given name and type. */
public static FunctionParameter createFunctionParameter(String name, IType type) {
FunctionParameter fp = DefinitionsFactory.eINSTANCE.createFunctionParameter();
......
/*-------------------------------------------------------------------------+
| Copyright 2020 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.expression.utils;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.createVar;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.funcCall;
import org.fortiss.af3.expression.model.definitions.FunctionDeployedParameter;
import org.fortiss.af3.expression.model.terms.FunctionCall;
import org.fortiss.af3.expression.model.terms.imperative.ImperativeFactory;
import org.fortiss.af3.expression.model.terms.imperative.Return;
import org.fortiss.af3.expression.model.terms.imperative.StatementSequence;
import org.fortiss.af3.expression.model.types.TDouble;
import org.fortiss.af3.expression.model.types.TInt;
/**
* This class is an extension of {@link ExpressionModelElementFactory} and exists because the length
* limit has been reached.
*
* @author eisenmann
*/
public class ExpressionModelElementFactory2 {
/** Creates a statement sequence to look up the value of a parameter */
public static StatementSequence createParameterLookup(FunctionDeployedParameter def) {
StatementSequence seq = ImperativeFactory.eINSTANCE.createStatementSequence();
FunctionCall fQuery = funcCall("conf_get");
fQuery.getArguments().add(createVar("\"" + def.getLookupUrl() + "\""));
FunctionCall fTransform;
if(def.getReturnType() instanceof TDouble) {
fTransform = funcCall("atof");
} else if(def.getReturnType() instanceof TInt) {
fTransform = funcCall("atoi");
} else {
throw new UnsupportedOperationException(
"No C transformation for parameter type " + def.getReturnType());
}
fTransform.getArguments().add(fQuery);
Return ret = ExpressionModelElementFactory.returns(fTransform);
seq.getStatements().add(ret);
return seq;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment