| Revision | 03a51f4c733b787e09faae85a0a1a1d930a265e0 (tree) |
|---|---|
| Time | 2015-12-07 01:03:37 |
| Author | TENMYO Masakazu <tenmyo@gmai...> |
| Commiter | TENMYO Masakazu |
コンテキストのチェックまで。
TODO: 排他定義の有効化(排他制御されている部分を指定したら出力フィルタ)
TODO: 出力改善
| @@ -0,0 +1,13 @@ | ||
| 1 | +The zlib/libpng License (Zlib) | |
| 2 | + | |
| 3 | +Copyright (c) 2015 TENMYO Masakazu | |
| 4 | + | |
| 5 | +This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. | |
| 6 | + | |
| 7 | +Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: | |
| 8 | + | |
| 9 | +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. | |
| 10 | + | |
| 11 | +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. | |
| 12 | + | |
| 13 | +3. This notice may not be removed or altered from any source distribution. |
| @@ -0,0 +1,2 @@ | ||
| 1 | +powershell -ExecutionPolicy RemoteSigned -File %~dpn0.ps1 %* | |
| 2 | +@If Not Errorlevel 0 pause |
| @@ -0,0 +1,57 @@ | ||
| 1 | +# DoxygenのXMLを結合する | |
| 2 | +# 引数: Doxygen結果のxml格納フォルダ | |
| 3 | +[CmdletBinding()] | |
| 4 | +param( | |
| 5 | + [Parameter(Mandatory=$True)] | |
| 6 | + [string]$xml_dir | |
| 7 | +) | |
| 8 | + | |
| 9 | +# お約束 | |
| 10 | +Set-StrictMode -Version Latest | |
| 11 | +$ErrorActionPreference = "Stop" | |
| 12 | +$WarningPreference = "Continue" | |
| 13 | +$VerbosePreference = "Continue" | |
| 14 | +$DebugPreference = "Continue" | |
| 15 | +trap { | |
| 16 | + $Error | foreach { | |
| 17 | + Write-Debug $_.Exception.Message | |
| 18 | + Write-Debug $_.InvocationInfo.PositionMessage | |
| 19 | + } | |
| 20 | + Exit -1 | |
| 21 | +} | |
| 22 | + | |
| 23 | + | |
| 24 | +#### 処理 | |
| 25 | + | |
| 26 | +# パス準備 | |
| 27 | +$xml_dir = (Convert-Path $xml_dir) | |
| 28 | +[string]$xslt_path = (Join-Path $xml_dir combine.xslt) | |
| 29 | +[string]$index_path = (Join-Path $xml_dir index.xml) | |
| 30 | +[string]$combined_path = ($xml_dir + ".xml") | |
| 31 | + | |
| 32 | +# 存在チェック | |
| 33 | +if (-not (Test-Path $xslt_path)) { | |
| 34 | + Write-Host ("Error File Not Found: " + $xslt_path) -ForegroundColor red | |
| 35 | + Exit -1 | |
| 36 | +} | |
| 37 | +if (-not (Test-Path $index_path)) { | |
| 38 | + Write-Host ("Error File Not Found: " + $index_path) -ForegroundColor red | |
| 39 | + Exit -1 | |
| 40 | +} | |
| 41 | + | |
| 42 | +# 結合 | |
| 43 | +# XSLT読み込み | |
| 44 | +$xslt = New-Object System.Xml.Xsl.XslCompiledTransform | |
| 45 | +$xslt_setting = New-Object System.Xml.Xsl.XsltSettings | |
| 46 | +$xslt_setting.EnableDocumentFunction = $true | |
| 47 | +$xslt_setting.EnableScript = $true | |
| 48 | +$xslt.Load($xslt_path, $xslt_setting, $null) | |
| 49 | +# 出力準備 | |
| 50 | +$writer_setting = New-Object System.Xml.XmlWriterSettings | |
| 51 | +$writer_setting.Indent = $true | |
| 52 | +$writer = [System.Xml.XmlWriter]::Create($combined_path, $writer_setting) | |
| 53 | +# 変換 | |
| 54 | +$xslt.Transform($index_path, $writer) | |
| 55 | +# 終了 | |
| 56 | +$writer.Close() | |
| 57 | +Write-Host ("Complete Combine: " + $combined_path) -ForegroundColor green |
| @@ -0,0 +1,93 @@ | ||
| 1 | +#!/usr/bin/python | |
| 2 | +# -*- coding: utf-8 -*- | |
| 3 | +import collections | |
| 4 | +import sys | |
| 5 | +from pprint import pprint as pp | |
| 6 | + | |
| 7 | + | |
| 8 | +Member = collections.namedtuple("Member", "id kind is_static name fpath line") | |
| 9 | + | |
| 10 | + | |
| 11 | +def read_ctx(ctx_fpath): | |
| 12 | + ctx = collections.defaultdict(set) | |
| 13 | + with open(ctx_fpath) as ctx_file: | |
| 14 | + for line in ctx_file: | |
| 15 | + if line.startswith("#"): | |
| 16 | + continue | |
| 17 | + try: | |
| 18 | + (name, id) = line.rstrip().split() | |
| 19 | + except ValueError: | |
| 20 | + continue | |
| 21 | + ctx[id].add(name) | |
| 22 | + return ctx | |
| 23 | + | |
| 24 | + | |
| 25 | +def read_member(member_fpath): | |
| 26 | + member = dict() | |
| 27 | + with open(member_fpath) as member_file: | |
| 28 | + for line in member_file: | |
| 29 | + if line.startswith("#"): | |
| 30 | + continue | |
| 31 | + try: | |
| 32 | + (id, kind, static, name, fpath, line) = line.rstrip().split() | |
| 33 | + except ValueError: | |
| 34 | + continue | |
| 35 | + m = Member(id, kind, static=="yes", name, fpath, line) | |
| 36 | + member[m.id] = m | |
| 37 | + return member | |
| 38 | + | |
| 39 | + | |
| 40 | +def read_dep(dep_fpath): | |
| 41 | + dep = collections.defaultdict(set) | |
| 42 | + with open(dep_fpath) as dep_file: | |
| 43 | + for line in dep_file: | |
| 44 | + if line.startswith("#"): | |
| 45 | + continue | |
| 46 | + try: | |
| 47 | + (src, dst) = line.rstrip().split() | |
| 48 | + except ValueError: | |
| 49 | + continue | |
| 50 | + dep[src].add(dst) | |
| 51 | + return dep | |
| 52 | + | |
| 53 | + | |
| 54 | +def walk(ctx_id, src, dep, mark): | |
| 55 | + if ctx_id in mark[src]: | |
| 56 | + return | |
| 57 | + mark[src].add(ctx_id) | |
| 58 | + for dst in dep[src]: | |
| 59 | + walk(ctx_id, dst, dep, mark) | |
| 60 | + | |
| 61 | +def run(ctx_fpath, member_fpath, dep_fpath, mutex_fpath, | |
| 62 | + tgt_fpath, counter_fpath): | |
| 63 | + ctx = read_ctx(ctx_fpath) | |
| 64 | + pp(dict(ctx)) | |
| 65 | + | |
| 66 | + member = read_member(member_fpath) | |
| 67 | + pp(dict(member)) | |
| 68 | + | |
| 69 | + dep = read_dep(dep_fpath) | |
| 70 | + pp(dict(dep)) | |
| 71 | + | |
| 72 | + mark = collections.defaultdict(set) | |
| 73 | + for (ctx_id, names) in ctx.items(): | |
| 74 | + srcs = { m.id | |
| 75 | + for m | |
| 76 | + in member.values() | |
| 77 | + if m.name in names } | |
| 78 | + for src in srcs: | |
| 79 | + walk(ctx_id, src, dep, mark) | |
| 80 | + pp(dict(mark)) | |
| 81 | + | |
| 82 | + for (member_id, ctx_ids) in mark.items(): | |
| 83 | + if len(ctx_ids) <= 1: | |
| 84 | + continue | |
| 85 | + print(member_id, ",".join(ctx_ids)) | |
| 86 | + | |
| 87 | + | |
| 88 | +def main(argv): | |
| 89 | + run(*argv[1:]) | |
| 90 | + return 0 | |
| 91 | + | |
| 92 | +if __name__ == '__main__': | |
| 93 | + sys.exit(main(sys.argv)) |
| @@ -0,0 +1,2 @@ | ||
| 1 | +powershell -ExecutionPolicy RemoteSigned -File %~dpn0.ps1 %* | |
| 2 | +@If Not Errorlevel 0 pause |
| @@ -0,0 +1,47 @@ | ||
| 1 | +# Doxygenの結合XMLから各メンバ情報を出力する | |
| 2 | +# 引数: Doxygenの結合XML | |
| 3 | +[CmdletBinding()] | |
| 4 | +param( | |
| 5 | + [Parameter(Mandatory=$True)] | |
| 6 | + [string]$xml_path | |
| 7 | +) | |
| 8 | + | |
| 9 | +# お約束 | |
| 10 | +Set-StrictMode -Version Latest | |
| 11 | +$ErrorActionPreference = "Stop" | |
| 12 | +$WarningPreference = "Continue" | |
| 13 | +$VerbosePreference = "Continue" | |
| 14 | +$DebugPreference = "Continue" | |
| 15 | +trap { | |
| 16 | + $Error | foreach { | |
| 17 | + Write-Debug $_.Exception.Message | |
| 18 | + Write-Debug $_.InvocationInfo.PositionMessage | |
| 19 | + } | |
| 20 | + Exit -1 | |
| 21 | +} | |
| 22 | + | |
| 23 | + | |
| 24 | +#### 処理 | |
| 25 | + | |
| 26 | +# パス準備 | |
| 27 | +$xml_path = (Convert-Path $xml_path) | |
| 28 | +[string]$xslt_path = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path, ".xslt") | |
| 29 | +[string]$out_path = [System.IO.Path]::ChangeExtension($xml_path, "member.tsv") | |
| 30 | + | |
| 31 | +# 存在チェック | |
| 32 | +if (-not (Test-Path $xslt_path)) { | |
| 33 | + Write-Host ("Error File Not Found: " + $xslt_path) -ForegroundColor red | |
| 34 | + Exit -1 | |
| 35 | +} | |
| 36 | + | |
| 37 | +# 結合 | |
| 38 | +# XSLT読み込み | |
| 39 | +$xslt = New-Object System.Xml.Xsl.XslCompiledTransform | |
| 40 | +$xslt_setting = New-Object System.Xml.Xsl.XsltSettings | |
| 41 | +$xslt_setting.EnableDocumentFunction = $true | |
| 42 | +$xslt_setting.EnableScript = $true | |
| 43 | +$xslt.Load($xslt_path, $xslt_setting, $null) | |
| 44 | +# 変換 | |
| 45 | +$xslt.Transform($xml_path, $out_path) | |
| 46 | +# 終了 | |
| 47 | +Write-Host ("Complete: " + $out_path) -ForegroundColor green |
| @@ -0,0 +1,27 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<xsl:stylesheet version="1.0" | |
| 3 | + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
| 4 | + | |
| 5 | + <xsl:output method="text" encoding="Shift_JIS" /> | |
| 6 | + | |
| 7 | + <xsl:param name="delim" select="'	'" /> | |
| 8 | + <xsl:param name="break" select="'
'" /> | |
| 9 | + | |
| 10 | + <xsl:template match="/doxygen"> | |
| 11 | + <xsl:text>#id</xsl:text><xsl:value-of select="$delim" /> | |
| 12 | + <xsl:text>kind</xsl:text><xsl:value-of select="$delim" /> | |
| 13 | + <xsl:text>static</xsl:text><xsl:value-of select="$delim" /> | |
| 14 | + <xsl:text>name</xsl:text><xsl:value-of select="$delim" /> | |
| 15 | + <xsl:text>file</xsl:text><xsl:value-of select="$delim" /> | |
| 16 | + <xsl:text>line</xsl:text><xsl:value-of select="$break" /> | |
| 17 | + <xsl:for-each select="//memberdef"> | |
| 18 | + <xsl:value-of select="./@id" /><xsl:value-of select="$delim" /> | |
| 19 | + <xsl:value-of select="./@kind" /><xsl:value-of select="$delim" /> | |
| 20 | + <xsl:value-of select="./@static" /><xsl:value-of select="$delim" /> | |
| 21 | + <xsl:value-of select="./name" /><xsl:value-of select="$delim" /> | |
| 22 | + <xsl:value-of select="./location/@file" /><xsl:value-of select="$delim" /> | |
| 23 | + <xsl:value-of select="./location/@line" /><xsl:value-of select="$break" /> | |
| 24 | + </xsl:for-each> | |
| 25 | + </xsl:template> | |
| 26 | + | |
| 27 | +</xsl:stylesheet> |
| @@ -0,0 +1,2 @@ | ||
| 1 | +powershell -ExecutionPolicy RemoteSigned -File %~dpn0.ps1 %* | |
| 2 | +@If Not Errorlevel 0 pause |
| @@ -0,0 +1,47 @@ | ||
| 1 | +# Doxygenの結合XMLから関数からの参照情報を出力する | |
| 2 | +# 引数: Doxygenの結合XML | |
| 3 | +[CmdletBinding()] | |
| 4 | +param( | |
| 5 | + [Parameter(Mandatory=$True)] | |
| 6 | + [string]$xml_path | |
| 7 | +) | |
| 8 | + | |
| 9 | +# お約束 | |
| 10 | +Set-StrictMode -Version Latest | |
| 11 | +$ErrorActionPreference = "Stop" | |
| 12 | +$WarningPreference = "Continue" | |
| 13 | +$VerbosePreference = "Continue" | |
| 14 | +$DebugPreference = "Continue" | |
| 15 | +trap { | |
| 16 | + $Error | foreach { | |
| 17 | + Write-Debug $_.Exception.Message | |
| 18 | + Write-Debug $_.InvocationInfo.PositionMessage | |
| 19 | + } | |
| 20 | + Exit -1 | |
| 21 | +} | |
| 22 | + | |
| 23 | + | |
| 24 | +#### 処理 | |
| 25 | + | |
| 26 | +# パス準備 | |
| 27 | +$xml_path = (Convert-Path $xml_path) | |
| 28 | +[string]$xslt_path = [System.IO.Path]::ChangeExtension($MyInvocation.MyCommand.Path, ".xslt") | |
| 29 | +[string]$out_path = [System.IO.Path]::ChangeExtension($xml_path, "ref.tsv") | |
| 30 | + | |
| 31 | +# 存在チェック | |
| 32 | +if (-not (Test-Path $xslt_path)) { | |
| 33 | + Write-Host ("Error File Not Found: " + $xslt_path) -ForegroundColor red | |
| 34 | + Exit -1 | |
| 35 | +} | |
| 36 | + | |
| 37 | +# 結合 | |
| 38 | +# XSLT読み込み | |
| 39 | +$xslt = New-Object System.Xml.Xsl.XslCompiledTransform | |
| 40 | +$xslt_setting = New-Object System.Xml.Xsl.XsltSettings | |
| 41 | +$xslt_setting.EnableDocumentFunction = $true | |
| 42 | +$xslt_setting.EnableScript = $true | |
| 43 | +$xslt.Load($xslt_path, $xslt_setting, $null) | |
| 44 | +# 変換 | |
| 45 | +$xslt.Transform($xml_path, $out_path) | |
| 46 | +# 終了 | |
| 47 | +Write-Host ("Complete: " + $out_path) -ForegroundColor green |
| @@ -0,0 +1,23 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<xsl:stylesheet version="1.0" | |
| 3 | + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
| 4 | + | |
| 5 | + <xsl:output method="text" encoding="Shift_JIS" /> | |
| 6 | + | |
| 7 | + <xsl:param name="delim" select="'	'" /> | |
| 8 | + <xsl:param name="break" select="'
'" /> | |
| 9 | + | |
| 10 | + <xsl:template match="/doxygen"> | |
| 11 | + <xsl:text>#src_id</xsl:text><xsl:value-of select="$delim" /> | |
| 12 | + <xsl:text>dst_id</xsl:text><xsl:value-of select="$break" /> | |
| 13 | + <xsl:for-each select="//memberdef[@kind="function"]/references"> | |
| 14 | + <xsl:value-of select="../@id" /><xsl:value-of select="$delim" /> | |
| 15 | + <xsl:value-of select="./@refid" /><xsl:value-of select="$break" /> | |
| 16 | + </xsl:for-each> | |
| 17 | + <xsl:for-each select="//memberdef[@kind="function"]/referencedby"> | |
| 18 | + <xsl:value-of select="./@refid" /><xsl:value-of select="$delim" /> | |
| 19 | + <xsl:value-of select="../@id" /><xsl:value-of select="$break" /> | |
| 20 | + </xsl:for-each> | |
| 21 | + </xsl:template> | |
| 22 | + | |
| 23 | +</xsl:stylesheet> |