sourceinsight 头文件和函数注释的宏实现
2024-09-05 09:21:54
插入文件注释代码实现
macro InsertFileComment()
{ hbuf = GetCurrentBuf()
ln =
szName = "pengchao"
szContent = "";
SysTime = GetSysTime()
szYear=SysTime.Year
InsBufLine(hbuf, ln + , "/********************************************************************************")
InsBufLine(hbuf, ln + , "")
InsBufLine(hbuf, ln + , " **** Copyright (C), @szYear@, xx xx xx xx info&tech Co., Ltd. ****")
InsBufLine(hbuf, ln + , "")
InsBufLine(hbuf, ln + , " ********************************************************************************")
sz = GetFileName(GetBufName (hbuf))
InsBufLine(hbuf, ln + , " * File Name : @sz@")
InsBufLine(hbuf, ln + , " * Author : @szName@")
SysTime = GetSysTime()
sz=SysTime.Year
sz1=SysTime.month
sz3=SysTime.day
if (sz1 < )
{
szMonth = "0@sz1@"
}
else
{
szMonth = sz1
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
}
InsBufLine(hbuf, ln + , " * Date : @sz@-@szMonth@-@szDay@") szTmp = " * Description : "
nlnDesc = ln
iLen = strlen (szContent)
InsBufLine(hbuf, ln + , " * Description : @szContent@")
InsBufLine(hbuf, ln + , " * Version : 1.0")
InsBufLine(hbuf, ln + ," * Function List :")
InsBufLine(hbuf, ln + ," * ")
//插入函数列表 InsBufLine(hbuf, ln + , " * Record :")
InsBufLine(hbuf, ln + , " * 1.Date : @sz@-@szMonth@-@szDay@")
InsBufLine(hbuf, ln + , " * Author : @szName@")
InsBufLine(hbuf, ln + , " * Modification: Created file")
InsBufLine(hbuf, ln + , "")
InsBufLine(hbuf, ln + , "*************************************************************************************************************/")
InsBufLine(hbuf, ln + , "") if(iLen != )
{
return
} //如果没有功能描述内容则提示输入
//szContent = Ask("Description")
SetBufIns(hbuf,nlnDesc + ,)
DelBufLine(hbuf,nlnDesc +) //注释输出处理,自动换行
CommentContent(hbuf,nlnDesc + ," Description : ",szContent,)
}
插入函数注释代码实现
macro InsertFuncComment()
//macro FuncHeadCommentEN(hbuf, ln, szFunc, szMyName,newFunc)
{
hbuf = GetCurrentBuf()
hwnd = GetCurrentWnd()
ln = GetWndSelLnFirst(hwnd)
szMyName = "pengchao"
szFunc = GetCurSymbol()
newFunc =
iIns =
if(newFunc != )
{
symbol = GetSymbolLocationFromLn(hbuf, ln)
if(strlen(symbol) > )
{
hTmpBuf = NewBuf("Tempbuf") //将文件参数头整理成一行并去掉了注释
szLine = GetFunctionDef(hbuf,symbol)
iBegin = symbol.ichName //取出返回值定义
szTemp = strmid(szLine,,iBegin)
szTemp = TrimString(szTemp)
szRet = GetFirstWord(szTemp)
if(symbol.Type == "Method")
{
szTemp = strmid(szTemp,strlen(szRet),strlen(szTemp))
szTemp = TrimString(szTemp)
if(szTemp == "::")
{
szRet = ""
}
}
if(toupper (szRet) == "MACRO")
{
//对于宏返回值特殊处理
szRet = ""
} //从函数头分离出函数参数
nMaxParamSize = GetWordFromString(hTmpBuf,szLine,iBegin,strlen(szLine),"(",",",")")
lnMax = GetBufLineCount(hTmpBuf)
ln = symbol.lnFirst
SetBufIns (hbuf, ln, )
}
}
else
{
lnMax =
szRet = ""
szLine = ""
}
InsBufLine(hbuf, ln, "/*****************************************************************************")
InsBufLine(hbuf, ln+, " * Function : @szFunc@")
InsBufLine(hbuf, ln+, " * Description : ")
oldln = ln
szIns = " * Input : "
if(newFunc != )
{
//对于已经存在的函数输出输入参数表
i =
while ( i < lnMax)
{
szTmp = GetBufLine(hTmpBuf, i)
nLen = strlen(szTmp); //对齐参数后面的空格,实际是对齐后面的参数的说明
szBlank = CreateBlankString(nMaxParamSize - nLen + )
szTmp = cat(szTmp,szBlank)
ln = ln +
szTmp = cat(szIns,szTmp)
InsBufLine(hbuf, ln+, "@szTmp@")
iIns =
szIns = " "
i = i +
}
closebuf(hTmpBuf)
}
if(iIns == )
{
ln = ln +
InsBufLine(hbuf, ln+, " * Input : None")
}
InsBufLine(hbuf, ln+, " * Output : None")
InsBufLine(hbuf, ln+, " * Return : @szRet@")
/*InsBufLine(hbuf, ln+5, " Calls : ")
InsBufLine(hbuf, ln+6, " Called By : ")*/
InsbufLIne(hbuf, ln+, " * Others : "); SysTime = GetSysTime();
sz1=SysTime.Year
sz2=SysTime.month
sz3=SysTime.day
if (sz2 < )
{
szMonth = "0@sz2@"
}
else
{
szMonth = sz2
}
if (sz3 < )
{
szDay = "0@sz3@"
}
else
{
szDay = sz3
} InsBufLine(hbuf, ln + , " * Record")
InsBufLine(hbuf, ln + , " * 1.Date : @sz1@@szMonth@@szDay@")
InsBufLine(hbuf, ln + , " * Author : @szMyName@")
InsBufLine(hbuf, ln + , " * Modification: Created function")
InsBufLine(hbuf, ln + , "")
InsBufLine(hbuf, ln + , "*****************************************************************************/")
if ((newFunc == ) && (strlen(szFunc)>))
{
InsBufLine(hbuf, ln+, "VOS_UINT32 @szFunc@( # )")
InsBufLine(hbuf, ln+, "{");
InsBufLine(hbuf, ln+, " #");
InsBufLine(hbuf, ln+, "}");
SearchForward()
}
hwnd = GetCurrentWnd()
if (hwnd == )
stop
sel = GetWndSel(hwnd)
sel.ichFirst =
sel.ichLim = sel.ichFirst
sel.lnFirst = ln +
sel.lnLast = ln +
//szContent = Ask("Description")
DelBufLine(hbuf,oldln + )
setWndSel(hwnd,sel)
newln = CommentContent(hbuf,oldln + ," * Description : ",szContent,) -
ln = ln + newln - oldln
if ((newFunc == ) && (strlen(szFunc)>))
{
//提示输入函数返回值名
szRet = Ask("Please input return value type")
if(strlen(szRet) > )
{
PutBufLine(hbuf, ln+, " * Return : @szRet@")
PutBufLine(hbuf, ln+, "@szRet@ @szFunc@( # )")
SetbufIns(hbuf,ln+,strlen(szRet)+strlen(szFunc) +
}
szFuncDef = ""
isFirstParam =
sel.ichFirst = strlen(szFunc)+strlen(szRet) +
sel.ichLim = sel.ichFirst + //循环输入新函数的参数
while ()
{
szParam = ask("Please input parameter")
szParam = TrimString(szParam)
szTmp = cat(szIns,szParam)
szParam = cat(szFuncDef,szParam)
sel.lnFirst = ln +
sel.lnLast = ln +
setWndSel(hwnd,sel)
sel.ichFirst = sel.ichFirst + strlen(szParam)
sel.ichLim = sel.ichFirst
oldsel = sel
if(isFirstParam == )
{
PutBufLine(hbuf, ln+, "@szTmp@")
isFirstParam =
}
else
{
ln = ln +
InsBufLine(hbuf, ln+, "@szTmp@")
oldsel.lnFirst = ln +
oldsel.lnLast = ln +
}
SetBufSelText(hbuf,szParam)
szIns = " "
szFuncDef = ", "
oldsel.lnFirst = ln +
oldsel.lnLast = ln +
oldsel.ichFirst =
oldsel.ichLim =
setWndSel(hwnd,oldsel)
}
}
return ln +
}
使用步骤:
1、创建一个quicker.em文件,添加到base工程
/*****************************************************************************
�� �� �� : AutoExpand
�������� : ��չ������ں���
������� : ��
�� �� ֵ :
���ú��� :
�������� : ����ʷ :
1.�� �� : 2008��6��18��
�� �� : ��ǿ
������ : �� *****************************************************************************/
macro AutoExpand()
{
//������Ϣ
// get window, sel, and buffer handles
hwnd = GetCurrentWnd()
if (hwnd == 0)
stop
sel = GetWndSel(hwnd)
if(sel.lnFirst != sel.lnLast)
{
/*�������*/
BlockCommandProc()
}
if (sel.ichFirst == 0)
stop
hbuf = GetWndBuf(hwnd)
language = getreg(LANGUAGE)
if(language != 1)
{
language = 0
}
nVer = 0
nVer = GetVersion()
/*ȡ���û���*/
szMyName = getreg(MYNAME)
if(strlen( szMyName ) == 0)
{
szMyName = Ask("Enter your name:")
setreg(MYNAME, szMyName)
}
// get line the selection (insertion point) is on
szLine = GetBufLine(hbuf, sel.lnFirst);
// parse word just to the left of the insertion point
wordinfo = GetWordLeftOfIch(sel.ichFirst, szLine)
ln = sel.lnFirst;
chTab = CharFromAscii(9) // prepare a new indented blank line to be inserted.
// keep white space on left and add a tab to indent.
// this preserves the indentation level.
chSpace = CharFromAscii(32);
ich = 0
while (szLine[ich] == chSpace || szLine[ich] == chTab)
{
ich = ich + 1
}
szLine1 = strmid(szLine,0,ich)
szLine = strmid(szLine, 0, ich) # " " sel.lnFirst = sel.lnLast
sel.ichFirst = wordinfo.ich
sel.ichLim = wordinfo.ich /*�Զ���ɼ������ƥ����ʾ*/
wordinfo.szWord = RestoreCommand(hbuf,wordinfo.szWord)
sel = GetWndSel(hwnd)
if (wordinfo.szWord == "pn") /*���ⵥ�ŵĴ���*/
{
DelBufLine(hbuf, ln)
AddPromblemNo()
return
}
/*��������ִ��*/
else if (wordinfo.szWord == "config" || wordinfo.szWord == "co")
{
DelBufLine(hbuf, ln)
ConfigureSystem()
return
}
/*����ʷ��¼����*/
else if (wordinfo.szWord == "hi")
{
InsertHistory(hbuf,ln+1,language)
DelBufLine(hbuf, ln)
return
}
else if (wordinfo.szWord == "abg")
{
sel.ichFirst = sel.ichFirst - 3
SetWndSel(hwnd,sel)
InsertReviseAdd()
PutBufLine(hbuf, ln+1 ,szLine1)
SetBufIns(hwnd,ln+1,sel.ichFirst)
return
}
else if (wordinfo.szWord == "dbg")
{
sel.ichFirst = sel.ichFirst - 3
SetWndSel(hwnd,sel)
InsertReviseDel()
PutBufLine(hbuf, ln+1 ,szLine1)
SetBufIns(hwnd,ln+1,sel.ichFirst)
return
}
else if (wordinfo.szWord == "mbg")
{
sel.ichFirst = sel.ichFirst - 3
SetWndSel(hwnd,sel)
InsertReviseMod()
PutBufLine(hbuf, ln+1 ,szLine1)
SetBufIns(hwnd,ln+1,sel.ichFirst)
return
}
if(language == 1)
{
ExpandProcEN(szMyName,wordinfo,szLine,szLine1,nVer,ln,sel)
}
else
{
ExpandProcCN(szMyName,wordinfo,szLine,szLine1,nVer,ln,sel)
}
} /*****************************************************************************
�� �� �� : ExpandProcEN
�������� : Ӣ��˵������չ�����
������� : szMyName �û���
wordinfo
szLine
szLine1
nVer
ln
sel
������� : ��
�� �� ֵ :
���ú��� :
�������� : ����ʷ :
1.�� �� : 2008��6��19��
�� �� : ��ǿ
������ : �����ɺ��� 2.�� �� : 2011��2��16��
�� �� : ���
������ : �����ⵥ��Ϊmantis�ţ���ʱ���ʽΪxxxxxxxx���ꡢ�¡��գ���
�м�û�зָ�������ӵ���ע�ͣ��Զ���չ��Ϊ"an" 3.�� �� : 2011��2��22��
�� �� : ���
������ : �ĵ���ע��ͷΪadd by��delete by��modify by���Զ���չ��ֱ�Ϊ"as"��"ds"��"ms"
�ĵ���ע��Ϊ��������е���最新文章
- tail -f 和 -F 的用法
- 一步一步安装hive
- 理解Docker容器的进程管理
- ZOJ 2334 Monkey King
- git 学习笔记6--remote &; log
- ArcGIS Engine 中 Geometric Network 显示流向代码
- c#获取网页内容的三种方法
- 在String()构造器不存在的情况下自定义一个MyString()函数,实现如下内建String()方法和属性:
- asp.net mvc NPOI 生成Excel文件
- 练习--LINUX进程间通信之有名管理FIFO
- Longest Consecutive Sequence——Leetcode
- d038: 星罗密布
- linux系统安装iprouter
- 第一周作业.四则运算生成器(基于python)
- C++与Java,C#的异同(一):值,地址,引用
- MongoDB操作(1)—MongoDB java驱动核心层次结构及操作流程
- vc++基础班[24]---系统各种路径信息的获取
- web页面加载、解析、渲染过程
- Mysql中 in or exists not exists not in区别 (网络整理)
- 5、在Dreamweaver cc 2017中添加服务器扩展组件
热门文章