VC 60VS系列自动生成函数注释 DSM宏工具源代码.docx

上传人:b****8 文档编号:28716950 上传时间:2023-07-19 格式:DOCX 页数:55 大小:456.99KB
下载 相关 举报
VC 60VS系列自动生成函数注释 DSM宏工具源代码.docx_第1页
第1页 / 共55页
VC 60VS系列自动生成函数注释 DSM宏工具源代码.docx_第2页
第2页 / 共55页
VC 60VS系列自动生成函数注释 DSM宏工具源代码.docx_第3页
第3页 / 共55页
VC 60VS系列自动生成函数注释 DSM宏工具源代码.docx_第4页
第4页 / 共55页
VC 60VS系列自动生成函数注释 DSM宏工具源代码.docx_第5页
第5页 / 共55页
点击查看更多>>
下载资源
资源描述

VC 60VS系列自动生成函数注释 DSM宏工具源代码.docx

《VC 60VS系列自动生成函数注释 DSM宏工具源代码.docx》由会员分享,可在线阅读,更多相关《VC 60VS系列自动生成函数注释 DSM宏工具源代码.docx(55页珍藏版)》请在冰豆网上搜索。

VC 60VS系列自动生成函数注释 DSM宏工具源代码.docx

VC60VS系列自动生成函数注释DSM宏工具源代码

VC6.0&VS2003~2011系列自动生成函数注释DSM宏工具源代码

工具:

(需账号)

/Files/Lhw978/VC6.0-VS2003-2011系列自动生成函数注释.rar

VC6.0效果:

 

用法:

VC6.0函数注释.DSM:

/Files/Lhw978/VC6.0-VS2003-2011系列自动生成函数注释.rar

转载请注明本文出处:

 

1。

将本VC6.0函数注释.DSM文件放到VC的安装路径,如C:

\ProgramFiles\MicrosoftVisualStudio\common\MSDev98\Macros

2。

在VC6.0的Tool|Customize...的“Add-inandMacroFIles”中添加刚才的VC6.0函数注释.DSM

3。

之后整行选中函数的申明,包括函数返回类型、函数名、参数列表。

4。

在VC6.0的Tool|Macro中,现在MacroFile选择VC6.0函数注释, 之后选择FunctionHead,点击run按钮即可生成注释。

             

   也可利用Tool|Customize...中的“Command”,将Macro子项下的FunctionHead拖动到工具栏,并添加工具栏按钮:

     

之后,选择笑脸图标:

    

即可在工具栏中添加一个笑脸按钮用于注释:

以后,先整行选中函数的申明,包括函数返回类型、函数名、参数列表,之后单击工具栏这个按钮即可生成注释。

 

此脚本适合于VC6.0。

对于VS2003或更高版本,需要做适当的少量修改(对于VS2005,一定要先打上SP1补丁包):

VS2003-2011系列的用法:

1.  在VS2005开发环境中打开“工具|宏|新建宏项目”菜单,输入一个宏项目的名称,比如FunctionComment。

之后在右侧的“宏资源管理器”中的FunctionComment下自动生成Module1。

2.  双击Module1,则探出“MicrosoftVisualStudioMacros”编辑器窗口。

3.  在“MicrosoftVisualStudioMacros”编辑器窗口左侧双击FunctionComment中的Module1,之后在对应的编辑窗口中的Public Module Module1 和  End Module 之间插入 VS2005.txt 中的所有文本。

4.  关闭“MicrosoftVisualStudioMacros”编辑器窗口,并回到VS2005开发环境中。

5.  整行选中 函数的申明,包括函数返回类型、函数名、参数列表,并双击右侧右侧的“宏资源管理器”中的FunctionComment下自动生成Module1中的FunctionHead,即可生成和VC6.0种一样的函数注释。

 

6.  也可在VS2005开发环境中打开“工具|自定义”菜单的“命令|宏”中为FunctionHead设定工具栏图标(拖动即可)和键盘快捷键:

 

 

 

 

附VC6.0的DSM宏文件源代码:

'****************************************************************************

'------(C)Lhw978@----

'文件名:

Commentate.DSM

'作者:

劲草...无香

'日期:

2010-2-1023:

57:

31

'功能:

本文档中提供了让VC6.0为C/C++和VBscript文档添加文档注释、函数注释

'和修改记录的VBscript脚本函数,详见各个脚本函数的具体注释和代码。

'版权归属:

本文档的所有权由作者劲草...无香保留,只能用于学习交流,不能用于任何商业或其他非法目的

'事实:

DeveloperStudio提供取消运行宏的手段,当宏运行时,DeveloperStudio宏图标

'显示在windows任务栏右边的系统区中。

双击这个图标,显示结束宏的确认消息。

'因为在确认消息显示时,宏继续运行,所以,必须要尽快对此消息作出反应。

'备注:

本文件中所有的变量名都需要用Dim显式定义

'在Sub过程名下一行紧跟'DESCRIPTION:

XXX,则XXX将作为注释信息显示在宏列表窗口下方做为注解

'***************************************************************************

'ExecuteCommand"UserTool7"'calltheusertoolintheToolsmenu.

 

OptionExplicit'必须对变量进行显式声明

ConstconAuthor="劲草...无香",conEmail="Lhw978@"

ConstconPreComment="//",conPreVBComment="'"

'****************************************************************************

'函数名:

FileExt

'作者:

劲草...无香

'日期:

2010-2-1022:

37:

58

'功能:

提取doc文档对象的小写的文件扩展名

'输入参数:

doc-ByVal值类型,Document内置对象

'返回值:

Function过程.doc文档对象的扩展名(包含"."),如".cpp"

'修改记录:

本过程源自SAMPLE.DSM,并加以修改。

'备注:

返回值被转换为小写,且包含"."

'***************************************************************************

FunctionFileExt(ByValdoc)

'DESCRIPTION:

?

?

doc?

?

?

?

?

?

?

?

?

?

?

?

?

DimstrExt

DimintPos

strExt=doc.Name

FileExt=""

intPos=Instr(strExt,".")

IfintPos>0Then

DoWhileintPos<>1

strExt=Mid(strExt,intPos,Len(strExt)-intPos+1)

intPos=Instr(strExt,".")

Loop

strExt=LCase(strExt)

EndIf

FileExt=strExt

EndFunction

'****************************************************************************

'过程名:

DelComment

'作者:

劲草...无香

'日期:

2010-2-1023:

12:

16

'功能:

消除块注释/*...*/和行注释//...

'输入参数:

strCode-待操作的代码

'返回值:

Function过程.返回取消注释后的代码

'修改记录:

'备注:

调用此函数消除行注释时,应确保回车/换行符完整

'***************************************************************************

FunctionDelComment(ByValstrCode)

'DESCRIPTION:

消除块注释/*...*/和行注释//...

Dimi

DelComment=""

i=1

DoWhilei<=Len(strCode)

If"/"=Mid(strCode,i,1)_

Andi+1<=Len(StrCode)And"*"=Mid(strCode,i+1,1)Then'检测块注释

i=i+2

DoWhilei

If"*"=Mid(strCode,i,1)And"/"=Mid(strCode,i+1,1)Then

i=i+1

ExitDo'跳出Do循环

EndIf

i=i+1

Loop

ElseIf"/"=Mid(strCode,i,1)_

Andi+1<=Len(StrCode)AndMid(strCode,i+1,1)="/"Then'检测行注释

i=i+2

DoWhilei<=Len(strCode)'跳过行注释(让i指向行注释的末尾)

IfvbLf=Mid(strCode,i,1)OrvbCr=Mid(strCode,i,1)Then

ExitDo'跳出Do循环

EndIf

i=i+1

Loop

Else

DelComment=DelComment+Mid(strCode,i,1)

EndIf

i=i+1

Loop

EndFunction

'****************************************************************************

'过程名:

ExtractComment

'作者:

劲草...无香

'日期:

2010-2-1023:

27:

03

'功能:

提取strCode中intCommentPos以后的第一个块注释或行注释

'输入参数:

strCode-源代码

'intCommentPos-引用类型,输入为注释起始提取位置,输出为注释结束提取位置

'返回值:

Function过程.返回提取到的注释(已除去两端空格)和结束位置,若没有注释则

'intCommentPos返回起始提取位置.

'修改记录:

'备注:

调用此函数提取行注释时,应确保回车、换行符完整。

'***************************************************************************

FunctionExtractComment(ByValstrCode,ByRefintCommentPos)

'DESCRIPTION:

提取strCode中intCommentPos以后的第一个块注释或行注释

Dimi

DimblnLFComment

i=intCommentPos

ExtractComment=""

DoWhilei<=Len(strCode)

If"/"=Mid(strCode,i,1)_

Andi+1<=Len(StrCode)And"*"=Mid(strCode,i+1,1)Then'检测块注释

i=i+2

blnLFComment=False

DoWhilei

If"*"=Mid(strCode,i,1)And"/"=Mid(strCode,i+1,1)Then

i=i+1

ExitDo'跳出Do循环

EndIf

IfvbLf=Mid(strCode,i,1)OrvbCr=Mid(strCode,i,1)Then

blnLFComment=True'处理注释中的换行

ExtractComment=ExtractComment+Mid(strCode,i,1)

ElseIfblnLFComment=TrueThen

IfMid(strCode,i,1)<>""AndMid(strCode,i,1)<>vbTabThen

ExtractComment=ExtractComment+conPreComment+""+Mid(strCode,i,1)

blnLFComment=False

EndIf

Else

ExtractComment=ExtractComment+Mid(strCode,i,1)

EndIf

i=i+1

Loop

intCommentPos=i

ExtractComment=Trim(ExtractComment)

ExitFunction'跳出函数

ElseIf"/"=Mid(strCode,i,1)_

Andi+1<=Len(StrCode)And"/"=Mid(strCode,i+1,1)Then'检测行注释

i=i+2

DoWhilei<=Len(strCode)'跳过行注释(让i指向行注释的末尾)

IfvbLf=Mid(strCode,i,1)OrvbCr=Mid(strCode,i,1)Then

ExitDo

EndIf

ExtractComment=ExtractComment+Mid(strCode,i,1)

i=i+1

Loop

ExtractComment=Trim(Replace(ExtractComment,"*/",""))

intCommentPos=i

ExitFunction'跳出函数

Else

'intCommentPos=i

'ExitFunction

EndIf

i=i+1

Loop

EndFunction

'****************************************************************************

'过程名:

IsCommentForPreParam

'作者:

劲草...无香

'日期:

2010-2-1023:

39:

13

'功能:

判断当前行的注释是否属于上一参数(1:

属于,0:

不属于)

'输入参数:

strCode-待操作的代码

'intLastPos-反向解析位置

'返回值:

Function过程.(1:

属于,0:

不属于)

'修改记录:

'备注:

'***************************************************************************

FunctionIsCommentForPreParam(ByValstrCode,ByValintLastPos)

'DESCRIPTION:

判断当前行的注释是否属于上一参数(1:

属于,0:

不属于)

Dimi

'判断当前行的注释是否属于上一参数(1:

属于,0:

不属于)

IsCommentForPreParam=0

Fori=intLastPosTo1Step-1

IfInstr(",();",Mid(strCode,i,1))Then

IsCommentForPreParam=1

ExitFunction'跳出函数

ElseIfvbLf=Mid(strCode,i,1)OrvbCr=Mid(strCode,i,1)Then

ExitFunction

ElseIfNot(""=Mid(strCode,i,1)OrvbTab=Mid(strCode,i,1))Then

ExitFunction'跳出函数

EndIf

Next

EndFunction

'****************************************************************************

'过程名:

ParseFuncNameAndType

'作者:

劲草...无香

'日期:

2010-2-1023:

41:

34

'功能:

根据strParamList(0,0)和(0,1)分理出正确的函数名\函数类型\类名

'输入参数:

strParamList(0,3)数组-待解析的函数信息

'返回值:

Sub过程.

'修改记录:

'备注:

strParamList(0,0):

类型,(0,1):

名称,(0,2):

所属类名,(0,3):

注释。

'***************************************************************************

SubParseFuncNameAndType(ByRefstrParamList)

'DESCRIPTION:

根据strParamList(0,0)和(0,1)分理出正确的函数名\函数类型\类名

ConstconCurRow=0

DimintPosTmp

'根据strParamList(0,0)和strParamList(0,1)分理出正确的函数名\函数类型\类名

If""=Trim(strParamList(conCurRow,1))Then'没有函数类型

strParamList(conCurRow,1)=strParamList(conCurRow,0)

strParamList(conCurRow,0)="void"

EndIf

intPosTmp=InstrRev(strParamList(conCurRow,1),":

:

",-1,1)'分解类名

IfintPosTmp>0Then'类名在函数名部分

strParamList(conCurRow,2)=Trim(Left(strParamList(conCurRow,1),intPosTmp-1))

strParamList(conCurRow,1)=Right(strParamList(conCurRow,1),_

Len(strParamList(conCurRow,1))-(intPosTmp+1))

intPosTmp=InstrRev(strParamList(conCurRow,2),"",-1,1)

IfintPosTmp>0Then'类名中包含了类型信息

strParamList(conCurRow,0)=strParamList(conCurRow,0)_

+""+Left(strParamList(conCurRow,2),intPosTmp-1)

strParamList(conCurRow,2)=Right(strParamList(conCurRow,2),_

Len(strParamList(conCurRow,2))-intPosTmp)

EndIf

'msgbox"0:

"+strParamList(conCurRow,0)+"1:

"+strParamList(conCurRow,1)_

'+"2:

"+strParamList(conCurRow,2)+"3:

"+strParamList(conCurRow,3)

Else

intPosTmp=InstrRev(strParamList(conCurRow,0),":

:

",-1,1)

IfintPosTmp>0Then'类名在类型部分

strParamList(conCurRow,2)=Left(strParamList(conCurRow,0),intPosTmp-1)

strParamList(conCurRow,1)=Right(strParamList(conCurRow,0),_

Len(strParamList(conCurRow,0))-(intPosTmp+1))+""+strParamList(conCurRow,1)

strParamList(conCurRow,0)="void"

Else

strParamList(conCurRow,2)=""

strParamList(conCurRow,1)=Trim(strParamList(conCurRow,1))

intPosTmp=InstrRev(strParamList(conCurRow,1),"",-1,1)

IfintPosTmp>0Then'函数名中包含了类型信息

strParamList(conCurRow,0)=Trim(strParamList(conCurRow,0))_

+""+Left(strParamList(conCurRow,1),intPosTmp-1)

strParamList(conCurRow,1)=Right(strParamList(conCurRow,1),_

Len(strParamList(conCurRow,1))-intPosTmp)

EndIf

EndIf

EndIf

EndSub

'****************************************************************************

'过程名:

GetFuncParam

'作者:

劲草...无香

'日期:

2010-2-1023:

43:

43

'功能:

获取函数的返回类型和参数表.

'输入参数:

strFunc-完整的函数定义代码

'strParamList(20,4)-2维数组,用于存放要输出的参数列表.

'返回值:

Function过程.返回strParamList中的有效参数个数,并通过数组

'strParamList(20,4)返回参数列表(第一行strParamList(0)为函数类型和函数名).

'修改记录:

'备注:

strFunc须为完整的函数定义,且符合函数定义语法规则,否则可能会得到

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1