Exemplo n.º 1
0
    public void onAdjustParam()
    {
        if (obj == null || !obj.gameObject.activeSelf)
        {
            return;
        }

        if (type == 1)
        {
            if (hightlightTog)
            {
                obj.GetComponent <pointCloud> ().ChangeColor(hightColor, highlightMin, highlightMax, filterType);
            }
            else
            {
                //obj.GetComponent<pointCloud> ().ChangeColor (getColorFromUI(), -1, 99999, 0);
            }
            if (scaleTog)
            {
                obj.GetComponent <pointCloud> ().ChangeScale(scaleVal);
            }
            else
            {
                //obj.GetComponent<pointCloud> ().ChangeScale (100);
            }
        }
        if (type == 2)
        {
            List <KeyFrameC> kfList = CppInterface.GetKFList(id);
            if (hightlightTog)
            {
                obj.GetComponent <KFListObj> ().ChangeColors(hightColor, highlightMin, highlightMax, filterType);
            }
            else
            {
                //obj.GetComponent<KFListObj> ().ChangeColors (getColorFromUI() , -1, 99999, filterType);
            }
            obj.GetComponent <KFListObj> ().ShowTraj(lineModeTog, lineColor);
            if (connectLineTog)
            {
                obj.GetComponent <KFListObj> ().ClearKFConnection();
                for (int i = 0; i < kfList.Count; i++)
                {
                    ShowKFConnect(i);
                }
            }
            else
            {
                obj.GetComponent <KFListObj> ().ClearKFConnection();
            }
            if (scaleTog)
            {
                obj.GetComponent <KFListObj> ().changeScale(scaleVal);
            }
            else
            {
                //obj.GetComponent<KFListObj> ().changeScale (100);
            }
        }
    }
Exemplo n.º 2
0
        public CsInterface(CppInterface cppInterface, string name) : base(cppInterface, name)
        {
            var tag = cppInterface?.Rule;

            IsCallback         = tag?.IsCallbackInterface ?? IsCallback;
            IsDualCallback     = tag?.IsDualCallbackInterface ?? IsDualCallback;
            AutoGenerateShadow = tag?.AutoGenerateShadow ?? AutoGenerateShadow;
            AutoGenerateVtbl   = tag?.AutoGenerateVtbl ?? AutoGenerateVtbl;
            StaticShadowVtbl   = tag?.StaticShadowVtbl ?? StaticShadowVtbl;
            ShadowVisibility   = tag?.ShadowVisibility ?? ShadowVisibility;
            VtblVisibility     = tag?.VtblVisibility ?? VtblVisibility;

            if (tag?.ShadowName != null)
            {
                ShadowName = tag.ShadowName;
            }
            if (tag?.VtblName != null)
            {
                VtblName = tag.VtblName;
            }

            if (cppInterface is null)
            {
                return;
            }

            Guid = FindGuid(cppInterface);
        }
Exemplo n.º 3
0
    //data file related
    public void onReadFileBtn()
    {
        int channelId = Int32.Parse(curChennel.text);
        int count     = CppInterface.ReadSingleData(FileAddrUI, FileTypeUI, channelId);

        if (count > 0)
        {
            ChannelInfoRaw channelItem = new ChannelInfoRaw();
            channelItem.type  = FileTypeUI;
            channelItem.id    = channelId;
            channelItem.count = count;
            ChannelInfo uiItem = addListUI(channelItem);
            uiItem.showTog.isOn = true;
            if (FileTypeUI == 1)               //mp

            {
            }
            if (FileTypeUI == 2)              //kf
            {
            }
            if (FileTypeUI == 3)              //road

            {
            }
            if (FileTypeUI == 4)              //features


            {
            }
            if (FileTypeUI == 5)              //images

            {
            }
        }
    }
Exemplo n.º 4
0
    public CsInterface(CppInterface cppInterface, string name) : base(cppInterface, name)
    {
        if (cppInterface == null)
        {
            return;
        }

        var tag = cppInterface.Rule;

        IsCallback         = tag.IsCallbackInterface ?? IsCallback;
        IsDualCallback     = tag.IsDualCallbackInterface ?? IsDualCallback;
        AutoGenerateShadow = tag.AutoGenerateShadow ?? AutoGenerateShadow;
        AutoGenerateVtbl   = tag.AutoGenerateVtbl ?? AutoGenerateVtbl;
        StaticShadowVtbl   = tag.StaticShadowVtbl ?? StaticShadowVtbl;
        ShadowVisibility   = tag.ShadowVisibility ?? ShadowVisibility;
        VtblVisibility     = tag.VtblVisibility ?? VtblVisibility;
        AutoDisposePersistentProperties = tag.AutoDisposePersistentProperties ?? AutoDisposePersistentProperties;

        if (tag.ShadowName != null)
        {
            ShadowName = tag.ShadowName;
        }
        if (tag.VtblName != null)
        {
            VtblName = tag.VtblName;
        }

        Guid = FindGuid(cppInterface);
    }
Exemplo n.º 5
0
    public void updateFrameDisplay(ChannelInfo img, ChannelInfo Feature)
    {
        List <Mat> imgList  = CppInterface.GetIMList(img.id);
        Mat        colorMat = new Mat();

        Imgproc.cvtColor(imgList[0], colorMat, Imgproc.COLOR_GRAY2RGB);
        if (Feature != null)
        {
            List <FeaturesCpp> featureList = CppInterface.GetFPList(Feature.id);
            for (int i = 0; i < featureList.Count; i++)
            {
                FeaturesCpp info = featureList [i];
                Imgproc.circle(colorMat, new Point(info.u, info.v), info.r / 2, new Scalar(info.red, info.green, 0), 2);
                if (info.lastU > 10)
                {
                    Imgproc.line(colorMat, new Point(info.u, info.v), new Point(info.lastU, info.lastV), new Scalar(255, 0, 255), 2);
                }
            }
        }

        RectTransform sizeSetting = FrameDisplay.GetComponent <RectTransform> ();
        float         winH        = colorMat.rows();
        float         winW        = colorMat.cols();

        if (winH > 600)
        {
            winW = winW * 600f / winH;
            winH = 600;
        }
        sizeSetting.sizeDelta = new Vector2(winW, winH);
        Texture2D texture = new Texture2D(colorMat.cols(), colorMat.rows(), TextureFormat.RGBA32, false);

        Utils.matToTexture2D(colorMat, texture);
        FrameDisplay.GetComponent <RawImage> ().texture = texture;
    }
Exemplo n.º 6
0
    public void PointerSizeReturnValueNotLarge()
    {
        var config = new ConfigFile
        {
            Id        = nameof(PointerSizeReturnValueNotLarge),
            Namespace = nameof(PointerSizeReturnValueNotLarge),
            Includes  =
            {
                new IncludeRule
                {
                    File      = "pointerSize.h",
                    Attach    = true,
                    Namespace = nameof(PointerSizeReturnValueNotLarge)
                }
            },
            Extension =
            {
                new DefineExtensionRule
                {
                    Struct            = "SharpGen.Runtime.PointerSize",
                    SizeOf            = 8,
                    IsNativePrimitive = true,
                }
            },
            Bindings =
            {
                new BindRule("int", "SharpGen.Runtime.PointerSize")
            }
        };

        var iface = new CppInterface("Interface");

        iface.Add(new CppMethod("method")
        {
            ReturnValue = new CppReturnValue
            {
                TypeName = "int"
            }
        });

        var include = new CppInclude("pointerSize");

        include.Add(iface);

        var module = new CppModule("SharpGenTestModule");

        module.Add(include);

        var(solution, _) = MapModel(module, config);

        Assert.Single(solution.EnumerateDescendants <CsInterface>());

        var csIface = solution.EnumerateDescendants <CsInterface>().First();

        Assert.Single(csIface.Methods);

        var method = csIface.Methods.First();

        Assert.False(method.IsReturnStructLarge);
    }
Exemplo n.º 7
0
    public void dealWithResult()
    {
        if (AlgoTypeUI == 1)          //slam
        {
            updateListUI();
            List <ChannelInfoRaw> tempList = CppInterface.GetChannelInfo(2);
            //int lastChannelId = tempList [tempList.Count - 1].id;
            if (showFrameUI.isOn)
            {
                ChannelInfo img     = ChannelInfo.getChannel(5, 0);
                ChannelInfo feature = ChannelInfo.getChannel(4, 0);
                if (img != null && feature != null)
                {
                    updateFrameDisplay(img, feature);
                }
            }
//			ChannelInfo item1 = ChannelInfo.getChannel (1, 0);
//			if (item1!=null) {
//				item1.showTog.isOn = true;
//			}
            ChannelInfo item2 = ChannelInfo.getChannel(2, 0);
            if (item2 != null)
            {
                item2.showTog.isOn = true;
            }
        }
        if (AlgoTypeUI == 2)          //gpe
        {
            updateListUI();
            ChannelInfo item1 = ChannelInfo.getChannel(3, 0);
            if (item1 != null)
            {
                item1.showTog.isOn = true;
            }
        }
        if (AlgoTypeUI == 3)          //server
        {
            updateListUI();
            ChannelInfo item1 = ChannelInfo.getChannel(1, 2);
            if (item1 != null)
            {
                item1.showTog.isOn = true;
            }
            ChannelInfo item2 = ChannelInfo.getChannel(2, 2);
            if (item2 != null)
            {
                item2.showTog.isOn = true;
            }
        }
        if (AlgoTypeUI == 4)          //TSL
        {
            updateListUI();
            ChannelInfo item1 = ChannelInfo.getChannel(6, 0);
            if (item1 != null)
            {
                item1.showTog.isOn = true;
            }
        }
    }
Exemplo n.º 8
0
 public CsInterface(CppInterface cppInterface)
 {
     CppElement = cppInterface;
     if (cppInterface != null)
     {
         Guid = cppInterface.Guid;
     }
 }
Exemplo n.º 9
0
        public void Simple()
        {
            var config = new ConfigFile
            {
                Id        = nameof(Simple),
                Namespace = nameof(Simple),
                Includes  =
                {
                    new IncludeRule
                    {
                        File      = "interface.h",
                        Attach    = true,
                        Namespace = nameof(Simple)
                    }
                },
                Bindings =
                {
                    new BindRule("int", "System.Int32")
                }
            };

            var iface = new CppInterface("Interface")
            {
                TotalMethodCount = 1
            };

            iface.Add(new CppMethod("method")
            {
                ReturnValue = new CppReturnValue
                {
                    TypeName = "int"
                }
            });

            var include = new CppInclude("interface");

            include.Add(iface);

            var module = new CppModule("SharpGenTestModule");

            module.Add(include);

            var(solution, _) = MapModel(module, config);

            Assert.Single(solution.EnumerateDescendants().OfType <CsInterface>());

            var csIface = solution.EnumerateDescendants().OfType <CsInterface>().First();

            Assert.Single(csIface.Methods);

            var method = csIface.Methods.First();

            Assert.Equal(0, method.Offset);

            Assert.IsType <CsFundamentalType>(method.ReturnValue.PublicType);

            Assert.Equal(TypeRegistry.Int32, method.ReturnValue.PublicType);
        }
Exemplo n.º 10
0
    public void onReadResultBtn()
    {
        int re = CppInterface.ReadAllData(FileAddrUI);

        if (re > 0)
        {
            dealWithResult();
        }
    }
Exemplo n.º 11
0
        public void DualCallbackFlowsNativeImplementation()
        {
            var config = new ConfigFile
            {
                Id        = nameof(Simple),
                Namespace = nameof(Simple),
                Includes  =
                {
                    new IncludeRule
                    {
                        File      = "interface.h",
                        Attach    = true,
                        Namespace = nameof(Simple)
                    }
                },
                Bindings =
                {
                    new BindRule("int", "System.Int32")
                },
                Mappings =
                {
                    new MappingRule
                    {
                        Interface               = "Interface",
                        IsCallbackInterface     = true,
                        IsDualCallbackInterface = true
                    }
                }
            };

            var iface = new CppInterface("Interface")
            {
                TotalMethodCount = 1
            };

            iface.Add(new CppMethod("method")
            {
                ReturnValue = new CppReturnValue
                {
                    TypeName = "int"
                }
            });

            var include = new CppInclude("interface");

            include.Add(iface);

            var module = new CppModule("SharpGenTestModule");

            module.Add(include);

            var(_, defines) = GetConsumerBindings(module, config);

            var interfaceDefine = defines.First(define => define.Interface == "Simple.Interface");

            Assert.Equal("Simple.InterfaceNative", interfaceDefine.NativeImplementation);
        }
Exemplo n.º 12
0
 public CsInterface(CppInterface cppInterface)
 {
     CppElement = cppInterface;
     if (cppInterface != null)
     {
         Guid = cppInterface.Guid;
     }
     NativeImplem = this;
 }
Exemplo n.º 13
0
        public void RemoveParentDoesNotRemoveAllParents()
        {
            var config = new Config.ConfigFile
            {
                Id        = nameof(RemoveParentDoesNotRemoveAllParents),
                Assembly  = nameof(RemoveParentDoesNotRemoveAllParents),
                Namespace = nameof(RemoveParentDoesNotRemoveAllParents),
                Includes  =
                {
                    new Config.IncludeRule
                    {
                        Attach    = true,
                        File      = "cppEnum.h",
                        Namespace = nameof(RemoveParentDoesNotRemoveAllParents)
                    }
                },
                Mappings =
                {
                    new Config.RemoveRule
                    {
                        Method = @"#.*ToRemove"
                    }
                }
            };

            var cppModel = new CppModule();

            var cppInclude = new CppInclude
            {
                Name = "cppEnum"
            };

            var cppIface = new CppInterface
            {
                Name = "TestInterface"
            };

            cppInclude.Add(cppIface);

            var cppMethod = new CppMethod
            {
                Name = "Method"
            };

            cppMethod.Add(new CppParameter
            {
                Name = "ParamToRemove"
            });
            cppModel.Add(cppInclude);

            var(solution, _) = MapModel(cppModel, config);

            var members = solution.EnumerateDescendants();

            Assert.NotEmpty(members.OfType <CsInterface>());
            Assert.Empty(members.OfType <CsParameter>());
        }
Exemplo n.º 14
0
 IEnumerator UpdateNumber()
 {
     while (true)
     {
         lbl_fps[0].text = number.ToString();
         number          = CppInterface.Add(number, 1);
         yield return(new WaitForSeconds(0.1f));
     }
 }
Exemplo n.º 15
0
    public void updateListUI()
    {
        onClearSceneBtn();
        List <ChannelInfoRaw> tempList = CppInterface.GetAllChannelInfo();

        for (int i = 0; i < tempList.Count; i++)
        {
            ChannelInfo.create(tempList[i]);
        }
    }
Exemplo n.º 16
0
        public override bool VisitCppInterface(CppInterface cppInterface)
        {
            Declaration unitDecl;

            cppElementToDeclarationMapping.TryGetValue(cppInterface.ParentInclude, out unitDecl);
            TranslationUnit unit = unitDecl != null ? unitDecl as TranslationUnit : FindDeclParent <TranslationUnit>(cppInterface.ParentInclude);

            Namespace @namespace = null;
            Class     @interface = null;

            // Check if we have an namespace
            if (!string.IsNullOrEmpty(cppInterface.Namespace))
            {
                @namespace = unit.FindCreateNamespace(cppInterface.Namespace.TrimStart(':'));
                @interface = @namespace.FindClass(cppInterface.Name, true, true);
            }
            else
            {
                @interface = unit.FindClass(cppInterface.Name, true, true);
            }

            @interface.Type = ClassType.Interface;

            // Check if we have an base class
            if (!string.IsNullOrEmpty(cppInterface.ParentName))
            {
                Class baseClass = null;
                if (@namespace != null)
                {
                    baseClass = @namespace.FindClass(cppInterface.ParentName, true, true);
                }
                else
                {
                    baseClass = unit.FindClass(cppInterface.ParentName, true, true);
                }

                // Set type of base class
                baseClass.Type = baseClass.Name.StartsWith("I") ? ClassType.Interface : ClassType.ValueType;

                // Add type tag
                @interface.Bases.Add(new BaseClassSpecifier
                {
                    Access = AccessSpecifier.Public,
                    Type   = new TagType(baseClass)
                });
            }

            cppElementToDeclarationMapping.Add(cppInterface, @interface);
            return(base.VisitCppInterface(cppInterface));
        }
Exemplo n.º 17
0
    private static string FindGuid(CppInterface cppInterface)
    {
        if (!string.IsNullOrEmpty(cppInterface.Guid))
        {
            return(cppInterface.Guid);
        }

        // If Guid is null we try to recover it from a declared GUID

        var finder = new CppElementFinder(cppInterface.ParentInclude);

        var cppGuid = finder.Find <CppGuid>("IID_" + cppInterface.Name).FirstOrDefault();

        return(cppGuid != null
                   ? cppGuid.Guid.ToString()
                   : cppInterface.Guid);
    }
Exemplo n.º 18
0
    void Start()
    {
        MaxStepUI  = 0;
        NextStepUI = -1;
        AlgoTypeUI = 1;
        FileTypeUI = 1;
        commonObj.Init();
        commonObj.mMainUI = this;
        curChennel        = transform.FindChild("Panel/ChannelId").GetComponent <InputField>();
        curChennel.text   = "0";
        CppInterface.NewViewHandle();
        util.ReadHistory(out inputBoxHistory, out lastOpenHistory);
        util.ReadSetting(out uiSetting);
        mainPanel = transform.FindChild("Panel");
        updateListUI();
        commonObj.prefabFileBrower = prefabBrowser;
        listUI             = GameObject.Find("Canvas/Panel/ListRoot/ScrollView/List");
        commonObj.listRoot = listUI.transform;
        runBtn             = GameObject.Find("Canvas/Panel/RunBtn").GetComponent <Button>();
        stopBtn            = GameObject.Find("Canvas/Panel/Stop").GetComponent <Button>();
        reloadBtn          = GameObject.Find("Canvas/Panel/Reload").GetComponent <Button>();
        clearLogBtn        = GameObject.Find("Canvas/Panel/ClearLog").GetComponent <Button>();
        debugLogUI         = GameObject.Find("Canvas/DebugLog").GetComponent <Text>();
        //GameObject.Find ("Canvas/DebugLog").SetActive (false);
        showFrameUI = GameObject.Find("Canvas/Panel/HideFrame").GetComponent <Toggle>();
        showLogUI   = GameObject.Find("Canvas/Panel/ShowLog").GetComponent <Toggle>();
        GScaleUI    = GameObject.Find("Canvas/Panel/GScale").GetComponent <InputField>();
        if (uiSetting.ContainsKey("GScale"))
        {
            string gscaleStr = uiSetting ["GScale"];
            onChangeGScale(gscaleStr);
            GScaleUI.text = gscaleStr;
        }

        //debugLogUI.color = new Color (255, 0, 0, 255);
        runBtn.interactable = true;
        curState            = UIState.idle;
        updateCurTime       = 0;
        requestPause        = false;
        commonObj.goundGird = groundGird.create();
        commonObj.goundGird.gameObject.SetActive(true);
        camModel.generateMesh();
    }
Exemplo n.º 19
0
    public override void Init()
    {
        javaDev = new AndroidJavaClass("com.example.hyz.devlib.Device");
        classId = javaDev.GetRawClass();
        //DevInit();
        RtnStrDelegate cbvn     = GetVersionName;
        IntPtr         cbvn_ptr = Marshal.GetFunctionPointerForDelegate(cbvn);

        CppInterface.SetVersionNamePtr(cbvn_ptr);

        RtnIntDelegate cbvc     = GetVersionCode;
        IntPtr         cbvc_ptr = Marshal.GetFunctionPointerForDelegate(cbvc);

        CppInterface.SetVersionCodePtr(cbvc_ptr);

        RtnStrDelegate cban     = GetAppName;
        IntPtr         cban_ptr = Marshal.GetFunctionPointerForDelegate(cban);

        CppInterface.SetAppNamePtr(cban_ptr);
    }
Exemplo n.º 20
0
 public void onRunBtn()
 {
     CppInterface.NewViewHandle();
     if (AlgoTypeUI == 1)
     {
         CppInterface.SetParam(0, Params[0]);
         CppInterface.SetParam(1, Params[1]);
         CppInterface.SetParam(2, Params[2]);
         CppInterface.SetParam(3, Params[3]);
         FileAddrUI = Params [3];
     }
     if (AlgoTypeUI == 2)
     {
     }
     if (AlgoTypeUI == 3)
     {
         CppInterface.SetParam(0, Params[0]);
         CppInterface.SetParam(1, Params[1]);
     }
     oThread = new Thread(RunThread);
     oThread.Start();
 }
Exemplo n.º 21
0
        public void NativePrimitiveTypeNotLarge()
        {
            var config = new ConfigFile
            {
                Id        = nameof(NativePrimitiveTypeNotLarge),
                Namespace = nameof(NativePrimitiveTypeNotLarge),
                Includes  =
                {
                    new IncludeRule
                    {
                        File      = "pointerSize.h",
                        Attach    = true,
                        Namespace = nameof(NativePrimitiveTypeNotLarge)
                    }
                },
                Extension =
                {
                    new DefineExtensionRule
                    {
                        Struct            = "NativePrimitiveType",
                        SizeOf            = 16,
                        IsNativePrimitive = true,
                    }
                },
                Bindings =
                {
                    new BindRule("NativePrimitive", "NativePrimitiveType")
                }
            };

            var iface = new CppInterface
            {
                Name             = "Interface",
                TotalMethodCount = 1
            };

            iface.Add(new CppMethod
            {
                Name        = "method",
                ReturnValue = new CppReturnValue
                {
                    TypeName = "NativePrimitive"
                }
            });

            var include = new CppInclude
            {
                Name = "pointerSize"
            };

            include.Add(iface);

            var module = new CppModule();

            module.Add(include);

            var(solution, _) = MapModel(module, config);

            Assert.Single(solution.EnumerateDescendants().OfType <CsInterface>());

            var csIface = solution.EnumerateDescendants().OfType <CsInterface>().First();

            Assert.Single(csIface.Methods);

            var method = csIface.Methods.First();

            Assert.False(method.IsReturnStructLarge);

            Assert.False(Logger.HasErrors);
        }
Exemplo n.º 22
0
 public void onSaveListBtn()
 {
     CppInterface.SaveList(FileTypeUI, Int32.Parse(curChennel.text), FileAddrUI);
 }
Exemplo n.º 23
0
 public void onSaveResultBtn()
 {
     CppInterface.SaveResult(FileAddrUI);
 }
Exemplo n.º 24
0
 public void ShowObj(bool val, int scale = 100)
 {
     if (menuObj == null && val == true)
     {
         initMenu();
     }
     if (obj == null && val == true)
     {
         if (type == 1)
         {
             obj = pointCloud.create(CppInterface.GetMPList(id));
         }
         if (type == 2)
         {
             obj = KFListObj.create(CppInterface.GetKFList(id), ListId).transform;
         }
         if (type == 3)
         {
             RdSegData = CppInterface.GetRSList(id);
             if (showCount > RdSegData.Count || showCount <= 0)
             {
                 showCount = RdSegData.Count;
             }
             obj = RoadMesh.create(RdSegData.GetRange(0, showCount)).transform;
         }
         if (type == 5)
         {
             ChannelInfo img     = ChannelInfo.getChannel(5, id);
             ChannelInfo feature = ChannelInfo.getChannel(4, id);
             if (img != null)
             {
                 commonObj.mMainUI.updateFrameDisplay(img, feature);
             }
         }
         if (type == 6)
         {
             List <TraficSign> tmp = CppInterface.GetTSList(id);
             if (showCount >= 0 && showCount < tmp.Count)
             {
                 tmp.RemoveRange(showCount, tmp.Count - showCount);
             }
             obj = TraficSignMesh.create(tmp).transform;
         }
         if (type == 7)
         {
             List <ActMapPoint> tmp = CppInterface.GetAMPList(id);
             obj = ActMPMesh.create(tmp);
         }
     }
     if (obj != null)
     {
         obj.gameObject.SetActive(val);
         if (val)
         {
             transform.Find("Text").GetComponent <Text> ().color = getColorFromUI();
         }
         else
         {
             transform.Find("Text").GetComponent <Text> ().color = new Color32(0, 0, 0, 255);
         }
     }
 }
Exemplo n.º 25
0
        public void DefineWithNativeImplementationDefinesNativeImplementationType()
        {
            var config = new ConfigFile
            {
                Id        = nameof(Simple),
                Namespace = nameof(Simple),
                Includes  =
                {
                    new IncludeRule
                    {
                        File      = "interface.h",
                        Attach    = true,
                        Namespace = nameof(Simple)
                    }
                },
                Extension =
                {
                    new DefineExtensionRule
                    {
                        Interface            = "Imported.Param",
                        NativeImplementation = "Imported.ParamNative"
                    }
                },
                Bindings =
                {
                    new BindRule("int",   "System.Int32"),
                    new BindRule("Param", "Imported.Param")
                }
            };

            var iface = new CppInterface
            {
                Name             = "Interface",
                TotalMethodCount = 1
            };

            var method = new CppMethod
            {
                Name        = "method",
                ReturnValue = new CppReturnValue
                {
                    TypeName = "int"
                }
            };

            method.Add(new CppParameter
            {
                Name     = "param",
                TypeName = "Param",
                Pointer  = "*"
            });

            iface.Add(method);

            var include = new CppInclude
            {
                Name = "interface"
            };

            include.Add(iface);

            var module = new CppModule();

            module.Add(include);

            var(solution, _) = MapModel(module, config);

            Assert.Single(solution.EnumerateDescendants().OfType <CsParameter>());

            var param = solution.EnumerateDescendants().OfType <CsParameter>().First();

            Assert.IsType <CsInterface>(param.PublicType);

            Assert.NotNull(((CsInterface)param.PublicType).NativeImplementation);

            Assert.False(Logger.HasErrors);
        }
Exemplo n.º 26
0
 private static async Task DocumentInterface(this IDocProvider docProvider, DocItemCache cache, CppInterface cppInterface)
 {
     await Task.WhenAll(
         cppInterface.Methods
         .Select(func => docProvider.DocumentCallable(cache, func, name: cppInterface.Name + "::" + func.Name))
         .Concat(new[] { docProvider.DocumentElement(cache, cppInterface, documentInnerElements: false) }));
 }
Exemplo n.º 27
0
 void RegisterDebugCallback()
 {
     DebugDelegate cb = CallBackFunction;
     IntPtr intptr_delegate = Marshal.GetFunctionPointerForDelegate(cb);
     CppInterface.SetDebugFuncPtr(intptr_delegate);
 }
Exemplo n.º 28
0
        public void PointerSizeReturnValueNotLarge()
        {
            var config = new Config.ConfigFile
            {
                Id        = nameof(PointerSizeReturnValueNotLarge),
                Assembly  = nameof(PointerSizeReturnValueNotLarge),
                Namespace = nameof(PointerSizeReturnValueNotLarge),
                Includes  =
                {
                    new Config.IncludeRule
                    {
                        File      = "pointerSize.h",
                        Attach    = true,
                        Namespace = nameof(PointerSizeReturnValueNotLarge)
                    }
                },
                Extension =
                {
                    new DefineExtensionRule
                    {
                        Struct = "SharpGen.Runtime.PointerSize",
                        SizeOf = 8,
                    }
                },
                Bindings =
                {
                    new Config.BindRule("int", "SharpGen.Runtime.PointerSize")
                }
            };

            var iface = new CppInterface
            {
                Name             = "Interface",
                TotalMethodCount = 1
            };

            iface.Add(new CppMethod
            {
                Name        = "method",
                ReturnValue = new CppReturnValue
                {
                    TypeName = "int"
                }
            });

            var include = new CppInclude
            {
                Name = "pointerSize"
            };

            include.Add(iface);

            var module = new CppModule();

            module.Add(include);

            var(solution, _) = MapModel(module, config);

            Assert.Single(solution.EnumerateDescendants().OfType <CsInterface>());

            var csIface = solution.EnumerateDescendants().OfType <CsInterface>().First();

            Assert.Single(csIface.Methods);

            var method = csIface.Methods.First();

            Assert.False(method.IsReturnStructLarge);
        }
Exemplo n.º 29
0
 void RunThread()
 {
     curState = UIState.running;
     CppInterface.InitAlgo(AlgoTypeUI);
     curState = UIState.idle;
 }