Пример #1
0
            private string ObjectName(bool canheader)
            {
                if (d_wrapper != null)
                {
                    return(d_wrapper.Id);
                }
                else if (d_object != null)
                {
                    Cdn.Variable prop = d_object as Cdn.Variable;

                    if (prop != null)
                    {
                        return(prop.Name);
                    }

                    Cdn.EdgeAction action = d_object as Cdn.EdgeAction;

                    if (action != null)
                    {
                        return(action.Target);
                    }
                }

                if (canheader)
                {
                    return(HeaderName);
                }
                else
                {
                    return(null);
                }
            }
Пример #2
0
        public Cdn.Edge GetActionTemplate(Cdn.EdgeAction action, bool match_full)
        {
            IntPtr raw_ret = cdn_edge_get_action_template(Handle, action == null ? IntPtr.Zero : action.Handle, match_full);

            Cdn.Edge ret = GLib.Object.GetObject(raw_ret) as Cdn.Edge;
            return(ret);
        }
Пример #3
0
        public bool Equal(Cdn.EdgeAction other)
        {
            bool raw_ret = cdn_edge_action_equal(Handle, other == null ? IntPtr.Zero : other.Handle);
            bool ret     = raw_ret;

            return(ret);
        }
Пример #4
0
        public Cdn.EdgeAction Copy()
        {
            IntPtr raw_ret = cdn_edge_action_copy(Handle);

            Cdn.EdgeAction ret = GLib.Object.GetObject(raw_ret, true) as Cdn.EdgeAction;
            return(ret);
        }
Пример #5
0
        public bool RemoveAction(Cdn.EdgeAction action)
        {
            bool raw_ret = cdn_edge_remove_action(Handle, action == null ? IntPtr.Zero : action.Handle);
            bool ret     = raw_ret;

            return(ret);
        }
Пример #6
0
        public Cdn.EdgeAction GetAction(string target)
        {
            IntPtr native_target = GLib.Marshaller.StringToPtrGStrdup(target);
            IntPtr raw_ret       = cdn_edge_get_action(Handle, native_target);

            Cdn.EdgeAction ret = GLib.Object.GetObject(raw_ret) as Cdn.EdgeAction;
            GLib.Marshaller.Free(native_target);
            return(ret);
        }
Пример #7
0
        public Cdn.EdgeAction GetActionWithIndexAndPhases(string target, Cdn.Expression index, GLib.SList phases)
        {
            IntPtr native_target = GLib.Marshaller.StringToPtrGStrdup(target);
            IntPtr raw_ret       = cdn_edge_get_action_with_index_and_phases(Handle, native_target, index == null ? IntPtr.Zero : index.Handle, phases == null ? IntPtr.Zero : phases.Handle);

            Cdn.EdgeAction ret = GLib.Object.GetObject(raw_ret) as Cdn.EdgeAction;
            GLib.Marshaller.Free(native_target);
            return(ret);
        }
Пример #8
0
        private void AddEdgeAction(Cdn.EdgeAction action)
        {
            TreeIter iter;

            d_treeview.NodeStore.Add(new Node(action), out iter);

            if (d_selectAction)
            {
                d_treeview.Selection.UnselectAll();
                d_treeview.Selection.SelectIter(iter);
            }
        }
Пример #9
0
        public Cdn.EdgeAction AddAction(string target, Cdn.Expression expression)
        {
            Cdn.EdgeAction action = new Cdn.EdgeAction(target, expression);

            if (AddAction(action))
            {
                return(action);
            }
            else
            {
                return(null);
            }
        }
Пример #10
0
        private string SliceKey(Cdn.EdgeAction action)
        {
            var indices = action.Indices;

            if (indices == null)
            {
                return("");
            }
            else
            {
                return(String.Join(",", Array.ConvertAll <int, string>(indices, a => a.ToString())));
            }
        }
Пример #11
0
 protected virtual void OnActionRemoved(Cdn.EdgeAction action)
 {
     GLib.Value      ret             = GLib.Value.Empty;
     GLib.ValueArray inst_and_params = new GLib.ValueArray(2);
     GLib.Value[]    vals            = new GLib.Value [2];
     vals [0] = new GLib.Value(this);
     inst_and_params.Append(vals [0]);
     vals [1] = new GLib.Value(action);
     inst_and_params.Append(vals [1]);
     g_signal_chain_from_overridden(inst_and_params.ArrayPtr, ref ret);
     foreach (GLib.Value v in vals)
     {
         v.Dispose();
     }
 }
Пример #12
0
 public Wrappers.Edge GetActionTemplate(Cdn.EdgeAction action, bool match_full)
 {
     return((Wrappers.Edge)Wrapper.Wrap(WrappedObject.GetActionTemplate(action, match_full)));
 }
Пример #13
0
 public EventActionState(Cdn.EdgeAction action, Cdn.Variable v) : base(v, action.Equation, State.Flags.EventAction | (action.TargetVariable.HasFlag(VariableFlags.Integrated) ? State.Flags.Derivative : 0))
 {
     d_action   = action;
     d_variable = v;
 }
Пример #14
0
 public bool AddAction(Cdn.EdgeAction action)
 {
     return(WrappedObject.AddAction(action));
 }
Пример #15
0
 public bool RemoveAction(Cdn.EdgeAction action)
 {
     return(WrappedObject.RemoveAction(action));
 }
Пример #16
0
 public void Select(Cdn.EdgeAction action)
 {
     /* TODO */
 }
Пример #17
0
 private void HandleEdgeActionRemoved(object source, Cdn.EdgeAction action)
 {
     d_treeview.NodeStore.Remove(action);
 }
Пример #18
0
 public RemoveEdgeAction(Wrappers.Edge link, Cdn.EdgeAction action) : base(link, action.Target, action.Equation.AsString)
 {
 }
Пример #19
0
 private void HandleEdgeActionAdded(object source, Cdn.EdgeAction action)
 {
     d_treeview.NodeStore.Remove(d_dummy);
     AddEdgeAction(action);
     d_treeview.NodeStore.Add(d_dummy);
 }
Пример #20
0
		public void Set(IntPtr gerror, Cdn.Object objekt, Cdn.Variable property, Cdn.EdgeAction action, Cdn.Expression expression) {
			cdn_compile_error_set(Handle, gerror, objekt == null ? IntPtr.Zero : objekt.Handle, property == null ? IntPtr.Zero : property.Handle, action == null ? IntPtr.Zero : action.Handle, expression == null ? IntPtr.Zero : expression.Handle);
		}
Пример #21
0
        private void PromoteEdgeSlices()
        {
            // This function splits all the edge actions on variables based
            // on the slice on which the operate on the target variable.
            var cp = d_actionedVariables;

            d_actionedVariables = new Dictionary <Variable, EdgeAction[]>();

            foreach (var pair in cp)
            {
                var variable = pair.Key;
                var actions  = pair.Value;

                var split = SplitActionsPerSlice(actions);

                if (split.Count == 1)
                {
                    // That's ok, no diversity means we can just use the
                    // normal code path
                    d_actionedVariables[pair.Key] = pair.Value;
                    continue;
                }

                // Contains a set of instructions for each value in the matrix
                // representing the final, new equation. Each value in the matrix
                // is a set of instructions because it can be a sum
                List <Cdn.Instruction>[] instructions = new List <Instruction> [variable.Dimension.Size()];

                // Ai! Cool stuff needs to happen here. Split out new
                // variables for these equations and setup a new edge action
                // representing the fully combined set. Complex you say? Indeed!
                foreach (var elem in split)
                {
                    // Combine elements with the same indices by simply doing a sum
                    var            eqs = Array.ConvertAll <Cdn.EdgeAction, Cdn.Expression>(elem.ToArray(), a => a.Equation);
                    Cdn.Expression sum = Cdn.Expression.Sum(eqs);

                    // Now make a variable for it
                    var nv = new Cdn.Variable(UniqueVariableName(variable.Object, String.Format("__d{0}", variable.Name)), sum, VariableFlags.None);
                    variable.Object.AddVariable(nv);

                    // Add relevant instructions as per slice
                    var slice = elem[0].Indices;

                    if (slice == null || slice.Length == 0)
                    {
                        // Empty slice is just the full range
                        slice = new int[variable.Dimension.Size()];

                        for (int i = 0; i < slice.Length; ++i)
                        {
                            slice[i] = i;
                        }
                    }

                    for (int i = 0; i < slice.Length; ++i)
                    {
                        if (instructions[slice[i]] == null)
                        {
                            instructions[slice[i]] = new List <Instruction>();
                        }

                        var vinstr = new Cdn.InstructionVariable(nv);

                        vinstr.SetSlice(new int[] { i }, new Cdn.Dimension {
                            Rows = 1, Columns = 1
                        });
                        instructions[slice[i]].Add(vinstr);
                    }
                }

                List <Cdn.Instruction> ret = new List <Instruction>();

                // Create substitute edge action
                foreach (var i in instructions)
                {
                    if (i == null)
                    {
                        ret.Add(new Cdn.InstructionNumber("0"));
                    }
                    else
                    {
                        // Add indexing instructions
                        ret.AddRange(i);

                        // Then add simple plus operators
                        for (int j = 0; j < i.Count - 1; ++j)
                        {
                            ret.Add(new Cdn.InstructionFunction((uint)Cdn.MathFunctionType.Plus, null, 2));
                        }
                    }
                }

                var minstr = new Cdn.InstructionMatrix(new Cdn.StackArgs(instructions.Length), variable.Dimension);
                ret.Add(minstr);

                var retex = new Cdn.Expression("");
                retex.SetInstructionsTake(ret.ToArray());

                var action = new Cdn.EdgeAction(variable.Name, retex);
                ((Cdn.Node)variable.Object).SelfEdge.AddAction(action);

                d_actionedVariables[variable] = new EdgeAction[] { action };
            }
        }
Пример #22
0
 public WrapperNode(Widget widget, Cdn.EdgeAction action) : this(widget, null, action)
 {
 }