コード例 #1
0
 protected override void CreateBodyReturnValue(StringBuilder sb, TypeAndName funcDef, bool returnsVal)
 {
     if (returnsVal)
     {
         AddBodyLine(sb, "return(" + CreateXptrObjRefFunction + @"(" + ReturnedValueVarname + ", '" + funcDef.TypeName + "'))");
     }
 }
コード例 #2
0
        private void ApiArgToRcpp(StringBuilder sb, TypeAndName typeAndName)
        {
            var rt = typeAndName.TypeName;

            ApiTypeToRcpp(sb, rt);
            sb.Append(" ");
            sb.Append(typeAndName.VarName);
        }
コード例 #3
0
 // 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");
     }
 }
コード例 #4
0
        protected void ApiArgToCsharp(StringBuilder sb, TypeAndName typeAndName)
        {
            var rt = typeAndName.TypeName;

            ApiTypeToCsharpApi(sb, rt);
            sb.Append(" ");
            sb.Append(typeAndName.VarName);
        }
コード例 #5
0
        protected void ReturnApiArgToCsharpDelegateArg(StringBuilder sb, TypeAndName typeAndName)
        {
            var rt = typeAndName.TypeName;

            ReturnApiTypeToCsharpDelegateArgType(sb, rt);
            sb.Append(" ");
            sb.Append(typeAndName.VarName);
        }
コード例 #6
0
        public string CleanupTransientApiArgument(TypeAndName typeAndName)
        {
            TransientArgumentConversion t = FindTransientArgConversion(typeAndName);

            if (t == null)
            {
                return(string.Empty);
            }
            return(t.LocalVarCleanup);
        }
コード例 #7
0
 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);
 }
コード例 #8
0
        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);
        }
コード例 #9
0
 // 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;");
     }
 }
コード例 #10
0
 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");
     }
 }
コード例 #11
0
        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;
        }
コード例 #12
0
 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);
         }
     }
 }
コード例 #13
0
        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);
        }
コード例 #14
0
        public static string GetFuncName(string funDef)
        {
            TypeAndName typeAndName = GetFunctionTypeAndName(funDef);

            return(typeAndName.VarName);
        }
コード例 #15
0
 protected TransientArgumentConversion FindTransientArgConversion(TypeAndName typeAndName)
 {
     return(FindTransientArgConversion(typeAndName.TypeName, typeAndName.VarName));
 }
コード例 #16
0
        protected override void CreateApiFunctionCallFunction(StringBuilder sb, TypeAndName funcDef)
        {
            string matlabCallsLib = "calllib('" + NativeLibraryNameNoext + "', '" + funcDef.VarName + "', ";

            sb.Append(matlabCallsLib);
        }
コード例 #17
0
 protected void TransientArgsCleanup(StringBuilder sb, TypeAndName typeAndName)
 {
     sb.Append(CleanupTransientApiArgument(typeAndName));
 }
コード例 #18
0
 protected void TransientArgsCreation(StringBuilder sb, TypeAndName typeAndName)
 {
     sb.Append(CreateTransientApiArgument(typeAndName));
 }
コード例 #19
0
 protected abstract void CreateBodyReturnValue(StringBuilder sb, TypeAndName funcDef, bool returnsVal);
コード例 #20
0
 protected virtual void CreateApiFunctionCallFunction(StringBuilder sb, TypeAndName funcDef)
 {
     sb.Append(ApiCallPrefix + funcDef.VarName + ApiCallPostfix);
 }
コード例 #21
0
 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);
 }
コード例 #22
0
 private void ApiArgToRfunctionArgument(StringBuilder sb, TypeAndName typeAndName)
 {
     // dynamic runtime type only for py:
     sb.Append(typeAndName.VarName);
 }
コード例 #23
0
 protected static bool FunctionReturnsValue(TypeAndName funcDef)
 {
     return(funcDef.TypeName.Trim() != "void");
 }
コード例 #24
0
 protected override void CreateBodyReturnValue(StringBuilder sb, TypeAndName funcDef, bool returnsVal)
 {
     // should not be called for delegate signature declaration. Do nothing.
 }
コード例 #25
0
 private void ApiCallArgument(StringBuilder sb, TypeAndName typeAndName)
 {
     CsharpApiToCApiType(sb, typeAndName.TypeName, typeAndName.VarName);
 }
コード例 #26
0
 private void ApiCallArgument(StringBuilder sb, TypeAndName typeAndName)
 {
     // Do nothing - delegates are declaration only
 }
コード例 #27
0
 private void ApiCallArgument(StringBuilder sb, TypeAndName typeAndName)
 {
     sb.Append(typeAndName.VarName);
 }
コード例 #28
0
 private void ApiCallArgument(StringBuilder sb, TypeAndName typeAndName)
 {
     RcppToApiType(sb, typeAndName.TypeName, typeAndName.VarName);
 }
コード例 #29
0
 private void ApiArgToRfunctionArgument(StringBuilder sb, TypeAndName typeAndName)
 {
     sb.Append(typeAndName.VarName);
 }