Esempio n. 1
0
        public string GetVtxShader(int ProgramIndex, bool HasGeoShader, out ShaderNameBlock Names)
        {
            ShaderProgram Program = SHBin.Programs[ProgramIndex];

            Initialize(Program);

            StringBuilder Output = new StringBuilder();

            Output.AppendLine("//SPICA auto-generated code");
            Output.AppendLine("//This code was translated from a MAESTRO Vertex Shader");
            Output.AppendLine("#version 330 core");

            Output.AppendLine();

            GenVec4Uniforms(Output, Program.Vec4Uniforms);
            GenIVec4Uniforms(Output, Program.IVec4Uniforms);
            GenBoolUniforms(Output, Program.BoolUniforms);

            Output.AppendLine();

            Output.AppendLine($"vec4 {TempRegName}[16];");
            Output.AppendLine($"bvec2 {CmpRegName};");
            Output.AppendLine($"ivec2 {A0RegName};");
            Output.AppendLine($"int {ALRegName};");

            Output.AppendLine();

            for (int i = 0; i < Program.InputRegs.Length; i++)
            {
                string Name = Program.InputRegs[i];

                if (Name != null)
                {
                    Name = $"i_{i}_{GetValidName(Name)}";

                    InputNames[i] = Name;

                    Output.AppendLine($"layout(location = {i}) in vec4 {Name};");
                }
            }

            Output.AppendLine();

            GenOutputs(Output, Program.OutputRegs, HasGeoShader ? "_" : string.Empty);

            int FuncStart = Output.Length;

            while (Procs.Count > 0)
            {
                SB = new StringBuilder(Environment.NewLine);

                GenProc(Program, Procs.Dequeue());

                Output.Insert(FuncStart, SB.ToString());
            }

            Names = GetNameBlock();

            return(Output.ToString());
        }
        }         // proc UnregisterList

        #endregion

        #region -- Controller Http ----------------------------------------------------

        private XElement GetControllerXmlNode(string sId, object item)
        {
            if (item is IDEListController configController)
            {
                var x = new XElement("list",
                                     new XAttribute("id", configController.Id),
                                     Procs.XAttributeCreate("displayname", configController.DisplayName)
                                     );

                if (configController.List is IList indexAccess)
                {
                    x.Add(new XAttribute("count", indexAccess.Count));
                }

                return(x);
            }
            else if (item is DEConfigItemPublicAction configAction)
            {
                var x = new XElement("action",
                                     new XAttribute("id", configAction.ActionId),
                                     Procs.XAttributeCreate("displayname", configAction.DisplayName)
                                     );
                return(x);
            }
            else
            {
                return(null);
            }
        }         // func GetControllerXmlNode
Esempio n. 3
0
            }             // proc Dispose

            protected virtual void Dispose(bool disposing)
            {
                if (disposing)
                {
                    Procs.FreeAndNil(ref stream);
                }
            }             // prop Dispsoe
Esempio n. 4
0
        private bool ChangeConfigurationValue(ParseContext context, XObject x, string currentValue, out string newValue)
        {
            var valueModified = ChangeConfigurationStringValue(context, currentValue, out newValue);

            // first check for type converter
            var attributeDefinition = GetAttribute(x);

            if (attributeDefinition != null)
            {
                if (attributeDefinition.TypeName == "PathType")
                {
                    newValue = ProcsDE.GetFileName(x, newValue);

                    valueModified |= true;
                }
                else if (attributeDefinition.TypeName == "PathArray")
                {
                    newValue = Procs.JoinPaths(Procs.SplitPaths(newValue).Select(c => ProcsDE.GetFileName(x, c)));

                    valueModified |= true;
                }
                else if (attributeDefinition.TypeName == "CertificateType")
                {
                    if (String.IsNullOrEmpty(newValue) || !newValue.StartsWith("store://"))
                    {
                        newValue       = ProcsDE.GetFileName(x, newValue);
                        valueModified |= true;
                    }
                }
            }

            return(valueModified);
        }         // func ChangeConfigurationValue
Esempio n. 5
0
        }         // proc ParseConfiguration

        private void IncludeConfigTree(ParseContext context, XProcessingInstruction xPI)
        {
            if (xPI.Parent == null)
            {
                throw context.CreateConfigException(xPI, "It is not allowed to include to a root element.");
            }

            var xInc = context.LoadFile(xPI, xPI.Data).Root;

            if (xInc.Name == DEConfigurationConstants.xnInclude)
            {
                XNode xLast = xPI;

                // Copy the baseuri annotation
                var copy = new List <XElement>();
                foreach (var xSrc in xInc.Elements())
                {
                    Procs.XCopyAnnotations(xSrc, xSrc);
                    copy.Add(xSrc);
                }

                // Remove all elements from the source, that not get internal copied.
                xInc.RemoveAll();
                xPI.AddAfterSelf(copy);
            }
            else
            {
                Procs.XCopyAnnotations(xInc, xInc);
                xInc.Remove();
                xPI.AddAfterSelf(xInc);
            }
        }         // proc IncludeConfigTree
Esempio n. 6
0
        }         // proc WriteXml

        public static void WriteObject(this IDEContext context, object value, string contentType = null)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            else if (value is XElement)
            {
                WriteXml(context, (XElement)value, contentType ?? MimeTypes.Text.Xml);
            }
            else if (value is XDocument)
            {
                WriteXml(context, (XDocument)value, contentType ?? MimeTypes.Text.Xml);
            }
            else if (value is string)
            {
                WriteText(context, (string)value, contentType ?? MimeTypes.Text.Plain);
            }
            else if (value is Stream)
            {
                WriteStream(context, (Stream)value, contentType ?? MimeTypes.Application.OctetStream);
            }
            else if (value is byte[])
            {
                WriteBytes(context, (byte[])value, contentType ?? MimeTypes.Application.OctetStream);
            }
            else if (value is LuaTable)
            {
                WriteXml(context, new XDocument(Procs.ToXml((LuaTable)value)));
            }
            else
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest, String.Format("Can not send return value of type '{0}'.", value.GetType().FullName));
            }
        }         // proc WriteObject
Esempio n. 7
0
        }         // proc SumArray

        /// <summary>Vergleicht die zwei Schranken miteinander.</summary>
        /// <param name="o">Vergleichswert</param>
        /// <returns><c>true</c>, wenn die Schranken exakt gleich sind.</returns>
        public bool CompareTo(ref CronBound o)
        {
            return(Procs.CompareBytes(days, o.days) &&
                   Procs.CompareBytes(weekDays, o.weekDays) &&
                   Procs.CompareBytes(hours, o.hours) &&
                   Procs.CompareBytes(minutes, o.minutes));
        }         // func CompareTo
Esempio n. 8
0
            }             // proc Load

            private Task SaveAsync()
            {
                var xState = new XElement("state",
                                          Procs.XAttributeCreate("v", state)
                                          );

                if (accountKey != null)
                {
                    xState.Add(new XElement("account", new XCData(accountKey)));
                }

                switch (state)
                {
                case AcmeState.Pending:
                    xState.Add(new XElement("order", orderUri?.ToString()));
                    xState.Add(new XElement("token", token));
                    xState.Add(new XElement("authz", keyAuthz));
                    break;

                case AcmeState.Installed:
                case AcmeState.Issued:
                    if (pfxContent != null)
                    {
                        xState.Add(new XElement("pfx", Convert.ToBase64String(pfxContent)));
                    }
                    break;
                }

                return(Task.Run(() => xState.Save(fileName)));
            }             // proc SaveAsync
Esempio n. 9
0
        }         // ctor

        /// <summary>Add a meta info value.</summary>
        /// <param name="key">Meta key.</param>
        /// <param name="getDataType">Data type of the value.</param>
        /// <param name="value">Unconverted value of the meta key.</param>
        protected void Add(string key, Func <Type> getDataType, object value)
        {
            if (String.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key");
            }

            if (value == null)
            {
                metaInfo.Remove(key);
            }
            else
            {
                // change the type
                if (WellknownMetaTypes.TryGetValue(key, out var dataType))
                {
                    value = Procs.ChangeType(value, dataType);
                }
                else if (getDataType != null)
                {
                    value = Procs.ChangeType(value, getDataType());
                }

                // add the key
                if (value == null)
                {
                    metaInfo.Remove(key);
                }
                else
                {
                    metaInfo[key] = value;
                }
            }
        }         // proc Add
Esempio n. 10
0
        /// <summary>Parse tag, return from sqlite db.</summary>
        /// <param name="attributeLine"></param>
        /// <returns></returns>
        public static PpsObjectTag ParseTag(string attributeLine)
        {
            // name:class=value
            // e.g.: key:0=text

            var m = regAttributeLine.Match(attributeLine);

            if (!m.Success)
            {
                throw new FormatException("Attribute line does not match format.");
            }

            var    classHint = (PpsObjectTagClass)(String.IsNullOrEmpty(m.Groups["c"].Value) ? 0 : Int32.Parse(m.Groups["c"].Value));
            object value;

            if (classHint == PpsObjectTagClass.Deleted)
            {
                value = null;
            }
            else
            {
                var dataType = GetTypeFromClass(classHint);
                value = Procs.UnescapeSpecialChars(m.Groups["v"].Value);
                if (value != null)
                {
                    value = Procs.ChangeType(value, dataType);
                }
            }

            return(new PpsObjectTag(m.Groups["n"].Value, classHint, value));
        }         // func ParseTag
Esempio n. 11
0
            }             // func TruncateAsync

            #endregion

            #region -- Commit/Transmission State --------------------------------------

            public async Task CommitFileAsync(long recordCount, long unitCount)
            {
                if (readOnly)
                {
                    throw new InvalidOperationException();
                }

                // validate file size
                if (RecordCount != recordCount)
                {
                    throw new OdetteFileServiceException(OdetteAnswerReason.InvalidRecordCount, String.Format("Invalid record count (local: {0}, endpoint: {1}).", RecordCount, recordCount));
                }
                if (TotalLength != unitCount)
                {
                    throw new OdetteFileServiceException(OdetteAnswerReason.InvalidByteCount, String.Format("Invalid record count (local: {0}, endpoint: {1}).", TotalLength, unitCount));
                }

                // close the stream
                Procs.FreeAndNil(ref stream);

                // rename file to show that it is received
                await ChangeInFileStateAsync(fileItem.FileInfo, OdetteInFileState.Received);

                // notify that the file is received
                await fileItem.NotifyFileReceivedAsync();
            }             // proc CommitFileAsync
        }         // func GetExcelReportItems

        private static XElement CreateParameterInfo(XName n, PpsViewParameterDefinition def)
        {
            return(new XElement(n,
                                new XAttribute("name", def.Name),
                                Procs.XAttributeCreate("displayName", def.DisplayName, null)
                                ));
        }         // func CreateParameterInfo
 private static XElement CreateJoinInfo(PpsViewJoinDefinition def)
 {
     return(new XElement("join",
                         new XAttribute("view", def.ViewName),
                         Procs.XAttributeCreate("alias", def.AliasName, null),
                         Procs.XAttributeCreate("type", def.Type, PPSn.Data.PpsDataJoinType.Inner)
                         ));
 }         // func CreateJoinInfo
Esempio n. 14
0
        /// <summary></summary>
        /// <param name="xTag"></param>
        /// <returns></returns>
        public static PpsObjectTag FromXml(XElement xTag)
        {
            var key      = xTag.GetAttribute("key", null);
            var tagClass = xTag.GetAttribute("tagClass", PpsObjectTagClass.Text);
            var value    = Procs.ChangeType(xTag.GetAttribute("value", null), PpsObjectTag.GetTypeFromClass(tagClass));

            return(new PpsObjectTag(key, tagClass, value));
        } // func FromXml
Esempio n. 15
0
        }         // func GetPaneType

        /// <summary>Get default open pane mode</summary>
        /// <param name="paneManager">Pane manager to use.</param>
        /// <param name="arguments"></param>
        /// <returns></returns>
        public static PpsOpenPaneMode GetDefaultPaneMode(this IPpsWindowPaneManager paneManager, dynamic arguments)
        {
            if (arguments != null && arguments.Mode != null)
            {
                return(Procs.ChangeType <PpsOpenPaneMode>(arguments.Mode));
            }

            return(paneManager.Shell.GetOptionalValue("NewPaneMode", true) ? PpsOpenPaneMode.NewPane : PpsOpenPaneMode.ReplacePane);
        }         // func GetDefaultPaneMode
Esempio n. 16
0
        }         // proc WriteElementProperty

        /// <summary>Write a complete attribute.</summary>
        /// <param name="propertyName"></param>
        /// <param name="_value"></param>
        public void WriteAttributeProperty(string propertyName, object _value)
        {
            var value = _value.ChangeType <string>();

            if (value != null)
            {
                xml.WriteAttributeString(propertyName, Procs.RemoveInvalidXmlChars(value, '?'));
            }
        }         // proc WriteAttributeProperty
Esempio n. 17
0
        }         // ctor

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Procs.FreeAndNil(ref logFile);
                ConfigLogItemCount--;
            }
            base.Dispose(disposing);
        }         // proc Disposing
Esempio n. 18
0
 public void XmlRemoveInvalidChars()
 {
     Assert.AreEqual(Procs.RemoveInvalidXmlChars(null), null);
     Assert.AreEqual(Procs.RemoveInvalidXmlChars(String.Empty), String.Empty);
     Assert.AreEqual(Procs.RemoveInvalidXmlChars("String.Empty"), "String.Empty");
     Assert.AreEqual(XmlConvert.VerifyXmlChars(Procs.RemoveInvalidXmlChars("String\x1A.Empty")), "String.Empty");
     Assert.AreEqual(XmlConvert.VerifyXmlChars(Procs.RemoveInvalidXmlChars("\x001AEmp\x001Aty\x001A")), "Empty");
     Assert.AreEqual(XmlConvert.VerifyXmlChars(Procs.RemoveInvalidXmlChars("String\x001AEmp\x10000ty")), "StringEmp\x10000ty");
 }
Esempio n. 19
0
        }         // proc MergeConfigTree

        private void MergeConfigTree(XElement xRoot, XElement xMerge)
        {
            // merge attributes
            var attributeMerge = xMerge.FirstAttribute;

            while (attributeMerge != null)
            {
                var attributeRoot = xRoot.Attribute(attributeMerge.Name);
                if (attributeRoot == null)                 // attribute does not exists --> insert
                {
                    xRoot.SetAttributeValue(attributeMerge.Name, attributeMerge.Value);
                }
                else                 // attribute exists --> override or combine lists
                {
                    var attributeDefinition = GetAttribute(attributeMerge);
                    if (attributeDefinition != null)
                    {
                        if (attributeDefinition.IsList)                         // list detected
                        {
                            attributeRoot.Value = attributeRoot.Value + " " + attributeMerge.Value;
                        }
                        else
                        {
                            attributeRoot.Value = attributeMerge.Value;
                        }
                    }
                }

                attributeMerge = attributeMerge.NextAttribute;
            }

            // merge elements
            var xCurNodeMerge = xMerge.FirstNode;

            while (xCurNodeMerge != null)
            {
                var xCurMerge = xCurNodeMerge as XElement;
                var xNextNode = xCurNodeMerge.NextNode;

                if (xCurMerge != null)
                {
                    var xCurRoot = FindConfigTreeElement(xRoot, xCurMerge);
                    if (xCurRoot == null)                     // node is not present -> include
                    {
                        Procs.XCopyAnnotations(xCurMerge, xCurMerge);
                        xCurMerge.Remove();
                        xRoot.Add(xCurMerge);
                    }
                    else                     // merge node
                    {
                        MergeConfigTree(xCurRoot, xCurMerge);
                    }
                }

                xCurNodeMerge = xNextNode;
            }
        }         // proc MergeConfigTree
Esempio n. 20
0
        }         // ctor

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Procs.FreeAndNil(ref currentListener);
            }

            base.Dispose(disposing);
        }         // proc Dispose
Esempio n. 21
0
        }         // proc ProcessReceiveLine

        private void ProcessExited(object state, bool timeout)
        {
            if (!NativeMethods.GetExitCodeProcess(exitWaitHandle.SafeWaitHandle, out var exitCode))
            {
                exitCode = UInt32.MaxValue;
            }

            try
            {
                Log.LogMsg(LogMsgType.Information, "Process closed (ExitCode={0})", unchecked ((int)exitCode));

                if (this["ProcessStopped"] != null)
                {
                    CallMemberDirect("ProcessStopped", new object[] { (Process)state }, throwExceptions: false);
                }

                HttpRefreshProperties();
            }
            finally
            {
                Procs.FreeAndNil(ref exitWaitHandle);
                waitHandle = null;

                try
                {
                    if (hUser != IntPtr.Zero)
                    {
                        Debug.Print("UnloadProfile={0}", NativeMethods.UnloadUserProfile(hUser, hProfile));
                        Debug.Print("CloseUserHandle={0}", NativeMethods.CloseHandle(hUser));
                    }

                    if (arOutputStream != null)
                    {
                        procProcessLogLine.EndInvoke(arOutputStream);
                    }
                    if (arErrorStream != null)
                    {
                        procProcessLogLine.EndInvoke(arErrorStream);
                    }

                    arOutputStream = null;
                    arErrorStream  = null;

                    Procs.FreeAndNil(ref inputStream);
                    Procs.FreeAndNil(ref outputStream);
                    Procs.FreeAndNil(ref errorStream);
                }
                finally
                {
                    waitForExitEvent.Set();
                    Procs.FreeAndNil(ref waitForExitEvent);

                    process = null;
                }
            }
        }         // proc ProcessExited
Esempio n. 22
0
        }         // ctor

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Procs.FreeAndNil(ref propertyNextRun);
                Procs.FreeAndNil(ref propertyLastTime);
                Procs.FreeAndNil(ref propertyIsRunning);
            }
            base.Dispose(disposing);
        }         // proc Dispose
Esempio n. 23
0
        }         // func UpdateAsync

        private IEnumerable <PpsColumnInfo> ParseColumnInfo(string value)
        {
            foreach (var(startAt, len) in Procs.SplitNewLinesTokens(value))
            {
                if (len > 0)
                {
                    yield return(new PpsColumnInfo(value, startAt, len));
                }
            }
        }         // func ParseColumnInfo
Esempio n. 24
0
        }         // func TryLocalToUnc

        /// <summary>Translate a remote path to an unc path.</summary>
        /// <param name="uncPath"></param>
        /// <param name="localPath"></param>
        /// <returns></returns>
        public static bool TryUncToLocal(string uncPath, out string localPath)
        {
            lock (shares)
            {
                if (Procs.TrySplitUncPath(uncPath, out var serverName, out var shareName, out var sharePath) &&
                    String.Compare(serverName, Environment.MachineName, StringComparison.OrdinalIgnoreCase) == 0 &&
                    shares.Value.TryGetValue(shareName, out var share))
                {
                    localPath = share.Path + sharePath;
                    return(true);
                }
Esempio n. 25
0
        static SKDrawable()
        {
            delegates = new Procs {
                fDraw               = DrawInternal,
                fGetBounds          = GetBoundsInternal,
                fNewPictureSnapshot = NewPictureSnapshotInternal,
                fDestroy            = DestroyInternal,
            };

            SkiaApi.sk_manageddrawable_set_procs(delegates);
        }
Esempio n. 26
0
        }         // proc Dispose

        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                // Liste wieder austragen
                configItem.UnregisterList(this);

                // Sperren zerstören
                Procs.FreeAndNil(ref listLock);
            }
        }         // proc Dispose
Esempio n. 27
0
        static SKAbstractManagedWStream()
        {
            delegates = new Procs {
                fWrite        = WriteInternal,
                fFlush        = FlushInternal,
                fBytesWritten = BytesWrittenInternal,
                fDestroy      = DestroyInternal,
            };

            SkiaApi.sk_managedwstream_set_procs(delegates);
        }
Esempio n. 28
0
            }             // proc Dispose

            #endregion

            #region -- Compile --------------------------------------------------------------

            protected virtual void Compile(Func <TextReader> open, KeyValuePair <string, Type>[] args)
            {
                lock (chunkLock)
                {
                    // clear the current chunk
                    Procs.FreeAndNil(ref chunk);

                    // recompile the script
                    using (var tr = open())
                        chunk = Lua.CompileChunk(tr, scriptId, compiledWithDebugger ? engine.debugOptions : null, args);
                }
            }             // proc Compile
Esempio n. 29
0
        public static void RunCommand(string cmd, string[] argArray)
        {
            var ti = typeof(Program).GetTypeInfo();

            var mi = (from c in ti.GetRuntimeMethods()
                      let attr = c.GetCustomAttribute <InteractiveCommandAttribute>()
                                 where c.IsStatic && attr != null && (String.Compare(attr.Name, cmd, StringComparison.OrdinalIgnoreCase) == 0 || String.Compare(attr.Short, cmd, StringComparison.OrdinalIgnoreCase) == 0)
                                 select c).FirstOrDefault();

            if (mi == null)
            {
                throw new Exception($"Command '{cmd}' not found.");
            }


            var parameterInfo = mi.GetParameters();
            var parameters    = new object[parameterInfo.Length];

            if (parameterInfo.Length > 0)             // bind arguments
            {
                for (var i = 0; i < parameterInfo.Length; i++)
                {
                    if (i < argArray.Length)                     // convert argument
                    {
                        parameters[i] = Procs.ChangeType(argArray[i], parameterInfo[i].ParameterType);
                    }
                    else
                    {
                        parameters[i] = parameterInfo[i].DefaultValue;
                    }
                }
            }

            // execute command
            object r;

            if (mi.ReturnType == typeof(Task))             // async
            {
                var t = (Task)mi.Invoke(null, parameters);
                t.Wait();
                r = null;
            }
            else
            {
                r = mi.Invoke(null, parameters);
            }

            if (r != null)
            {
                view.WriteObject(r);
            }
        }         // proc RunCommand
Esempio n. 30
0
File: Stuff.cs Progetto: s72785/des
        public void XmlSplitPaths()
        {
            var t = Procs.SplitPaths("a b c").ToArray();

            Assert.AreEqual("a", t[0]);
            Assert.AreEqual("b", t[1]);
            Assert.AreEqual("c", t[2]);

            t = Procs.SplitPaths("a \"b\" \"c\\\"").ToArray();
            Assert.AreEqual("a", t[0]);
            Assert.AreEqual("b", t[1]);
            Assert.AreEqual("c\\", t[2]);
        }