sourceinsight 头文件和函数注释的宏实现
插入文件注释代码实现
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"
�ĵ���ע��Ϊ��������е���sourceinsight 头文件和函数注释的宏实现的更多相关文章
- C/C++常用头文件及函数汇总
转自: C/C++常用头文件及函数汇总 C/C++头文件一览 C #include <assert.h> //设定插入点#include <ctype.h> //字符处理#in ...
- C语言常用的库文件(头文件、函数库)
C语言常用的库文件(头文件.函数库) C系统提供了丰富的系统文件,称为库文件.C的库文件分为两类,一类是扩展名为".h"的文件,称为头文件,在前面的包含命令中我们已多次使用过.在& ...
- sstream头文件-getline 函数 和 stringstream函数 和string的常见用法
2017-08-12 19:50:50 writer:pprp getline函数可以读入一行的字符,不论有没有空格 第一个参数,流 第二个参数 ,将流读入的地方 第三个参数,当读到某个字符的时候停止 ...
- include <ctype.h> 头文件包含函数总结
里面包含的函数主要是: 1.字符测试函数,函数原型一般为:int isXXXX( int ); 参数为int, 只能正确处理[0, 127]. 2.字符映射函数,函数原型一般为:int toXXXX( ...
- glibc头文件和宏定义
头文件没啥好说的,无非就是" "和< >的区别,这估计只要是学过C/C++的人都明白.现在的编译器对头文件的包含顺序没有要求,但老的C实现则不一样.当然,我们现在无需关 ...
- extern,头文件和ifndif宏
转自:CSDN->fpmystar 用#include可以包含其他头文件中变量.函数的声明,为什么还要extern关键字,如果我想引用一个全局变量或函数f(),我只要直接在源文件中包含#incl ...
- gcc 头文件是用户应用程序和函数库之间的桥梁和纽带 功能的真正逻辑实现是以硬件层为基础
gcc GCC, the GNU Compiler Collection - GNU Project - Free Software Foundation (FSF) http://gcc.gnu.o ...
- App开发流程之通用宏定义及头文件
工欲善其事,必先利其器. 在正式实现各种炫酷的功能和UI前,做好准备工作是提高后续开发效率的必经之路. 所以,这个系列,我不是在各种堆技术,更关注的是“兵马动”之前的“粮草行”,有些繁琐,但当清晰理出 ...
- sort()函数与qsort()函数及其头文件
sort()函数与qsort()函数及其头文件 sort()函数是C++中的排序函数其头文件为:#include<algorithm>头文件: qsort()是C中的排序函数,其头文件为: ...
随机推荐
- 关于greenlet的一些问题
今天测试关于协程方面的代码发现我安装了greenlet模块缺导入不进.如图: 后来找了半天才发现原来greenlet被整进了gevent包中,如下导入就可以成功: 但这个greenlet没有了swit ...
- matplotlib 画图中的basemap安装问题
在我用matplotlib画图是会用到,basemap这个库,但是直接安装却会出现问题: 使用这条安装命令就能够安装功能了: conda install -c conda-forge basemap= ...
- 7.Linux查找目录下的所有文件中是否含有某个字符串
grep -rn "map" * 说明:-r 是递归查找-n 是显示行号* : 表示当前目录所有文件,也可以是某个文件名
- k8s组件通信或者创建pod生命周期
Kubernetes 多组件之间的通信原理: apiserver 负责 etcd 存储的所有操作,且只有 apiserver 才直接操作 etcd 集群 apiserver 对内(集群中的其他组件)和 ...
- Spring MVC 探讨DispatcherServlet
先上DispatcherServlet的运行流程图(request processing):
- win10下面opencv安装
记得以前是安装好的,但是用了conda更新所有包以后,cv2不好用了,试验了很多方法都不管用,最后只能卸载opencv然后重新安装了. 如果电脑上安装了很多版本的python,比如我就安装了pytho ...
- JS基础_函数的参数
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Django rest-framework框架-解析器
解析器: 开始: django: request.POST/ request.body 满足一下两个要求POST中才有值 1. 如果请求头中的 Content-Type: application/x- ...
- SpringBoot 中aop整合方法执行日志
今天事情不多, 处理完手中的事边想着捣鼓一下AOP, 着手开始写才发现, 多久不用, 自己已经忘得差不多了, 捣鼓半天之后, 慢慢整出这个小demo,以便于以后查阅回顾 1 .先创建一个注解, 用来作 ...
- dedecms Fatal error: Out of memory
max_execution_time = 300 php执行持续最长时间 比如:网站全站更新max_input_time = 30 php传送数据最长时间 比如:上传大文件memory_l ...