Beispiel #1
0
 public void LinkInstruction_IncompleteInstructionFromString_ThrowsArgumentException()
 {
     ExceptionAssert.Throws <ArgumentException>(() => LinkInstruction.FromString(""));
     ExceptionAssert.Throws <ArgumentException>(() => LinkInstruction.FromString("Link:"));
     ExceptionAssert.Throws <ArgumentException>(() => LinkInstruction.FromString("(Obj1,1,1)"));
     ExceptionAssert.Throws <ArgumentException>(() => LinkInstruction.FromString("Link:(Obj1,1,1)"));
 }
Beispiel #2
0
        public void LinkInstruction_CondensedInstructionFromString_IsCorrect()
        {
            var inst = LinkInstruction.FromString("Obj1,1,1-Obj1,1,2");

            Assert.AreEqual("Obj1", inst.Obj1.Obj);
            Assert.AreEqual(new XY(1, 1), inst.Obj1.Location);
            Assert.AreEqual("Obj1", inst.Obj2.Obj);
            Assert.AreEqual(new XY(1, 2), inst.Obj2.Location);
        }
Beispiel #3
0
        void WriteLink(LinkInstruction cmd)
        {
            //link/unlink parent box: this happens in VM first, then auto-save box
            if (cmd.Link == LinkType.FromBoxToParentBox)
            {
                if (Source is ExtBoxController sourceBlock)
                {
                    var sourceVM = sourceBlock.VM;
                    if (cmd.IsRemove)
                    {
                        sourceVM.ParentId = null;
                    }
                    else
                    {
                        sourceVM.ParentId = cmd.ToId;
                    }
                    sourceVM.IsDirty = true;
                    sourceBlock.ChangeMode(BaseController.Mode.Edit, true);

                    sourceBlock.ReloadLinks();
                }
                if (Target is ExtBoxController targetBlock)
                {
                    targetBlock.ReloadLinks();
                }
            }

            //box to child box is not handled; there should be no commands of that type
            else if (cmd.Link == LinkType.FromBoxToChildBox)
            {
            }

            else if (cmd.Link == LinkType.FromBoxToPerson)
            {
                Globals.UI.WritePersonLink(cmd);
                if (Source is ExtBoxController sourceBlock)
                {
                    sourceBlock.ReloadLinks();
                }
                if (Target is ExtPersonController targetBlock)
                {
                    targetBlock.ReloadLinks();
                }
            }

            else if (cmd.Link == LinkType.FromPersonToBox)
            {
                Globals.UI.WritePersonLink(cmd);
                if (Source is ExtPersonController sourceBlock)
                {
                    sourceBlock.ReloadLinks();
                }
                if (Target is ExtBoxController targetBlock)
                {
                    targetBlock.ReloadLinks();
                }
            }

            else if (cmd.Link == LinkType.FromPersonToPerson)
            {
                Globals.UI.WritePersonLink(cmd);
                if (Source is ExtPersonController sourceBlock && Target is ExtPersonController targetBlock)
                {
                    sourceBlock.ReloadLinks();
                    targetBlock.ReloadLinks();
                }
            }
        }
Beispiel #4
-1
        /*
         * Given:
         *   A Link instruction- a single instruction that has been parsed before, and a CustomComponent that has this link instruction
         * Output:
         *   A Component that can be used to generate a project for this .dll
         *  Note that we want to point to source files (.c, .h) instead of linking against things that are not in our current project.
         * */
        public static Component resolveLinkInstruction(LinkInstruction linkInstr, CustomComponent rule, Makefile mkfile)
        {
            Component component = new Component(mkfile);
            string componentName = "";
            componentName = rule.Name;
            component.setName(componentName);
            linkInstr.convertToLink(mkfile, component);

            //If the link instruction shares objs with the makefile's, then use its cflags. Otherwise, we assume that the link instruction has an accompanying compile instruction somewhere
            if (rule.contextSensitiveProps.Contains("OBJ_LIST_C_OBJS"))
            {
                component.CompilerFlags = new CompileFlags(mkfile);
                component.CompilerFlags.ParseString(mkfile.ResolveVariables(mkfile.CompilerFlagsStr, Makefile.VarType.RegularVariable | Makefile.VarType.PropSheetVariable, false));
            }

            string extension = Path.GetExtension(rule.Output).Replace(".", "");
            component.Type = extension;
            component.IsCustomLinkStep = true;

            return component;
        }
Beispiel #5
-1
        /*
         * Given:
         *   A CustomComponent that creates a .dll. This CustomComponent should have a link instruction.
         * Output:
         *   A Component that can be used to generate a project for this .dll
         *
         * */
        public static Component generateComponentFromRule(CustomComponent rule, Makefile mkfile)
        {
            Component result = new Component(rule.Name);
            result.Owner = mkfile;
            List<CustomInstruction> preBuildInstrs = new List<CustomInstruction>();
            List<CustomInstruction> postBuildInstrs = new List<CustomInstruction>();

            bool afterLinkInstruction = false;

            foreach (string instr in rule.CustomInstructions)
            {
                CustomInstruction cinstr = new CustomInstruction(instr);
                if (cinstr.isNmake())
                {
                    LinkInstruction linkInstr = new LinkInstruction(cinstr);
                    result = resolveLinkInstruction(linkInstr,rule,mkfile);
                    afterLinkInstruction = true;
                }
                else if (cinstr.isCl())
                {
                    ClInstruction compileInstruction = new ClInstruction(cinstr);
                    foreach (string sourceFile in compileInstruction.clFiles)
                        result.SourceFileNames.Add(sourceFile);

                }
                else if (!afterLinkInstruction)
                {
                    preBuildInstrs.Add(cinstr);
                }
                else
                {
                    postBuildInstrs.Add(cinstr);
                }

            }
            result.PreBuildInstructions = preBuildInstrs;
            result.PostBuildInstructions = postBuildInstrs;
            return result;
        }