protected override void CreateBodyReturnValue(StringBuilder sb, TypeAndName funcDef, bool returnsVal) { if (returnsVal) { AddBodyLine(sb, "return(" + CreateXptrObjRefFunction + @"(" + ReturnedValueVarname + ", '" + funcDef.TypeName + "'))"); } }
private void ApiArgToRcpp(StringBuilder sb, TypeAndName typeAndName) { var rt = typeAndName.TypeName; ApiTypeToRcpp(sb, rt); sb.Append(" "); sb.Append(typeAndName.VarName); }
// TODO: refactor - minor duplicate protected override void CreateBodyReturnValue(StringBuilder sb, TypeAndName funcDef, bool returnsVal) { if (returnsVal) { AddBodyLine(sb, "var x = " + CsharpWrap(funcDef.TypeName, ReturnedValueVarname)); AddBodyLine(sb, "return x"); } }
protected void ApiArgToCsharp(StringBuilder sb, TypeAndName typeAndName) { var rt = typeAndName.TypeName; ApiTypeToCsharpApi(sb, rt); sb.Append(" "); sb.Append(typeAndName.VarName); }
protected void ReturnApiArgToCsharpDelegateArg(StringBuilder sb, TypeAndName typeAndName) { var rt = typeAndName.TypeName; ReturnApiTypeToCsharpDelegateArgType(sb, rt); sb.Append(" "); sb.Append(typeAndName.VarName); }
public string CleanupTransientApiArgument(TypeAndName typeAndName) { TransientArgumentConversion t = FindTransientArgConversion(typeAndName); if (t == null) { return(string.Empty); } return(t.LocalVarCleanup); }
private void ApiCallArgument(StringBuilder sb, TypeAndName typeAndName) { // xptr <- SWIFT_API_FUNCNAME_R(modelInstance_xptr, obsVarId, observations, arrayLength, start, statisticId) // in context: //SWIFT_API_FUNCNAME_R_wrap < -function(modelInstance, obsVarId, observations, arrayLength, start, statisticId) { // modelInstance_xptr < -getSwiftXptr(modelInstance) // xptr <- SWIFT_API_FUNCNAME_R(modelInstance_xptr, obsVarId, observations, arrayLength, start, statisticId) // return (mkSwiftObjRef(xptr)) //} sb.Append(typeAndName.VarName); }
protected override void CreateApiFunctionCallFunction(StringBuilder sb, TypeAndName funcDef) { // SWIFT_API CONSTRAINT_PARAMETERIZER_PTR CreateMuskingumConstraint(HYPERCUBE_PTR hypercubeParameterizer, double deltaT, const char* paramNameK, const char* paramNameX, MODEL_SIMULATION_PTR simulation); // should lead to a function call such as: // MsDotnetNativeApi.NativeSwiftLib.GetFunction<CreateMuskingumConstraint_csdelegate>("CreateMuskingumConstraint") // (parameterizer.GetHandle(), deltaT, paramNameK, paramNameX, (simulation == null ? IntPtr.Zero : simulation.GetHandle())); string getFunction = string.Format(ClassName + ".NativeSwiftLib.GetFunction<{0}{1}>(\"{0}\")", funcDef.VarName, this.DelegateFunctionNamePostfix); sb.Append(getFunction); }
// TODO: refactor - minor duplicate protected override void CreateBodyReturnValue(StringBuilder sb, TypeAndName funcDef, bool returnsVal) { if (returnsVal) { sb.Append(" auto x = " + CppWrap(funcDef.TypeName, ReturnedValueVarname) + StatementSep + NewLineString); if (funcDef.TypeName == "char*") { sb.Append(" DeleteAnsiString(" + ReturnedValueVarname + ");" + NewLineString); } sb.Append(" return x;"); } }
protected override void CreateBodyReturnValue(StringBuilder sb, TypeAndName funcDef, bool returnsVal) { if (returnsVal) { string statement = "auto x = " + RcppWrap(funcDef.TypeName, ReturnedValueVarname); AddBodyLine(sb, statement); if (funcDef.TypeName == "char*") { AddBodyLine(sb, "DeleteAnsiString(" + ReturnedValueVarname + ")"); } AddBodyLine(sb, "return x"); } }
private void addTransientVariable(TypeAndName varDecl, Dictionary <string, TransientArgumentConversion> transientArgs) { string tname = varDecl.TypeName; string vname = varDecl.VarName; ArgConversion conv = FindConverter(tname); if (conv == null) { return; } var t = conv.Apply(vname); transientArgs[vname] = t; }
protected override void CreateBodyReturnValue(StringBuilder sb, TypeAndName funcDef, bool returnsVal) { if (returnsVal) { if (IsPointer(funcDef.TypeName)) { AddBodyLine(sb, FunctionOutputName + " = " + CreateXptrObjRefFunction + @"(" + ReturnedValueVarname + ", '" + funcDef.TypeName + "')"); } else { AddBodyLine(sb, FunctionOutputName + " = " + ReturnedValueVarname); } } }
private void ApiCallArgument(StringBuilder sb, TypeAndName typeAndName) { //""" // :param str element_name // :param bool select_network_above_element // :param bool include_element_in_selection // :param bool invert_selection // :param list termination_elements: List of str. //""" //termination_elems_c = [FFI_.new("char[]", as_bytes(x)) for x in termination_elements] //return LIB.SubsetModel(ptr, element_name, select_network_above_element, // include_element_in_selection, invert_selection, // termination_elems_c, len(termination_elements)) sb.Append(typeAndName.VarName); }
public static string GetFuncName(string funDef) { TypeAndName typeAndName = GetFunctionTypeAndName(funDef); return(typeAndName.VarName); }
protected TransientArgumentConversion FindTransientArgConversion(TypeAndName typeAndName) { return(FindTransientArgConversion(typeAndName.TypeName, typeAndName.VarName)); }
protected override void CreateApiFunctionCallFunction(StringBuilder sb, TypeAndName funcDef) { string matlabCallsLib = "calllib('" + NativeLibraryNameNoext + "', '" + funcDef.VarName + "', "; sb.Append(matlabCallsLib); }
protected void TransientArgsCleanup(StringBuilder sb, TypeAndName typeAndName) { sb.Append(CleanupTransientApiArgument(typeAndName)); }
protected void TransientArgsCreation(StringBuilder sb, TypeAndName typeAndName) { sb.Append(CreateTransientApiArgument(typeAndName)); }
protected abstract void CreateBodyReturnValue(StringBuilder sb, TypeAndName funcDef, bool returnsVal);
protected virtual void CreateApiFunctionCallFunction(StringBuilder sb, TypeAndName funcDef) { sb.Append(ApiCallPrefix + funcDef.VarName + ApiCallPostfix); }
protected bool CreateApiFunctionCall(StringBuilder sb, FuncAndArgs funcAndArgs, Action <StringBuilder, TypeAndName> argFunc, Dictionary <string, TransientArgumentConversion> transientArgs, TypeAndName funcDef, bool returnsVal) { sb.Append(UniformIndentation); sb.Append(Indentation); if (returnsVal) { AppendReturnedValueDeclaration(sb); } CreateApiFunctionCallFunction(sb, funcDef); if (!AddFunctionArgs(sb, funcAndArgs, argFunc, transientArgs, ApiCallOpenParenthesis)) { return(false); } sb.Append(StatementSep); sb.Append(NewLineString); return(true); }
private void ApiArgToRfunctionArgument(StringBuilder sb, TypeAndName typeAndName) { // dynamic runtime type only for py: sb.Append(typeAndName.VarName); }
protected static bool FunctionReturnsValue(TypeAndName funcDef) { return(funcDef.TypeName.Trim() != "void"); }
protected override void CreateBodyReturnValue(StringBuilder sb, TypeAndName funcDef, bool returnsVal) { // should not be called for delegate signature declaration. Do nothing. }
private void ApiCallArgument(StringBuilder sb, TypeAndName typeAndName) { CsharpApiToCApiType(sb, typeAndName.TypeName, typeAndName.VarName); }
private void ApiCallArgument(StringBuilder sb, TypeAndName typeAndName) { // Do nothing - delegates are declaration only }
private void ApiCallArgument(StringBuilder sb, TypeAndName typeAndName) { sb.Append(typeAndName.VarName); }
private void ApiCallArgument(StringBuilder sb, TypeAndName typeAndName) { RcppToApiType(sb, typeAndName.TypeName, typeAndName.VarName); }
private void ApiArgToRfunctionArgument(StringBuilder sb, TypeAndName typeAndName) { sb.Append(typeAndName.VarName); }