static void ParseDelegate(XPathNavigator node) { SpecDelegate result = new SpecDelegate(); result.Parameters = new List <SpecField> (); XPathNavigator nameNode = node.SelectSingleNode("name"); result.Name = result.MapName = nameNode.InnerXml; GetSpecType(result.Name).TypeObject = result; delegateMap.Add(result.Name, result); // move to name tag var child = node.CreateNavigator(); child.MoveToFirstChild(); var returnType = Regex.Match(child.Value, @"typedef (\w*)", RegexOptions.CultureInvariant); result.Return = GetSpecType(returnType.Groups[1].Value); result.ReturnIsPointer = Regex.IsMatch(child.Value, @"typedef (\w*)\s*\*", RegexOptions.CultureInvariant); foreach (XPathNavigator item in node.Select("type")) { var paramType = item.Value; item.MoveToNext(XPathNodeType.Text); var raw = Regex.Match(item.Value, @"\s*(\*)?\s*(\w+)", RegexOptions.CultureInvariant); var paramName = raw.Groups[2].Value; var paramIsPointer = raw.Groups[1].Success; result.Parameters.Add(new SpecField() { Type = GetSpecType(paramType), Name = paramName, MapName = paramName, IsPointer = paramIsPointer, }); } }
protected void WriteDelegate(SpecDelegate info) { var type = info.IsReturnVoid ? "void" : info.Return.FinalTypeName(); #line default #line hidden #line 9 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\DelegateTemplete.tt" this.Write("/// <summary>"); #line default #line hidden #line 10 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\DelegateTemplete.tt" this.Write(this.ToStringHelper.ToStringWithCulture(info.DebugLog())); #line default #line hidden #line 10 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\DelegateTemplete.tt" this.Write("</summary>\r\n[SuppressUnmanagedCodeSecurity, UnmanagedFunctionPointer(CallingConve" + "ntion.Winapi)]\r\npublic unsafe delegate "); #line default #line hidden #line 12 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\DelegateTemplete.tt" this.Write(this.ToStringHelper.ToStringWithCulture(type)); #line default #line hidden #line 12 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\DelegateTemplete.tt" this.Write(" "); #line default #line hidden #line 12 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\DelegateTemplete.tt" this.Write(this.ToStringHelper.ToStringWithCulture(info.MapName)); #line default #line hidden #line 12 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\DelegateTemplete.tt" this.Write(" ("); #line default #line hidden #line 12 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\DelegateTemplete.tt" WriteParameters2(info.Parameters); #line default #line hidden #line 12 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\DelegateTemplete.tt" this.Write(");\r\n"); #line default #line hidden #line 13 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\DelegateTemplete.tt" }